Fixing style errors.

This commit is contained in:
stickler-ci 2021-03-05 10:24:28 +00:00
parent 396fb3fae3
commit 06cabb35ec
3 changed files with 57 additions and 57 deletions

View File

@ -58,7 +58,7 @@ if ($action == 'setvalue' && $user->admin) {
$error++; $error++;
} }
if (!dolibarr_set_const($db, 'LDAP_GROUP_FILTER', GETPOST("filter"), 'chaine', 0, '', $conf->entity)) { if (!dolibarr_set_const($db, 'LDAP_GROUP_FILTER', GETPOST("filter"), 'chaine', 0, '', $conf->entity)) {
$error++; $error++;
} }
if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_FULLNAME', GETPOST("fieldfullname", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) { if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_FULLNAME', GETPOST("fieldfullname", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) {
$error++; $error++;
@ -222,12 +222,12 @@ if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
} elseif ($conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') { } elseif ($conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') {
$butlabel = $langs->trans("LDAPTestSearch"); $butlabel = $langs->trans("LDAPTestSearch");
$testlabel = 'testsearchgroup'; $testlabel = 'testsearchgroup';
$key = $conf->global->LDAP_KEY_GROUPS; $key = $conf->global->LDAP_KEY_GROUPS;
$dn = $conf->global->LDAP_GROUP_DN; $dn = $conf->global->LDAP_GROUP_DN;
$objectclass = $conf->global->LDAP_GROUP_OBJECT_CLASS; $objectclass = $conf->global->LDAP_GROUP_OBJECT_CLASS;
show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
} }
if (function_exists("ldap_connect")) { if (function_exists("ldap_connect")) {
@ -278,59 +278,59 @@ if (function_exists("ldap_connect")) {
} }
if ($action == 'testsearchgroup') { if ($action == 'testsearchgroup') {
// TODO Mutualize code following with other ldap_xxxx.php pages // TODO Mutualize code following with other ldap_xxxx.php pages
// Test synchro // Test synchro
$ldap = new Ldap(); $ldap = new Ldap();
$result = $ldap->connect_bind(); $result = $ldap->connect_bind();
if ($result > 0) { if ($result > 0) {
$required_fields = array( $required_fields = array(
$conf->global->LDAP_KEY_GROUPS, $conf->global->LDAP_KEY_GROUPS,
// $conf->global->LDAP_GROUP_FIELD_NAME, // $conf->global->LDAP_GROUP_FIELD_NAME,
$conf->global->LDAP_GROUP_FIELD_DESCRIPTION, $conf->global->LDAP_GROUP_FIELD_DESCRIPTION,
$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS, $conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS,
$conf->global->LDAP_GROUP_FIELD_GROUPID $conf->global->LDAP_GROUP_FIELD_GROUPID
); );
// Remove from required_fields all entries not configured in LDAP (empty) and duplicated // Remove from required_fields all entries not configured in LDAP (empty) and duplicated
$required_fields = array_unique(array_values(array_filter($required_fields, "dol_validElement"))); $required_fields = array_unique(array_values(array_filter($required_fields, "dol_validElement")));
// Get from LDAP database an array of results // Get from LDAP database an array of results
$ldapgroups = $ldap->getRecords('*', $conf->global->LDAP_GROUP_DN, $conf->global->LDAP_KEY_GROUPS, $required_fields, 'group'); $ldapgroups = $ldap->getRecords('*', $conf->global->LDAP_GROUP_DN, $conf->global->LDAP_KEY_GROUPS, $required_fields, 'group');
//$ldapgroups = $ldap->getRecords('*', $conf->global->LDAP_GROUP_DN, $conf->global->LDAP_KEY_GROUPS, '', 'group'); //$ldapgroups = $ldap->getRecords('*', $conf->global->LDAP_GROUP_DN, $conf->global->LDAP_KEY_GROUPS, '', 'group');
if (is_array($ldapgroups)) { if (is_array($ldapgroups)) {
$liste = array(); $liste = array();
foreach ($ldapgroups as $key => $ldapgroup) { foreach ($ldapgroups as $key => $ldapgroup) {
// Define the label string for this group // Define the label string for this group
$label = ''; $label = '';
foreach ($required_fields as $value) { foreach ($required_fields as $value) {
if ($value) { if ($value) {
$label .= $value."=".$ldapgroup[$value]." "; $label .= $value."=".$ldapgroup[$value]." ";
} }
} }
$liste[$key] = $label; $liste[$key] = $label;
} }
} else { } else {
setEventMessages($ldap->error, $ldap->errors, 'errors'); setEventMessages($ldap->error, $ldap->errors, 'errors');
} }
print "<br>\n"; print "<br>\n";
print "LDAP search for group:<br>\n"; print "LDAP search for group:<br>\n";
print "search: *<br>\n"; print "search: *<br>\n";
print "userDN: ".$conf->global->LDAP_GROUP_DN."<br>\n"; print "userDN: ".$conf->global->LDAP_GROUP_DN."<br>\n";
print "useridentifier: ".$conf->global->LDAP_KEY_GROUPS."<br>\n"; print "useridentifier: ".$conf->global->LDAP_KEY_GROUPS."<br>\n";
print "required_fields: ".implode(',', $required_fields)."<br>\n"; print "required_fields: ".implode(',', $required_fields)."<br>\n";
print "=> ".count($liste)." records<br>\n"; print "=> ".count($liste)." records<br>\n";
print "\n<br>"; print "\n<br>";
} else { } else {
print img_picto('', 'error').' '; print img_picto('', 'error').' ';
print '<font class="error">'.$langs->trans("LDAPSynchroKO"); print '<font class="error">'.$langs->trans("LDAPSynchroKO");
print ': '.$ldap->error; print ': '.$ldap->error;
print '</font><br>'; print '</font><br>';
print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'<br>'; print $langs->trans("ErrorLDAPMakeManualTest", $conf->ldap->dir_temp).'<br>';
} }
} }
} }

