28 if (!defined(
'NOSESSION')) {
29 define(
'NOSESSION',
'1');
32 $sapi_type = php_sapi_name();
33 $script_file = basename(__FILE__);
37 if (substr($sapi_type, 0, 3) ==
'cgi') {
38 echo
"Error: You are using PHP for CGI. To execute ".$script_file.
" from command line, you must use PHP for CLI mode.\n";
42 if (!isset($argv[1]) || !$argv[1]) {
43 print
"Usage: ".$script_file.
" now\n";
49 require_once $path.
"../../htdocs/master.inc.php";
50 require_once DOL_DOCUMENT_ROOT.
"/core/class/ldap.class.php";
51 require_once DOL_DOCUMENT_ROOT.
"/adherents/class/adherent_type.class.php";
54 $version = constant(
'DOL_VERSION');
62 print
"***** ".$script_file.
" (".$version.
") pid=".
dol_getmypid().
" *****\n";
63 dol_syslog($script_file.
" launched with arg ".join(
',', $argv));
73 if (!empty($dolibarr_main_db_readonly)) {
74 print
"Error: instance in read-onyl mode\n";
79 $sql =
"SELECT rowid";
80 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type";
84 $num = $db->num_rows(
$resql);
88 $result = $ldap->connect_bind();
94 $obj = $db->fetch_object(
$resql);
97 $membertype->id = $obj->rowid;
98 $membertype->fetch($membertype->id);
100 print $langs->trans(
"UpdateMemberType").
" rowid=".$membertype->id.
" ".$membertype->label;
102 $oldobject = $membertype;
104 $oldinfo = $membertype->_load_ldap_info();
105 $olddn = $membertype->_load_ldap_dn($oldinfo);
107 $info = $membertype->_load_ldap_info();
108 $dn = $membertype->_load_ldap_dn($info);
110 $result = $ldap->add($dn, $info, $user);
111 $result = $ldap->update($dn, $info, $user, $olddn);
113 print
" - ".$langs->trans(
"OK");
116 print
" - ".$langs->trans(
"KO").
' - '.$ldap->error;