28if (!defined(
'NOSESSION')) {
29 define(
'NOSESSION',
'1');
32$sapi_type = php_sapi_name();
33$script_file = basename(__FILE__);
37if (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";
42if (!isset($argv[1]) || !$argv[1]) {
43 print
"Usage: ".$script_file.
" now\n";
49require_once $path.
"../../htdocs/master.inc.php";
50require_once DOL_DOCUMENT_ROOT.
"/core/class/ldap.class.php";
51require_once DOL_DOCUMENT_ROOT.
"/adherents/class/adherent_type.class.php";
54$version = constant(
'DOL_VERSION');
57$hookmanager->initHooks(array(
'cli'));
65print
"***** ".$script_file.
" (".$version.
") pid=".
dol_getmypid().
" *****\n";
66dol_syslog($script_file.
" launched with arg ".join(
',', $argv));
75if (!empty($dolibarr_main_db_readonly)) {
76 print
"Error: instance in read-onyl mode\n";
82$sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent_type";
84$resql = $db->query($sql);
86 $num = $db->num_rows($resql);
90 $result = $ldap->connectBind();
96 $obj = $db->fetch_object($resql);
99 $membertype->id = $obj->rowid;
100 $membertype->fetch($membertype->id);
102 print $langs->trans(
"UpdateMemberType").
" rowid=".$membertype->id.
" ".$membertype->label;
104 $oldobject = $membertype;
106 $oldinfo = $membertype->_load_ldap_info();
107 $olddn = $membertype->_load_ldap_dn($oldinfo);
109 $info = $membertype->_load_ldap_info();
110 $dn = $membertype->_load_ldap_dn($info);
112 $result = $ldap->add($dn, $info, $user);
113 $result = $ldap->update($dn, $info, $user, $olddn);
115 print
" - ".$langs->trans(
"OK");
118 print
" - ".$langs->trans(
"KO").
' - '.$ldap->error;
Class to manage members type.
Class to manage LDAP features.
dol_getmypid()
Return getmypid() or random PID when function is disabled Some web hosts disable this php function fo...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.