View File

@ -957,7 +957,7 @@ class Ldap
if (((string) $activefilter == '1' || (string) $activefilter == 'user') && $this->filter) { if (((string) $activefilter == '1' || (string) $activefilter == 'user') && $this->filter) {
$filter = '('.$this->filter.')'; $filter = '('.$this->filter.')';
} elseif (((string) $activefilter == 'group') && $this->filtergroup ) { } elseif (((string) $activefilter == 'group') && $this->filtergroup ) {
$filter = '('.$this->filtergroup.')'; $filter = '('.$this->filtergroup.')';
} elseif (((string) $activefilter == 'member') && $this->filter) { } elseif (((string) $activefilter == 'member') && $this->filter) {
$filter = '('.$this->filtermember.')'; $filter = '('.$this->filtermember.')';
} else { } else {

View File

@ -98,9 +98,9 @@ print "login=".$conf->global->LDAP_ADMIN_DN."\n";
print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n"; print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n";
print "DN to extract=".$conf->global->LDAP_GROUP_DN."\n"; print "DN to extract=".$conf->global->LDAP_GROUP_DN."\n";
if (!empty($conf->global->LDAP_GROUP_FILTER)) { if (!empty($conf->global->LDAP_GROUP_FILTER)) {
print 'Filter=('.$conf->global->LDAP_GROUP_FILTER.')'."\n"; // Note: filter is defined into function getRecords print 'Filter=('.$conf->global->LDAP_GROUP_FILTER.')'."\n"; // Note: filter is defined into function getRecords
} else { } else {
print 'Filter=('.$conf->global->LDAP_KEY_GROUPS.'=*)'."\n"; print 'Filter=('.$conf->global->LDAP_KEY_GROUPS.'=*)'."\n";
} }
print "----- To Dolibarr database:\n"; print "----- To Dolibarr database:\n";
print "type=".$conf->db->type."\n"; print "type=".$conf->db->type."\n";