diff --git a/ChangeLog b/ChangeLog index 139069474c9e2182a2fed4a4eab3f4b170c087b9..30b640ac1307b4c24e53c65808565f693f7336b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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: diff --git a/scripts/members/sync_members_ldap2dolibarr.php b/scripts/members/sync_members_ldap2dolibarr.php index 07cf3f45ac39db21ed08186d6534c053f7f6dcb2..d081065a3faab058eb3d309bd4cf433788874879 100755 --- a/scripts/members/sync_members_ldap2dolibarr.php +++ b/scripts/members/sync_members_ldap2dolibarr.php @@ -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 diff --git a/scripts/user/sync_groups_ldap2dolibarr.php b/scripts/user/sync_groups_ldap2dolibarr.php index 1da80e57d4e666f1e724fa7a19ad052abc3d5902..3170714124b5693699ffca688c42b9b650e8d41e 100755 --- a/scripts/user/sync_groups_ldap2dolibarr.php +++ b/scripts/user/sync_groups_ldap2dolibarr.php @@ -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 diff --git a/scripts/user/sync_users_ldap2dolibarr.php b/scripts/user/sync_users_ldap2dolibarr.php index b7d041f64f9e12923afcbaabfd842df69c859deb..774a56c45e570ded3dd3d15704e23e912b8b76ec 100755 --- a/scripts/user/sync_users_ldap2dolibarr.php +++ b/scripts/user/sync_users_ldap2dolibarr.php @@ -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) {