From ac7d0b5eb623c211871dbe14fc02717d69886f8e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Sep 2019 04:12:48 +0200 Subject: [PATCH] Fix scrutinizer --- htdocs/adherents/ldap.php | 10 +++++----- htdocs/adherents/type_ldap.php | 9 +++++---- htdocs/contact/ldap.php | 9 +++++---- htdocs/core/class/ldap.class.php | 4 ++-- htdocs/user/group/ldap.php | 9 +++++---- htdocs/user/ldap.php | 7 ++++--- 6 files changed, 26 insertions(+), 22 deletions(-) diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index 1d890ab580f..84bedb9adf0 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -182,7 +182,7 @@ if ($result > 0) if (empty($dn)) { $langs->load("errors"); - print ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).''; + print ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).''; } else { @@ -190,12 +190,12 @@ if ($result > 0) //print_r($records); - // Affichage arbre - if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) + // Show tree + if (((! is_numeric($records)) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) { if (! is_array($records)) { - print ''.$langs->trans("ErrorFailedToReadLDAP").''; + print ''.$langs->trans("ErrorFailedToReadLDAP").''; } else { @@ -204,7 +204,7 @@ if ($result > 0) } else { - print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; + print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; } } diff --git a/htdocs/adherents/type_ldap.php b/htdocs/adherents/type_ldap.php index 6fe29379b58..86672386502 100644 --- a/htdocs/adherents/type_ldap.php +++ b/htdocs/adherents/type_ldap.php @@ -155,16 +155,17 @@ if ($result > 0) $info=$object->_load_ldap_info(); $dn=$object->_load_ldap_dn($info, 1); $search = "(".$object->_load_ldap_dn($info, 2).")"; + $records = $ldap->getAttribute($dn, $search); //print_r($records); - // Affichage arbre - if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) + // Show tree + if (((! is_numeric($records)) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) { if (! is_array($records)) { - print ''.$langs->trans("ErrorFailedToReadLDAP").''; + print ''.$langs->trans("ErrorFailedToReadLDAP").''; } else { @@ -173,7 +174,7 @@ if ($result > 0) } else { - print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; + print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; } $ldap->unbind(); diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php index 1514a2188ff..bc33a93adac 100644 --- a/htdocs/contact/ldap.php +++ b/htdocs/contact/ldap.php @@ -172,16 +172,17 @@ if ($result > 0) $info=$object->_load_ldap_info(); $dn=$object->_load_ldap_dn($info, 1); $search = "(".$object->_load_ldap_dn($info, 2).")"; + $records = $ldap->getAttribute($dn, $search); //var_dump($records); - // Affichage arbre - if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) + // Show tree + if (((! is_numeric($records)) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) { if (! is_array($records)) { - print ''.$langs->trans("ErrorFailedToReadLDAP").''; + print ''.$langs->trans("ErrorFailedToReadLDAP").''; } else { @@ -190,7 +191,7 @@ if ($result > 0) } else { - print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; + print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; } $ldap->unbind(); diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index c00f4003d5d..1d1a6122288 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -944,7 +944,7 @@ class Ldap // Only one entry should ever be returned $entry = ldap_first_entry($this->connection, $search); - if (!$entry) + if (! $entry) { $this->ldapErrorCode = -1; $this->ldapErrorText = "Couldn't find entry"; @@ -952,7 +952,7 @@ class Ldap } // Get values - if (! $values = ldap_get_attributes($this->connection, $entry)) + if (! ($values = ldap_get_attributes($this->connection, $entry))) { $this->ldapErrorCode = ldap_errno($this->connection); $this->ldapErrorText = ldap_error($this->connection); diff --git a/htdocs/user/group/ldap.php b/htdocs/user/group/ldap.php index c5110c052ef..5850f69890b 100644 --- a/htdocs/user/group/ldap.php +++ b/htdocs/user/group/ldap.php @@ -183,16 +183,17 @@ if ($result > 0) $info=$object->_load_ldap_info(); $dn=$object->_load_ldap_dn($info, 1); $search = "(".$object->_load_ldap_dn($info, 2).")"; + $records = $ldap->getAttribute($dn, $search); //var_dump($records); - // Affichage arbre - if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) + // Show tree + if (((! is_numeric($records)) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) { if (! is_array($records)) { - print ''.$langs->trans("ErrorFailedToReadLDAP").''; + print ''.$langs->trans("ErrorFailedToReadLDAP").''; } else { @@ -201,7 +202,7 @@ if ($result > 0) } else { - print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; + print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; } $ldap->unbind(); $ldap->close(); diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index decfbc1e0f7..c132bedf988 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -187,16 +187,17 @@ if ($result > 0) $info=$object->_load_ldap_info(); $dn=$object->_load_ldap_dn($info, 1); $search = "(".$object->_load_ldap_dn($info, 2).")"; + $records = $ldap->getAttribute($dn, $search); //print_r($records); // Affichage arbre - if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) + if (((! is_numeric($records)) || $records != 0) && (! isset($records['count']) || $records['count'] > 0)) { if (! is_array($records)) { - print ''.$langs->trans("ErrorFailedToReadLDAP").''; + print ''.$langs->trans("ErrorFailedToReadLDAP").''; } else { @@ -205,7 +206,7 @@ if ($result > 0) } else { - print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; + print ''.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')'; } $ldap->unbind();