societe_id to socid
This commit is contained in:
parent
42ca3bcdc7
commit
1620ab3118
@ -19,12 +19,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file scripts/product/migrate_picture_path.php
|
* \file scripts/user/migrate_picture_path.php
|
||||||
* \ingroup scripts
|
* \ingroup scripts
|
||||||
* \brief Migrate pictures from old system prior to 3.7 to new path for 3.7+
|
* \brief Migrate pictures from old system prior to 3.7 to new path for 3.7+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('NOSESSION')) define('NOSESSION', '1');
|
if (!defined('NOSESSION')) {
|
||||||
|
define('NOSESSION', '1');
|
||||||
|
}
|
||||||
|
|
||||||
$sapi_type = php_sapi_name();
|
$sapi_type = php_sapi_name();
|
||||||
$script_file = basename(__FILE__);
|
$script_file = basename(__FILE__);
|
||||||
|
|||||||
@ -24,7 +24,9 @@
|
|||||||
* \brief Script to update users into Dolibarr from LDAP
|
* \brief Script to update users into Dolibarr from LDAP
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('NOSESSION')) define('NOSESSION', '1');
|
if (!defined('NOSESSION')) {
|
||||||
|
define('NOSESSION', '1');
|
||||||
|
}
|
||||||
|
|
||||||
$sapi_type = php_sapi_name();
|
$sapi_type = php_sapi_name();
|
||||||
$script_file = basename(__FILE__);
|
$script_file = basename(__FILE__);
|
||||||
@ -59,12 +61,27 @@ print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
|
|||||||
dol_syslog($script_file." launched with arg ".join(',', $argv));
|
dol_syslog($script_file." launched with arg ".join(',', $argv));
|
||||||
|
|
||||||
// List of fields to get from LDAP
|
// List of fields to get from LDAP
|
||||||
$required_fields = array($conf->global->LDAP_KEY_USERS, $conf->global->LDAP_FIELD_FULLNAME, $conf->global->LDAP_FIELD_NAME, $conf->global->LDAP_FIELD_FIRSTNAME, $conf->global->LDAP_FIELD_LOGIN, $conf->global->LDAP_FIELD_LOGIN_SAMBA, $conf->global->LDAP_FIELD_PASSWORD, $conf->global->LDAP_FIELD_PASSWORD_CRYPTED, $conf->global->LDAP_FIELD_PHONE, $conf->global->LDAP_FIELD_FAX, $conf->global->LDAP_FIELD_MOBILE,
|
$required_fields = array(
|
||||||
|
$conf->global->LDAP_KEY_USERS,
|
||||||
|
$conf->global->LDAP_FIELD_FULLNAME,
|
||||||
|
$conf->global->LDAP_FIELD_NAME,
|
||||||
|
$conf->global->LDAP_FIELD_FIRSTNAME,
|
||||||
|
$conf->global->LDAP_FIELD_LOGIN,
|
||||||
|
$conf->global->LDAP_FIELD_LOGIN_SAMBA,
|
||||||
|
$conf->global->LDAP_FIELD_PASSWORD,
|
||||||
|
$conf->global->LDAP_FIELD_PASSWORD_CRYPTED,
|
||||||
|
$conf->global->LDAP_FIELD_PHONE,
|
||||||
|
$conf->global->LDAP_FIELD_FAX,
|
||||||
|
$conf->global->LDAP_FIELD_MOBILE,
|
||||||
// $conf->global->LDAP_FIELD_ADDRESS,
|
// $conf->global->LDAP_FIELD_ADDRESS,
|
||||||
// $conf->global->LDAP_FIELD_ZIP,
|
// $conf->global->LDAP_FIELD_ZIP,
|
||||||
// $conf->global->LDAP_FIELD_TOWN,
|
// $conf->global->LDAP_FIELD_TOWN,
|
||||||
// $conf->global->LDAP_FIELD_COUNTRY,
|
// $conf->global->LDAP_FIELD_COUNTRY,
|
||||||
$conf->global->LDAP_FIELD_MAIL, $conf->global->LDAP_FIELD_TITLE, $conf->global->LDAP_FIELD_DESCRIPTION, $conf->global->LDAP_FIELD_SID);
|
$conf->global->LDAP_FIELD_MAIL,
|
||||||
|
$conf->global->LDAP_FIELD_TITLE,
|
||||||
|
$conf->global->LDAP_FIELD_DESCRIPTION,
|
||||||
|
$conf->global->LDAP_FIELD_SID
|
||||||
|
);
|
||||||
|
|
||||||
// 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, "dolValidElement")));
|
$required_fields = array_unique(array_values(array_filter($required_fields, "dolValidElement")));
|
||||||
@ -75,15 +92,19 @@ if (!isset($argv[1])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($argv as $key => $val) {
|
foreach ($argv as $key => $val) {
|
||||||
if ($val == 'commitiferror')
|
if ($val == 'commitiferror') {
|
||||||
$forcecommit = 1;
|
$forcecommit = 1;
|
||||||
if (preg_match('/--server=([^\s]+)$/', $val, $reg))
|
}
|
||||||
|
if (preg_match('/--server=([^\s]+)$/', $val, $reg)) {
|
||||||
$conf->global->LDAP_SERVER_HOST = $reg[1];
|
$conf->global->LDAP_SERVER_HOST = $reg[1];
|
||||||
if (preg_match('/--excludeuser=([^\s]+)$/', $val, $reg))
|
}
|
||||||
|
if (preg_match('/--excludeuser=([^\s]+)$/', $val, $reg)) {
|
||||||
$excludeuser = explode(',', $reg[1]);
|
$excludeuser = explode(',', $reg[1]);
|
||||||
if (preg_match('/-y$/', $val, $reg))
|
}
|
||||||
|
if (preg_match('/-y$/', $val, $reg)) {
|
||||||
$confirmed = 1;
|
$confirmed = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
print "Mails sending disabled (useless in batch mode)\n";
|
print "Mails sending disabled (useless in batch mode)\n";
|
||||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails
|
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails
|
||||||
@ -94,9 +115,11 @@ print "port=".$conf->global->LDAP_SERVER_PORT."\n";
|
|||||||
print "login=".$conf->global->LDAP_ADMIN_DN."\n";
|
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_USER_DN."\n";
|
print "DN to extract=".$conf->global->LDAP_USER_DN."\n";
|
||||||
if (!empty($conf->global->LDAP_FILTER_CONNECTION))
|
if (!empty($conf->global->LDAP_FILTER_CONNECTION)) {
|
||||||
print 'Filter=('.$conf->global->LDAP_FILTER_CONNECTION.')'."\n"; // Note: filter is defined into function getRecords
|
print 'Filter=('.$conf->global->LDAP_FILTER_CONNECTION.')'."\n"; // Note: filter is defined into function getRecords
|
||||||
else print 'Filter=('.$conf->global->LDAP_KEY_USERS.'=*)'."\n";
|
} else {
|
||||||
|
print 'Filter=('.$conf->global->LDAP_KEY_USERS.'=*)'."\n";
|
||||||
|
}
|
||||||
print "----- To Dolibarr database:\n";
|
print "----- To Dolibarr database:\n";
|
||||||
print "type=".$conf->db->type."\n";
|
print "type=".$conf->db->type."\n";
|
||||||
print "host=".$conf->db->host."\n";
|
print "host=".$conf->db->host."\n";
|
||||||
@ -200,7 +223,7 @@ if ($result >= 0) {
|
|||||||
$fuser->job = $ldapuser[$conf->global->LDAP_FIELD_TITLE];
|
$fuser->job = $ldapuser[$conf->global->LDAP_FIELD_TITLE];
|
||||||
$fuser->note = $ldapuser[$conf->global->LDAP_FIELD_DESCRIPTION];
|
$fuser->note = $ldapuser[$conf->global->LDAP_FIELD_DESCRIPTION];
|
||||||
$fuser->admin = 0;
|
$fuser->admin = 0;
|
||||||
$fuser->societe_id = 0;
|
$fuser->socid = 0;
|
||||||
$fuser->contact_id = 0;
|
$fuser->contact_id = 0;
|
||||||
$fuser->fk_member = 0;
|
$fuser->fk_member = 0;
|
||||||
|
|
||||||
@ -254,9 +277,11 @@ if ($result >= 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$error || $forcecommit) {
|
if (!$error || $forcecommit) {
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
print $langs->transnoentities("NoErrorCommitIsDone")."\n";
|
print $langs->transnoentities("NoErrorCommitIsDone")."\n";
|
||||||
else print $langs->transnoentities("ErrorButCommitIsDone")."\n";
|
} else {
|
||||||
|
print $langs->transnoentities("ErrorButCommitIsDone")."\n";
|
||||||
|
}
|
||||||
$db->commit();
|
$db->commit();
|
||||||
} else {
|
} else {
|
||||||
print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", $error)."\n";
|
print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", $error)."\n";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user