From 35129f2192dff3f47d740c6ab80a7b8905dd0ffe Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Fri, 6 Feb 2015 16:33:33 +0100
Subject: [PATCH] Fix PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS option not
 correctly supported. Fix: No limit on ldap search on dolibarr side.

---
 htdocs/core/class/ldap.class.php |  3 +++
 htdocs/fourn/facture/card.php    | 11 ++++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php
index 95436a51e29..dc844ee3f02 100644
--- a/htdocs/core/class/ldap.class.php
+++ b/htdocs/core/class/ldap.class.php
@@ -176,7 +176,10 @@ class Ldap
 
 			if (is_resource($this->connection))
 			{
+				// Execute the ldap_set_option here (after connect and before bind)
 				$this->setVersion();
+				ldap_set_option($this->connection, LDAP_OPT_SIZELIMIT, 0); // no limit here. should return true.
+
 
 				if ($this->serverType == "activedirectory")
 				{
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index f3e752ed9d4..26aeffad655 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -1270,14 +1270,14 @@ if ($action == 'create')
     print '<tr><td class="fieldrequired">'.$langs->trans('Supplier').'</td>';
     print '<td>';
 
-    if ($_REQUEST['socid'] > 0)
+    if (GETPOST('socid') > 0)
     {
         print $societe->getNomUrl(1);
-        print '<input type="hidden" name="socid" value="'.$_GET['socid'].'">';
+        print '<input type="hidden" name="socid" value="'.GETPOST('socid','int').'">';
     }
     else
     {
-        print $form->select_company((empty($_GET['socid'])?'':$_GET['socid']),'socid','s.fournisseur = 1',1);
+        print $form->select_company(GETPOST('socid','int'),'socid','s.fournisseur = 1',1);
     }
     print '</td></tr>';
 
@@ -1392,12 +1392,13 @@ if ($action == 'create')
 	print '</td></tr>';
 
 	// Project
-	if (! empty($conf->projet->enabled)) {
+	if (! empty($conf->projet->enabled))
+	{
 		$formproject = new FormProjets($db);
 
 		$langs->load('projects');
 		print '<tr><td>' . $langs->trans('Project') . '</td><td colspan="2">';
-		$formproject->select_projects($soc->id, $projectid, 'projectid');
+		$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$soc->id:-1), $projectid, 'projectid');
 		print '</td></tr>';
 	}
 
-- 
GitLab