Skip to content
Snippets Groups Projects
Commit 823e976f authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Change the way parameters are provides to scripts

sync_xxx_ldap2dolibarr.php
parent e5d5a254
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,6 @@ For users:
- Fix: [ bug #1502 ] DON_CREATE trigger does not intercept trigger action
- Fix: [ bug #1505, #1504] Project trigger problem
For translators:
- Update language files.
......@@ -31,6 +30,11 @@ For developers:
- New: Add hook "searchAgendaFrom".
- New: Add trigger DON_UPDATE, DON_DELETE
WARNING: Following change may create regression for some external modules, but was necessary to make
Dolibarr better:
- Change the way parameters are provides to scripts sync_xxx_ldap2dolibarr.php
***** ChangeLog for 3.6 compared to 3.5.* *****
For users:
......
......@@ -93,14 +93,17 @@ $required_fields = array(
$required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement")));
if ($argv[3]) $conf->global->LDAP_SERVER_HOST=$argv[2];
if (! isset($argv[2]) || ! is_numeric($argv[2])) {
print "Usage: $script_file (nocommitiferror|commitiferror) id_member_type [ldapserverhost]\n";
print "Usage: $script_file (nocommitiferror|commitiferror) id_member_type [--server=ldapserverhost]\n";
exit(-1);
}
$typeid=$argv[2];
if ($argv[1] == 'commitiferror') $forcecommit=1;
foreach($argv as $key => $val)
{
if ($val == 'commitiferror') $forcecommit=1;
if (preg_match('/--server=([^\s]+)$/',$val,$reg)) $conf->global->LDAP_SERVER_HOST=$reg[1];
}
print "Mails sending disabled (useless in batch mode)\n";
$conf->global->MAIN_DISABLE_ALL_MAILS=1; // On bloque les mails
......
......@@ -70,16 +70,19 @@ $required_fields = array(
// Remove from required_fields all entries not configured in LDAP (empty) and duplicated
$required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement")));
if ($argv[2]) $conf->global->LDAP_SERVER_HOST=$argv[2];
if (! isset($argv[1])) {
//print "Usage: $script_file (nocommitiferror|commitiferror) [id_group]\n";
print "Usage: $script_file (nocommitiferror|commitiferror) [ldapserverhost]\n";
print "Usage: $script_file (nocommitiferror|commitiferror) [--server=ldapserverhost] [--excludeuser=user1,user2...]\n";
exit(-1);
}
$groupid=$argv[3];
if ($argv[1] == 'commitiferror') $forcecommit=1;
foreach($argv as $key => $val)
{
if ($val == 'commitiferror') $forcecommit=1;
if (preg_match('/--server=([^\s]+)$/',$val,$reg)) $conf->global->LDAP_SERVER_HOST=$reg[1];
if (preg_match('/--excludeuser=([^\s]+)$/',$val,$reg)) $excludeuser=explode(',',$reg[1]);
}
print "Mails sending disabled (useless in batch mode)\n";
$conf->global->MAIN_DISABLE_ALL_MAILS=1; // On bloque les mails
......
......@@ -47,6 +47,7 @@ $langs->load("errors");
$version=DOL_VERSION;
$error=0;
$forcecommit=0;
$excludeuser=array();
/*
......@@ -83,16 +84,17 @@ $required_fields = array(
// Remove from required_fields all entries not configured in LDAP (empty) and duplicated
$required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement")));
if ($argv[2]) $conf->global->LDAP_SERVER_HOST=$argv[2];
if (! isset($argv[1])) {
//print "Usage: $script_file (nocommitiferror|commitiferror) [id_group]\n";
print "Usage: $script_file (nocommitiferror|commitiferror) [ldapserverhost]\n";
print "Usage: $script_file (nocommitiferror|commitiferror) [--server=ldapserverhost] [--excludeuser=user1,user2...]\n";
exit(-1);
}
if ($argv[1] == 'commitiferror') $forcecommit=1;
foreach($argv as $key => $val)
{
if ($val == 'commitiferror') $forcecommit=1;
if (preg_match('/--server=([^\s]+)$/',$val,$reg)) $conf->global->LDAP_SERVER_HOST=$reg[1];
if (preg_match('/--excludeuser=([^\s]+)$/',$val,$reg)) $excludeuser=explode(',',$reg[1]);
}
print "Mails sending disabled (useless in batch mode)\n";
$conf->global->MAIN_DISABLE_ALL_MAILS=1; // On bloque les mails
......@@ -112,6 +114,7 @@ print "login=".$conf->db->user."\n";
print "database=".$conf->db->name."\n";
print "----- Options:\n";
print "commitiferror=".$forcecommit."\n";
print "excludeuser=".join(',',$excludeuser)."\n";
print "Mapped LDAP fields=".join(',',$required_fields)."\n";
print "\n";
......@@ -179,6 +182,13 @@ if ($result >= 0)
// Warning $ldapuser has a key in lowercase
foreach ($ldaprecords as $key => $ldapuser)
{
// If login into exclude list, we discard record
if (in_array($ldapuser[$conf->global->LDAP_FIELD_LOGIN],$excludeuser))
{
print $langs->transnoentities("UserDiscarded").' # '.$key.': login='.$ldapuser[$conf->global->LDAP_FIELD_LOGIN].' --> Discarded'."\n";
continue;
}
$fuser = new User($db);
if($conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_SID) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment