30require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
42 if (isset($versionarray[0])) {
43 $string = $versionarray[0];
45 if (isset($versionarray[1])) {
46 $string .=
'.'.$versionarray[1];
48 if (isset($versionarray[2])) {
49 $string .=
'.'.$versionarray[2];
75 $count1 = count($versionarray1);
76 $count2 = count($versionarray2);
77 $maxcount = max($count1, $count2);
78 while ($level < $maxcount) {
79 $operande1 = isset($versionarray1[$level]) ? $versionarray1[$level] : 0;
80 $operande2 = isset($versionarray2[$level]) ? $versionarray2[$level] : 0;
81 if (preg_match(
'/alpha|dev/i', $operande1)) {
84 if (preg_match(
'/alpha|dev/i', $operande2)) {
87 if (preg_match(
'/beta$/i', $operande1)) {
90 if (preg_match(
'/beta$/i', $operande2)) {
93 if (preg_match(
'/beta([0-9])+/i', $operande1)) {
96 if (preg_match(
'/beta([0-9])+/i', $operande2)) {
99 if (preg_match(
'/rc$/i', $operande1)) {
102 if (preg_match(
'/rc$/i', $operande2)) {
105 if (preg_match(
'/rc([0-9])+/i', $operande1)) {
108 if (preg_match(
'/rc([0-9])+/i', $operande2)) {
113 if ($operande1 < $operande2) {
117 if ($operande1 > $operande2) {
135 return explode(
'.', PHP_VERSION);
146 return preg_split(
'/[\-\.]/', DOL_VERSION);
173function run_sql($sqlfile, $silent = 1, $entity = 0, $usesavepoint = 1, $handler =
'', $okerror =
'default', $linelengthlimit = 32768, $nocommentremoval = 0, $offsetforchartofaccount = 0, $colspan = 0, $onlysqltoimportwebsite = 0, $database =
'')
175 global $db,
$conf, $langs;
177 dol_syslog(
"Admin.lib::run_sql run sql file ".$sqlfile.
" silent=".$silent.
" entity=".$entity.
" usesavepoint=".$usesavepoint.
" handler=".$handler.
" okerror=".$okerror, LOG_DEBUG);
179 if (!is_numeric($linelengthlimit)) {
180 dol_syslog(
"Admin.lib::run_sql param linelengthlimit is not a numeric", LOG_ERR);
191 $versionarray = $db->getVersionArray();
195 $fp = fopen($sqlfile,
"r");
199 if ($linelengthlimit > 0) {
200 $buf = fgets($fp, $linelengthlimit);
207 if (preg_match(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i', $buf, $reg)) {
211 if (!empty($reg[1])) {
212 if (!preg_match(
'/'.preg_quote($reg[1]).
'/i', $db->type)) {
219 if (!empty($reg[2])) {
220 if (is_numeric($reg[2])) {
221 $versionrequest = explode(
'.', $reg[2]);
224 if (!count($versionrequest) || !count($versionarray) ||
versioncompare($versionrequest, $versionarray) > 0) {
228 $dbcollation = strtoupper(preg_replace(
'/_/',
'',
$conf->db->dolibarr_main_db_collation));
231 if (empty(
$conf->db->dolibarr_main_db_collation) || ($reg[2] != $dbcollation)) {
241 $buf = preg_replace(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i',
'', $buf);
247 if ($nocommentremoval || !preg_match(
'/^\s*--/', $buf)) {
248 if (empty($nocommentremoval)) {
249 $buf = preg_replace(
'/([,;ERLT0\)])\s+--.*$/i',
'\1', $buf);
254 $buffer .= trim($buf);
259 if (preg_match(
'/;\s*$/', $buffer)) {
263 $arraysql[$i] = $buffer;
271 $arraysql[$i] = $buffer;
275 dol_syslog(
"Admin.lib::run_sql failed to open file ".$sqlfile, LOG_ERR);
279 $listofmaxrowid = array();
280 foreach ($arraysql as $i => $sql) {
284 while (preg_match(
'/__\+MAX_([A-Za-z0-9_]+)__/i', $newsql, $reg)) {
286 if (!isset($listofmaxrowid[$table])) {
288 $sqlgetrowid =
'SELECT MAX(rowid) as max from '.preg_replace(
'/^llx_/', MAIN_DB_PREFIX, $table);
289 $resql = $db->query($sqlgetrowid);
291 $obj = $db->fetch_object($resql);
292 $listofmaxrowid[$table] = $obj->max;
293 if (empty($listofmaxrowid[$table])) {
294 $listofmaxrowid[$table] = 0;
298 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
299 print
'<div class="error">'.$langs->trans(
"Failed to get max rowid for ".$table).
"</div>";
307 $from =
'__+MAX_'.$table.
'__';
308 $to =
'+'.$listofmaxrowid[$table];
309 $newsql = str_replace($from, $to, $newsql);
310 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1).
' (replacing '.$from.
' to '.$to.
')', LOG_DEBUG);
312 $arraysql[$i] = $newsql;
315 if ($offsetforchartofaccount > 0) {
321 $newsql = preg_replace(
'/VALUES\s*\(__ENTITY__, \s*(\d+)\s*,(\s*\'[^\',]*\'\s*,\s*\'[^\',]*\'\s*,\s*\'?[^\',]*\'?\s*),\s*\'?([^\',]*)\'?/ims',
'VALUES (__ENTITY__, \1 + '.((
int) $offsetforchartofaccount).
', \2, \3 + '.((
int) $offsetforchartofaccount), $newsql);
322 $newsql = preg_replace(
'/([,\s])0 \+ '.((
int) $offsetforchartofaccount).
'/ims',
'\1 0', $newsql);
324 $arraysql[$i] = $newsql;
333 $listofinsertedrowid = array();
334 $keyforsql = md5($sqlfile);
335 foreach ($arraysql as $i => $sql) {
338 if ($onlysqltoimportwebsite) {
339 $newsql = str_replace(array(
"\'"),
'__BACKSLASHQUOTE__', $sql);
342 $l = strlen($newsql);
347 $char = $newsql[$is];
354 } elseif (empty($quoteopen)) {
355 $newsqlclean .= $char;
359 $newsqlclean = str_replace(array(
"null"),
'__000__', $newsqlclean);
365 if (preg_match(
'/^--/', $newsqlclean)) {
367 } elseif (preg_match(
'/^UPDATE llx_website SET \w+ = \d+\+\d+ WHERE rowid = \d+;$/', $newsqlclean)) {
369 } elseif (preg_match(
'/^INSERT INTO llx_website_page\([a-z0-9_\s,]+\) VALUES\([0-9_\s,\+]+\);$/', $newsqlclean)) {
377 if (preg_match(
'/^UPDATE llx_website SET \w+ = \'[a-zA-Z,\s]*\' WHERE rowid = \d+;$/', $sql)) {
387 $errorphpcheck =
checkPHPCode($extractphpold, $extractphp);
388 if ($errorphpcheck) {
392 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains PHP code and checking this code returns errorphpcheck='.$errorphpcheck.'", LOG_WARNING);
402 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains non allowed instructions.", LOG_WARNING);
403 dol_syslog(
'$newsqlclean='.$newsqlclean, LOG_DEBUG);
409 if (MAIN_DB_PREFIX !=
'llx_') {
410 $sql = preg_replace(
'/llx_/i', MAIN_DB_PREFIX, $sql);
413 if (!empty($handler)) {
414 $sql = preg_replace(
'/__HANDLER__/i',
"'".$db->escape($handler).
"'", $sql);
417 if (!empty($database)) {
418 $sql = preg_replace(
'/__DATABASE__/i', $db->escape($database), $sql);
421 $newsql = preg_replace(
'/__ENTITY__/i', (!empty($entity) ? $entity : (string)
$conf->entity), $sql);
425 print
'<tr class="trforrunsql'.$keyforsql.
'"><td class="tdtop opacitymedium"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>'.$langs->trans(
"Request").
' '.($i + 1).
" sql='".
dol_htmlentities($newsql, ENT_NOQUOTES).
"'</td></tr>\n";
427 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1), LOG_DEBUG);
431 if (preg_match_all(
'/__ENCRYPT\(\'([^\']+)\'\)__/i', $newsql, $reg)) {
432 $num = count($reg[0]);
434 for ($j = 0; $j < $num; $j++) {
436 $to = $db->encrypt($reg[1][$j]);
437 $newsql = str_replace($from, $to, $newsql);
443 if (preg_match_all(
'/__DECRYPT\(\'([A-Za-z0-9_]+)\'\)__/i', $newsql, $reg)) {
444 $num = count($reg[0]);
446 for ($j = 0; $j < $num; $j++) {
448 $to = $db->decrypt($reg[1][$j]);
449 $newsql = str_replace($from, $to, $newsql);
455 while (preg_match(
'/__([0-9]+)__/', $newsql, $reg)) {
457 if (empty($listofinsertedrowid[$cursor])) {
459 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
460 print
'<div class="error">'.$langs->trans(
"FileIsNotCorrect").
"</div>";
467 $from =
'__'.$cursor.
'__';
468 $to = $listofinsertedrowid[$cursor];
469 $newsql = str_replace($from, $to, $newsql);
474 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1), LOG_DEBUG);
477 $result = $db->query($newsql, $usesavepoint);
480 print
'<!-- Result = OK -->'.
"\n";
483 if (preg_replace(
'/insert into ([^\s]+)/i', $newsql, $reg)) {
487 $table = preg_replace(
'/([^a-zA-Z_]+)/i',
'', $reg[1]);
488 $insertedrowid = $db->last_insert_id($table);
489 $listofinsertedrowid[$cursorinsert] = $insertedrowid;
490 dol_syslog(
'Admin.lib::run_sql Insert nb '.$cursorinsert.
', done in table '.$table.
', rowid is '.$listofinsertedrowid[$cursorinsert], LOG_DEBUG);
494 $errno = $db->errno();
496 print
'<!-- Result = '.$errno.
' -->'.
"\n";
501 'DB_ERROR_TABLE_ALREADY_EXISTS',
502 'DB_ERROR_COLUMN_ALREADY_EXISTS',
503 'DB_ERROR_KEY_NAME_ALREADY_EXISTS',
504 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS',
505 'DB_ERROR_RECORD_ALREADY_EXISTS',
506 'DB_ERROR_NOSUCHTABLE',
507 'DB_ERROR_NOSUCHFIELD',
508 'DB_ERROR_NO_FOREIGN_KEY_TO_DROP',
509 'DB_ERROR_NO_INDEX_TO_DROP',
510 'DB_ERROR_CANNOT_CREATE',
511 'DB_ERROR_CANT_DROP_PRIMARY_KEY',
512 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS',
515 if ($okerror ==
'none') {
520 if (!in_array($errno, $okerrors)) {
522 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
523 print
'<div class="error">'.$langs->trans(
"Error").
" ".$db->errno().
" (Req ".($i + 1).
"): ".$newsql.
"<br>".$db->error().
"</div>";
524 print
'</td></tr>'.
"\n";
526 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" Error ".$db->errno().
" ".$newsql.
"<br>".$db->error(), LOG_ERR);
534 print
'<tr><td>'.$langs->trans(
"ProcessMigrateScript").
'</td>';
535 print
'<td class="right">';
537 print
'<span class="ok">'.$langs->trans(
"OK").
'</span>';
539 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
543 print
'<script type="text/javascript">
544 jQuery(document).ready(function() {
545 function init_trrunsql'.$keyforsql.
'()
547 console.log("toggle .trforrunsql'.$keyforsql.
'");
548 jQuery(".trforrunsql'.$keyforsql.
'").toggle();
550 init_trrunsql'.$keyforsql.
'();
551 jQuery(".trforrunsqlshowhide'.$keyforsql.
'").click(function() {
552 init_trrunsql'.$keyforsql.
'();
556 if (count($arraysql)) {
557 print
' - <a class="trforrunsqlshowhide'.$keyforsql.
'" href="#" title="'.($langs->trans(
"ShowHideTheNRequests", count($arraysql))).
'">'.$langs->trans(
"ShowHideDetails").
'</a>';
559 print
' - <span class="opacitymedium">'.$langs->trans(
"ScriptIsEmpty").
'</span>';
563 print
'</td></tr>'.
"\n";
588 global
$conf, $hookmanager;
591 dol_print_error(
null,
'Error call dolibar_del_const with parameter name empty');
594 if (! is_object($hookmanager)) {
595 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
604 $reshook = $hookmanager->executeHooks(
'dolibarrDelConst', $parameters);
609 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
610 $sql .=
" WHERE (".$db->decrypt(
'name').
" = '".$db->escape((
string) $name).
"'";
611 if (is_numeric($name)) {
612 $sql .=
" OR rowid = ".((int) $name);
616 $sql .=
" AND entity = ".((int) $entity);
619 dol_syslog(
"admin.lib::dolibarr_del_const", LOG_DEBUG);
620 $resql = $db->query($sql);
622 $conf->global->$name =
'';
644 $sql =
"SELECT ".$db->decrypt(
'value').
" as value";
645 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
646 $sql .=
" WHERE name = ".$db->encrypt($name);
647 $sql .=
" AND entity = ".((int) $entity);
649 dol_syslog(
"admin.lib::dolibarr_get_const", LOG_DEBUG);
650 $resql = $db->query($sql);
652 $obj = $db->fetch_object($resql);
654 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
676function dolibarr_set_const($db, $name, $value, $type =
'chaine', $visible = 0, $note =
'', $entity = 1)
678 global
$conf, $hookmanager;
682 $value = (string) $value;
686 dol_print_error($db,
"Error: Call to function dolibarr_set_const with wrong parameters");
689 if (! is_object($hookmanager)) {
690 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
694 $value = (string) $value;
700 'visible' => $visible,
705 $reshook = $hookmanager->executeHooks(
'dolibarrSetConst', $parameters);
714 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
715 $sql .=
" WHERE name = ".$db->encrypt($name);
717 $sql .=
" AND entity = ".((int) $entity);
720 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
721 $resql = $db->query($sql);
723 if (strcmp($value,
'')) {
724 if (!preg_match(
'/^(MAIN_LOGEVENTS|MAIN_AGENDA_ACTIONAUTO)/', $name) && (preg_match(
'/(_KEY|_EXPORTKEY|_SECUREKEY|_SERVERKEY|_PASS|_PASSWORD|_PW|_PW_TICKET|_PW_EMAILING|_SECRET|_SECURITY_TOKEN|_WEB_TOKEN)$/', $name))) {
729 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
735 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name, value, type, visible, note, entity)";
737 $sql .= $db->encrypt($name);
738 $sql .=
", ".$db->encrypt($newvalue);
739 $sql .=
", '".$db->escape($type).
"', ".((int) $visible).
", '".$db->escape($note).
"', ".((int) $entity).
")";
743 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
744 $resql = $db->query($sql);
749 $conf->global->$name = $value;
770 global $langs, $form;
772 $desc = $langs->trans(
"ModulesDesc",
'{picto}');
773 $desc = str_replace(
'{picto}',
img_picto(
'',
'switch_off'), $desc);
778 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=".$mode;
779 if ($nbmodulesnotautoenabled <
getDolGlobalInt(
'MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) {
781 $head[$h][1] = $langs->trans(
"AvailableModules");
782 $head[$h][1] .= $form->textwithpicto(
'', $langs->trans(
"YouMustEnableOneModule").
'.<br><br><span class="opacitymedium">'.$desc.
'</span>', 1,
'warning');
785 $head[$h][1] = $langs->trans(
"AvailableModules").
'<span class="badge marginleftonly">'.$nbofactivatedmodules.
' / '.$nboftotalmodules.
'</span>';
787 $head[$h][2] =
'modules';
790 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=marketplace";
791 $head[$h][1] = $langs->trans(
"ModulesMarketPlaces");
792 $head[$h][2] =
'marketplace';
795 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=deploy";
796 $head[$h][1] = $langs->trans(
"AddExtensionThemeModuleOrOther");
797 $head[$h][2] =
'deploy';
800 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=develop";
801 $head[$h][1] = $langs->trans(
"ModulesDevelopYourModule");
802 $head[$h][2] =
'develop';
815 global $langs,
$conf;
819 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=other";
820 $head[$h][1] = $langs->trans(
"LanguageAndPresentation");
821 $head[$h][2] =
'other';
824 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=template";
825 $head[$h][1] = $langs->trans(
"SkinAndColors");
826 $head[$h][2] =
'template';
829 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=dashboard";
830 $head[$h][1] = $langs->trans(
"Dashboard");
831 $head[$h][2] =
'dashboard';
834 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=login";
835 $head[$h][1] = $langs->trans(
"LoginPage");
836 $head[$h][2] =
'login';
839 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=css";
840 $head[$h][1] = $langs->trans(
"CSSPage");
841 $head[$h][2] =
'css';
844 $head[$h][0] = DOL_URL_ROOT.
"/admin/tools/ui/index.php";
845 $head[$h][1] = $langs->trans(
"UxComponentsDoc").
' '.
img_picto(
'',
'external-link-square-alt');
865 global $db, $langs,
$conf;
869 $head[$h][0] = DOL_URL_ROOT.
"/admin/security_other.php";
870 $head[$h][1] = $langs->trans(
"Miscellaneous");
871 $head[$h][2] =
'misc';
874 $head[$h][0] = DOL_URL_ROOT.
"/admin/security_captcha.php";
875 $head[$h][1] = $langs->trans(
"Captcha");
876 $head[$h][2] =
'captcha';
879 $head[$h][0] = DOL_URL_ROOT.
"/admin/security.php";
880 $head[$h][1] = $langs->trans(
"Passwords");
881 $head[$h][2] =
'passwords';
884 $head[$h][0] = DOL_URL_ROOT.
"/admin/security_file.php";
885 $head[$h][1] = $langs->trans(
"Files").
' ('.$langs->trans(
"UploadName").
' | '.$langs->trans(
"Download").
')';
886 $head[$h][2] =
'file';
896 $head[$h][0] = DOL_URL_ROOT.
"/admin/proxy.php";
897 $head[$h][1] = $langs->trans(
"ExternalAccess");
898 $head[$h][2] =
'proxy';
901 $head[$h][0] = DOL_URL_ROOT.
"/admin/events.php";
902 $head[$h][1] = $langs->trans(
"Audit");
903 $head[$h][2] =
'audit';
909 $sql =
"SELECT COUNT(r.id) as nb";
910 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r";
911 $sql .=
" WHERE r.libelle NOT LIKE 'tou%'";
912 $sql .=
" AND entity = ".((int)
$conf->entity);
913 $sql .=
" AND bydefault = 1";
915 $sql .=
" AND r.perms NOT LIKE '%_advance'";
917 $resql = $db->query($sql);
919 $obj = $db->fetch_object($resql);
928 $head[$h][0] = DOL_URL_ROOT.
"/admin/perms.php";
929 $head[$h][1] = $langs->trans(
"DefaultRights");
931 $head[$h][1] .= (!
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
'<span class="badge marginleftonlyshort">'.$nbPerms.
'</span>' :
'');
933 $head[$h][2] =
'default';
948 global $langs,
$conf;
955 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".
$object->id.
'&mode=desc';
956 $head[$h][1] = $langs->trans(
"Description");
957 $head[$h][2] =
'desc';
960 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".
$object->id.
'&mode=feature';
961 $head[$h][1] = $langs->trans(
"TechnicalServicesProvided");
962 $head[$h][2] =
'feature';
965 if (
$object->isCoreOrExternalModule() ==
'external') {
966 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".
$object->id.
'&mode=changelog';
967 $head[$h][1] = $langs->trans(
"ChangeLog");
968 $head[$h][2] =
'changelog';
986 global $langs,
$conf;
990 $head[$h][0] = DOL_URL_ROOT.
"/admin/translation.php?mode=searchkey";
991 $head[$h][1] = $langs->trans(
"TranslationKeySearch");
992 $head[$h][2] =
'searchkey';
995 $head[$h][0] = DOL_URL_ROOT.
"/admin/translation.php?mode=overwrite";
996 $head[$h][1] =
'<span class="valignmiddle">'.$langs->trans(
"TranslationOverwriteKey").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
997 $head[$h][2] =
'overwrite';
1016 global $langs,
$conf;
1020 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=createform";
1021 $head[$h][1] = $langs->trans(
"DefaultCreateForm");
1022 $head[$h][2] =
'createform';
1025 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=filters";
1026 $head[$h][1] = $langs->trans(
"DefaultSearchFilters");
1027 $head[$h][2] =
'filters';
1030 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=sortorder";
1031 $head[$h][1] = $langs->trans(
"DefaultSortOrder");
1032 $head[$h][2] =
'sortorder';
1035 if (!empty(
$conf->use_javascript_ajax)) {
1036 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=focus";
1037 $head[$h][1] = $langs->trans(
"DefaultFocus");
1038 $head[$h][2] =
'focus';
1041 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=mandatory";
1042 $head[$h][1] = $langs->trans(
"DefaultMandatory");
1043 $head[$h][2] =
'mandatory';
1068 global
$conf, $php_session_save_handler;
1070 $arrayofSessions = array();
1072 if (!empty($php_session_save_handler) && $php_session_save_handler ==
'db') {
1073 require_once DOL_DOCUMENT_ROOT.
'/core/lib/phpsessionin'.$php_session_save_handler.
'.lib.php';
1078 $iniPath = ini_get(
"session.save_path");
1080 $sessPath = $iniPath;
1083 dol_syslog(
'admin.lib:listOfSessions sessPath='.$sessPath);
1087 while (($file = @readdir($dh)) !==
false) {
1088 if (preg_match(
'/^sess_/i', $file) && $file !=
"." && $file !=
"..") {
1089 $fullpath = $sessPath.$file;
1090 if (!@is_dir($fullpath) && is_readable($fullpath)) {
1091 $sessValues = file_get_contents($fullpath);
1097 if (preg_match(
'/dol_login/i', $sessValues) &&
1098 (preg_match(
'/dol_entity\|i:'.
$conf->entity.
';/i', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"'.
$conf->entity.
'"/i', $sessValues)) &&
1099 preg_match(
'/dol_company\|s:([0-9]+):"('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1100 $tmp = explode(
'_', $file);
1103 $arrayofSessions[$idsess][
"login"] =
'';
1104 $loginfound = preg_match(
'/dol_login\|s:[0-9]+:"([A-Za-z0-9]+)"/i', $sessValues, $regs);
1106 $arrayofSessions[$idsess][
"login"] = (string) $regs[1];
1108 $arrayofSessions[$idsess][
"age"] = time() - filectime($fullpath);
1109 $arrayofSessions[$idsess][
"creation"] = filectime($fullpath);
1110 $arrayofSessions[$idsess][
"modification"] = filemtime($fullpath);
1111 $arrayofSessions[$idsess][
"user_agent"] =
null;
1112 $arrayofSessions[$idsess][
"remote_ip"] =
null;
1113 $arrayofSessions[$idsess][
"raw"] = $sessValues;
1121 return $arrayofSessions;
1134 $sessPath = ini_get(
"session.save_path").
"/";
1135 dol_syslog(
'admin.lib:purgeSessions mysessionid='.$mysessionid.
' sessPath='.$sessPath);
1141 while (($file = @readdir($dh)) !==
false) {
1142 if ($file !=
"." && $file !=
"..") {
1143 $fullpath = $sessPath.$file;
1144 if (!@is_dir($fullpath)) {
1145 $sessValues = file_get_contents($fullpath);
1147 if (preg_match(
'/dol_login/i', $sessValues) &&
1148 (preg_match(
'/dol_entity\|i:('.
$conf->entity.
')/', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"('.
$conf->entity.
')"/i', $sessValues)) &&
1149 preg_match(
'/dol_company\|s:([0-9]+):"(' .
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1150 $tmp = explode(
'_', $file);
1153 if ($idsess != $mysessionid) {
1154 $res = @unlink($fullpath);
1185 global $db, $langs,
$conf, $mysoc;
1190 if (empty($value)) {
1191 $ret[
'errors'] = array(
'ErrorBadParameter');
1195 $ret = array(
'nbmodules' => 0,
'errors' => array(),
'nbperms' => 0);
1197 $modFile = $modName.
".class.php";
1204 foreach ($modulesdir as $dir) {
1205 if (file_exists($dir.$modFile)) {
1206 $found = @include_once $dir.$modFile;
1213 $objMod =
new $modName($db);
1214 '@phan-var-force DolibarrModules $objMod';
1218 $vermin = isset($objMod->phpmin) ? $objMod->phpmin : 0;
1220 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequirePHPVersion",
versiontostring($vermin));
1226 $vermin = isset($objMod->need_dolibarr_version) ? $objMod->need_dolibarr_version : 0;
1229 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireDolibarrVersion",
versiontostring($vermin));
1234 if (!empty($objMod->need_javascript_ajax) && empty(
$conf->use_javascript_ajax)) {
1235 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireJavascript");
1239 $const_name = $objMod->const_name;
1240 if ($noconfverification == 0) {
1246 $result = $objMod->init();
1249 $ret[
'errors'][] = $objMod->error;
1252 if (isset($objMod->depends) && is_array($objMod->depends) && !empty($objMod->depends)) {
1255 foreach ($objMod->depends as $key => $modulestringorarray) {
1257 if ((!is_numeric($key)) && !preg_match(
'/^always/', $key) && $mysoc->country_code && !preg_match(
'/^'.$mysoc->country_code.
'/', $key)) {
1258 dol_syslog(
"We are not concerned by dependency with key=".$key.
" because our country is ".$mysoc->country_code);
1262 if (!is_array($modulestringorarray)) {
1263 $modulestringorarray = array($modulestringorarray);
1266 foreach ($modulestringorarray as $modulestring) {
1269 foreach ($modulesdir as $dir) {
1270 if (file_exists($dir.$modulestring.
".class.php")) {
1272 if (empty($resarray[
'errors'])) {
1275 $activateerr = implode(
', ', $resarray[
'errors']);
1276 foreach ($resarray[
'errors'] as $errorMessage) {
1285 $ret[
'nbmodules'] += $resarray[
'nbmodules'];
1286 $ret[
'nbperms'] += $resarray[
'nbperms'];
1289 $ret[
'errors'][] = $activateerr;
1291 $ret[
'errors'][] = $langs->trans(
'activateModuleDependNotSatisfied', $objMod->name, $modulestring, $objMod->name).
'<br>'.$langs->trans(
'activateModuleDependNotSatisfied2', $modulestring, $objMod->name);
1297 if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && !empty($objMod->conflictwith)) {
1299 $num = count($objMod->conflictwith);
1300 for ($i = 0; $i < $num; $i++) {
1301 foreach ($modulesdir as $dir) {
1302 if (file_exists($dir.$objMod->conflictwith[$i].
".class.php")) {
1311 if (!count($ret[
'errors'])) {
1312 $ret[
'nbmodules']++;
1313 $ret[
'nbperms'] += (is_array($objMod->rights) ? count($objMod->rights) : 0);
1329 global $db, $modules,
$conf;
1332 if (empty($value)) {
1333 return 'ErrorBadParameter';
1338 $modFile = $modName.
".class.php";
1345 foreach ($modulesdir as $dir) {
1346 if (file_exists($dir.$modFile)) {
1347 $found = @include_once $dir.$modFile;
1355 $objMod =
new $modName($db);
1356 '@phan-var-force DolibarrModules $objMod';
1357 $result = $objMod->remove();
1359 $ret = $objMod->error;
1364 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
1366 $genericMod->name = preg_replace(
'/^mod/i',
'', $modName);
1367 $genericMod->rights_class = strtolower(preg_replace(
'/^mod/i',
'', $modName));
1368 $genericMod->const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', $modName));
1369 dol_syslog(
"modules::unActivateModule Failed to find module file, we use generic function with name ".$modName);
1370 $genericMod->remove(
'');
1374 if (!$ret && $requiredby && isset($objMod) && is_object($objMod) && is_array($objMod->requiredby)) {
1375 $countrb = count($objMod->requiredby);
1376 for ($i = 0; $i < $countrb; $i++) {
1404function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
1408 dol_syslog(
"complete_dictionary_with_modules Search external modules to complete the list of dictionary tables", LOG_DEBUG, 1);
1415 foreach ($modulesdir as $dir) {
1418 dol_syslog(
"Scan directory ".$dir.
" for modules");
1420 if (is_resource($handle)) {
1421 while (($file = readdir($handle)) !==
false) {
1423 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1424 $modName = substr($file, 0,
dol_strlen($file) - 10);
1427 include_once $dir.$file;
1428 $objMod =
new $modName($db);
1429 '@phan-var-force DolibarrModules $objMod';
1431 if ($objMod->numero > 0) {
1432 $j = $objMod->numero;
1437 $modulequalified = 1;
1440 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1442 $modulequalified = 0;
1445 $modulequalified = 0;
1449 $modulequalified = 0;
1452 if ($modulequalified) {
1454 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1455 foreach ($objMod->langfiles as $langfile) {
1456 $langs->load($langfile);
1463 if (empty($objMod->dictionaries) && !empty($objMod->{
"dictionnaries"})) {
1465 $objMod->dictionaries = $objMod->{
"dictionnaries"};
1469 if (!empty($objMod->dictionaries)) {
1471 $nbtabname = $nbtablib = $nbtabsql = $nbtabsqlsort = $nbtabfield = $nbtabfieldvalue = $nbtabfieldinsert = $nbtabrowid = $nbtabcond = $nbtabfieldcheck = $nbtabhelp = 0;
1472 $tabnamerelwithkey = array();
1473 foreach ($objMod->dictionaries[
'tabname'] as $key => $val) {
1474 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $val);
1476 $taborder[] = max($taborder) + 1;
1478 $tabnamerelwithkey[$key] = $val;
1479 $tabcomplete[$tmptablename][
'picto'] = $objMod->picto;
1481 foreach ($objMod->dictionaries[
'tablib'] as $key => $val) {
1482 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1485 $tabcomplete[$tmptablename][
'lib'] = $val;
1487 foreach ($objMod->dictionaries[
'tabsql'] as $key => $val) {
1488 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1491 $tabcomplete[$tmptablename][
'sql'] = $val;
1493 foreach ($objMod->dictionaries[
'tabsqlsort'] as $key => $val) {
1494 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1496 $tabsqlsort[] = $val;
1497 $tabcomplete[$tmptablename][
'sqlsort'] = $val;
1499 foreach ($objMod->dictionaries[
'tabfield'] as $key => $val) {
1500 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1503 $tabcomplete[$tmptablename][
'field'] = $val;
1505 foreach ($objMod->dictionaries[
'tabfieldvalue'] as $key => $val) {
1506 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1508 $tabfieldvalue[] = $val;
1509 $tabcomplete[$tmptablename][
'value'] = $val;
1511 foreach ($objMod->dictionaries[
'tabfieldinsert'] as $key => $val) {
1512 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1513 $nbtabfieldinsert++;
1514 $tabfieldinsert[] = $val;
1515 $tabcomplete[$tmptablename][
'fieldinsert'] = $val;
1517 foreach ($objMod->dictionaries[
'tabrowid'] as $key => $val) {
1518 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1521 $tabcomplete[$tmptablename][
'rowid'] = $val;
1523 foreach ($objMod->dictionaries[
'tabcond'] as $key => $val) {
1524 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1527 $tabcomplete[$tmptablename][
'cond'] = $val;
1529 if (!empty($objMod->dictionaries[
'tabhelp'])) {
1530 foreach ($objMod->dictionaries[
'tabhelp'] as $key => $val) {
1531 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1534 $tabcomplete[$tmptablename][
'help'] = $val;
1537 if (!empty($objMod->dictionaries[
'tabfieldcheck'])) {
1538 foreach ($objMod->dictionaries[
'tabfieldcheck'] as $key => $val) {
1539 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1541 $tabcomplete[$tmptablename][
'fieldcheck'] = $val;
1545 if ($nbtabname != $nbtablib || $nbtablib != $nbtabsql || $nbtabsql != $nbtabsqlsort) {
1546 print
'Error in descriptor of module '.$const_name.
'. Array ->dictionaries has not same number of record for key "tabname", "tablib", "tabsql" and "tabsqlsort"';
1556 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1563 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1584 foreach ($modulesdir as $dir) {
1586 dol_syslog(
"Scan directory ".$dir.
" for modules");
1588 if (is_resource($handle)) {
1589 while (($file = readdir($handle)) !==
false) {
1590 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1591 $modName = substr($file, 0,
dol_strlen($file) - 10);
1594 include_once $dir.$file;
1595 $objMod =
new $modName($db);
1596 '@phan-var-force DolibarrModules $objMod';
1598 $modulequalified = 1;
1601 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1603 if ($objMod->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
1604 $modulequalified = 0;
1606 if ($objMod->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
1607 $modulequalified = 0;
1610 $modulequalified = 0;
1613 if ($modulequalified) {
1615 if (property_exists($objMod,
'automatic_activation') && isset($objMod->automatic_activation) && is_array($objMod->automatic_activation) && isset($objMod->automatic_activation[$country_code])) {
1618 setEventMessages($objMod->automatic_activation[$country_code],
null,
'warnings');
1621 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1628 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1643 global $db, $modules,
$conf, $langs;
1646 $filename = array();
1655 dol_syslog(
"complete_elementList_with_modules Search external modules to complete the list of contact element", LOG_DEBUG, 1);
1659 foreach ($modulesdir as $dir) {
1662 dol_syslog(
"Scan directory ".$dir.
" for modules");
1664 if (is_resource($handle)) {
1665 while (($file = readdir($handle)) !==
false) {
1667 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1668 $modName = substr($file, 0,
dol_strlen($file) - 10);
1671 include_once $dir.$file;
1672 $objMod =
new $modName($db);
1674 if ($objMod->numero > 0) {
1675 $j = $objMod->numero;
1680 $modulequalified = 1;
1683 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1685 $modulequalified = 0;
1688 $modulequalified = 0;
1692 $modulequalified = 0;
1695 if ($modulequalified) {
1697 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1698 foreach ($objMod->langfiles as $langfile) {
1699 $langs->load($langfile);
1703 $modules[$i] = $objMod;
1704 $filename[$i] = $modName;
1705 $orders[$i] = $objMod->family.
"_".$j;
1709 if (!empty($objMod->module_parts[
'contactelement'])) {
1710 if (is_array($objMod->module_parts[
'contactelement'])) {
1711 foreach ($objMod->module_parts[
'contactelement'] as $elem => $title) {
1712 $elementList[$elem] = $langs->trans($title);
1715 $elementList[$objMod->name] = $langs->trans($objMod->name);
1722 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1729 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1750 global $db, $langs,
$conf, $user;
1751 global $_Avery_Labels;
1753 $form =
new Form($db);
1755 if (empty($strictw3c)) {
1756 dol_syslog(
"Warning: Function 'form_constantes' was called with parameter strictw3c = 0, this is deprecated. Value must be 2 now.", LOG_WARNING);
1758 if (!empty($strictw3c) && $strictw3c == 1) {
1759 print
"\n".
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1760 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1761 print
'<input type="hidden" name="action" value="updateall">';
1764 print
'<div class="div-table-responsive-no-min">';
1765 print
'<table class="noborder centpercent">';
1766 print
'<tr class="liste_titre">';
1767 print
'<td class="">'.$langs->trans(
"Description").
'</td>';
1769 $text = $langs->trans($text);
1770 print $form->textwithpicto($text, $helptext, 1,
'help',
'', 0, 2,
'idhelptext');
1772 if (empty($strictw3c)) {
1773 print
'<td class="center" width="80">'.$langs->trans(
"Action").
'</td>';
1778 foreach ($tableau as $key => $const) {
1781 if (is_numeric($key)) {
1784 if (is_array($const)) {
1785 $type = $const[
'type'];
1786 $label = $const[
'label'];
1795 $sql .=
", ".$db->decrypt(
'name').
" as name";
1796 $sql .=
", ".$db->decrypt(
'value').
" as value";
1799 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1800 $sql .=
" WHERE ".$db->decrypt(
'name').
" = '".$db->escape($const).
"'";
1801 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
1802 $sql .=
" ORDER BY name ASC, entity DESC";
1803 $result = $db->query($sql);
1808 $obj = $db->fetch_object($result);
1811 $obj = (object) array(
'rowid' =>
'',
'name' => $const,
'value' =>
'',
'type' => $type,
'note' =>
'');
1814 if (empty($strictw3c)) {
1815 print
"\n".
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1816 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1817 print
'<input type="hidden" name="page_y" value="'.newToken().
'">';
1818 print
'<input type="hidden" name="action" value="update">';
1821 print
'<tr class="oddeven">';
1825 print
'<input type="hidden" name="rowid'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.$obj->rowid.
'">';
1826 print
'<input type="hidden" name="constname'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.$const.
'">';
1827 print
'<input type="hidden" name="constnote_'.$obj->name.
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1828 print
'<input type="hidden" name="consttype_'.$obj->name.
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1831 $tmparray = explode(
':', $obj->type);
1832 if (!empty($tmparray[1])) {
1833 $picto = preg_replace(
'/_send$/',
'', $tmparray[1]);
1835 print
img_picto(
'', $picto,
'class="pictofixedwidth"');
1837 if (!empty($tableau[$key][
'tooltip'])) {
1838 print $form->textwithpicto($label ? $label : $langs->trans(
'Desc'.$const), $tableau[$key][
'tooltip']);
1840 print($label ? $label : $langs->trans(
'Desc'.$const));
1843 if ($const ==
'ADHERENT_MAILMAN_URL') {
1844 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick1">'.
img_down().
'</a><br>';
1846 print
'<div id="example1" class="hidden">';
1847 print
'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/add?subscribees_upload=%EMAIL%&adminpw=%MAILMAN_ADMINPW%&subscribe_or_invite=0&send_welcome_msg_to_this_batch=0&notification_to_list_owner=0';
1849 } elseif ($const ==
'ADHERENT_MAILMAN_UNSUB_URL') {
1850 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick2">'.
img_down().
'</a><br>';
1851 print
'<div id="example2" class="hidden">';
1852 print
'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/remove?unsubscribees_upload=%EMAIL%&adminpw=%MAILMAN_ADMINPW%&send_unsub_ack_to_this_batch=0&send_unsub_notifications_to_list_owner=0';
1855 } elseif ($const ==
'ADHERENT_MAILMAN_LISTS') {
1856 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick3">'.
img_down().
'</a><br>';
1857 print
'<div id="example3" class="hidden">';
1858 print
'mymailmanlist<br>';
1859 print
'mymailmanlist1,mymailmanlist2<br>';
1860 print
'TYPE:Type1:mymailmanlist1,TYPE:Type2:mymailmanlist2<br>';
1861 if (isModEnabled(
'category')) {
1862 print
'CATEG:Categ1:mymailmanlist1,CATEG:Categ2:mymailmanlist2<br>';
1866 } elseif (in_array($const, [
'ADHERENT_MAIL_FROM',
'ADHERENT_CC_MAIL_FROM'])) {
1867 print
' '.img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
1873 if ($const ==
'ADHERENT_CARD_TYPE' || $const ==
'ADHERENT_ETIQUETTE_TYPE') {
1876 require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
1877 $arrayoflabels = array();
1878 foreach (array_keys($_Avery_Labels) as $codecards) {
1879 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
1881 print $form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayoflabels, ($obj->value ? $obj->value :
'CARD'), 1, 0, 0);
1882 print
'<input type="hidden" name="consttype" value="yesno">';
1883 print
'<input type="hidden" name="constnote'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1887 print
'<input type="hidden" name="consttype'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1888 print
'<input type="hidden" name="constnote'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1889 if ($obj->type ==
'textarea' || in_array($const, array(
'ADHERENT_CARD_TEXT',
'ADHERENT_CARD_TEXT_RIGHT',
'ADHERENT_ETIQUETTE_TEXT'))) {
1890 print
'<textarea class="flat" name="constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" cols="50" rows="5" wrap="soft">'.
"\n";
1892 print
"</textarea>\n";
1893 } elseif ($obj->type ==
'html') {
1894 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1895 $doleditor =
new DolEditor(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $obj->value,
'', 160,
'dolibarr_notes',
'',
false,
false, isModEnabled(
'fckeditor'), ROWS_5,
'90%');
1896 $doleditor->Create();
1897 } elseif ($obj->type ==
'yesno') {
1898 print $form->selectyesno(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $obj->value, 1,
false, 0, 1);
1899 } elseif (preg_match(
'/emailtemplate/', $obj->type)) {
1900 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1903 $tmp = explode(
':', $obj->type);
1905 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, -1);
1907 $arrayofmessagename = array();
1908 if (is_array($formmail->lines_model)) {
1909 foreach ($formmail->lines_model as $modelmail) {
1912 if (!empty($arrayofmessagename[$modelmail->label])) {
1913 $moreonlabel =
' <span class="opacitymedium">('.$langs->trans(
"SeveralLangugeVariatFound").
')</span>';
1916 $arrayofmessagename[$modelmail->label.
':'.$tmp[1]] = $langs->trans(preg_replace(
'/\(|\)/',
'', $modelmail->label)).$moreonlabel;
1921 print $form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayofmessagename, $obj->value.
':'.$tmp[1],
'None', 0, 0,
'', 0, 0, 0,
'',
'', 1);
1923 print
'<a href="'.DOL_URL_ROOT.
'/admin/mails_templates.php?action=create&type_template='.urlencode($tmp[1]).
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'">'.
img_picto(
'',
'add').
'</a>';
1924 } elseif (preg_match(
'/MAIL_FROM$/i', $const)) {
1925 print
img_picto(
'',
'email',
'class="pictofixedwidth"').
'<input type="text" class="flat minwidth300" name="constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1927 print
'<input type="text" class="flat minwidth300" name="constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1933 if (empty($strictw3c)) {
1934 print
'<td class="center">';
1935 print
'<input type="submit" class="button small reposition" value="'.$langs->trans(
"Update").
'" name="update">';
1941 if (empty($strictw3c)) {
1949 if (!empty($strictw3c) && $strictw3c == 1) {
1950 print
'<div align="center"><input type="submit" class="button small reposition" value="'.$langs->trans(
"Update").
'" name="update"></div>';
1966 $text = $langs->transnoentitiesnoconv(
"OnlyFollowingModulesAreOpenedToExternalUsers");
1970 if (!empty($modules)) {
1972 foreach ($tmpmodules as $module) {
1973 $moduleconst = $module->const_name;
1974 $modulename = strtolower($module->name);
1978 if (!in_array($modulename, $listofmodules)) {
1990 $tmptext = $langs->transnoentitiesnoconv(
'Module'.$module->numero.
'Name');
1991 if ($tmptext !=
'Module'.$module->numero.
'Name') {
1992 $text .= $langs->transnoentitiesnoconv(
'Module'.$module->numero.
'Name');
1994 $text .= $langs->transnoentitiesnoconv($module->name);
2018 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity, libelle, description)";
2019 $sql .=
" VALUES ('".$db->escape($name).
"','".$db->escape($type).
"',".((int)
$conf->entity).
", ";
2020 $sql .= ($label ?
"'".$db->escape($label).
"'" :
'null').
", ";
2021 $sql .= (!empty($description) ?
"'".$db->escape($description).
"'" :
"null");
2024 dol_syslog(
"admin.lib::addDocumentModel", LOG_DEBUG);
2025 $resql = $db->query($sql);
2049 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"document_model";
2050 $sql .=
" WHERE nom = '".$db->escape($name).
"'";
2051 $sql .=
" AND type = '".$db->escape($type).
"'";
2052 $sql .=
" AND entity = ".((int)
$conf->entity);
2054 dol_syslog(
"admin.lib::delDocumentModel", LOG_DEBUG);
2055 $resql = $db->query($sql);
2076 $phpinfostring = ob_get_contents();
2079 $info_arr = array();
2080 $info_lines = explode(
"\n", strip_tags($phpinfostring,
"<tr><td><h2>"));
2082 foreach ($info_lines as $line) {
2085 preg_match(
"~<h2>(.*)</h2>~", $line, $title) ? $cat = $title[1] :
null;
2087 if (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2088 $info_arr[trim($cat)][trim($val[1])] = $val[2];
2089 } elseif (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2090 $info_arr[trim($cat)][trim($val[1])] = array(
"local" => $val[2],
"master" => $val[3]);
2103 global $langs,
$conf;
2108 $head[$h][0] = DOL_URL_ROOT.
"/admin/company.php";
2109 $head[$h][1] = $langs->trans(
"Company");
2110 $head[$h][2] =
'company';
2113 $head[$h][0] = DOL_URL_ROOT.
"/admin/company_socialnetworks.php";
2114 $head[$h][1] = $langs->trans(
"SocialNetworksInformation");
2115 $head[$h][2] =
'socialnetworks';
2118 $head[$h][0] = DOL_URL_ROOT.
"/admin/openinghours.php";
2119 $head[$h][1] = $langs->trans(
"OpeningHours");
2120 $head[$h][2] =
'openinghours';
2123 $head[$h][0] = DOL_URL_ROOT.
"/admin/accountant.php";
2124 $head[$h][1] = $langs->trans(
"Accountant");
2125 $head[$h][2] =
'accountant';
2142 global $langs,
$conf, $user;
2147 if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
2148 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails.php";
2149 $head[$h][1] = $langs->trans(
"OutGoingEmailSetup");
2150 $head[$h][2] =
'common';
2153 if (isModEnabled(
'mailing')) {
2154 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_emailing.php";
2155 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"EMailing"));
2156 $head[$h][2] =
'common_emailing';
2160 if (isModEnabled(
'ticket')) {
2161 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ticket.php";
2162 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"Ticket"));
2163 $head[$h][2] =
'common_ticket';
2167 if (!
getDolGlobalString(
'MAIN_MAIL_HIDE_CUSTOM_SENDING_METHOD_FOR_PASSWORD_RESET')) {
2168 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_passwordreset.php";
2169 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"PasswordReset"));
2170 $head[$h][2] =
'common_passwordreset';
2176 if (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates') {
2177 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_senderprofile_list.php";
2178 $head[$h][1] = $langs->trans(
"EmailSenderProfiles");
2179 $head[$h][2] =
'senderprofiles';
2183 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_templates.php";
2184 $head[$h][1] = $langs->trans(
"EMailTemplates");
2185 $head[$h][2] =
'templates';
2188 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ingoing.php";
2189 $head[$h][1] = $langs->trans(
"InGoingEmailSetup", $langs->transnoentitiesnoconv(
"EMailing"));
2190 $head[$h][2] =
'common_ingoing';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
versiontostring($versionarray)
Renvoi une version en chaine depuis une version en tableau.
security_prepare_head()
Prepare array with list of tabs.
run_sql($sqlfile, $silent=1, $entity=0, $usesavepoint=1, $handler='', $okerror='default', $linelengthlimit=32768, $nocommentremoval=0, $offsetforchartofaccount=0, $colspan=0, $onlysqltoimportwebsite=0, $database='')
Launch a sql file.
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
purgeSessions($mysessionid)
Purge existing sessions.
unActivateModule($value, $requiredby=1)
Disable a module.
form_constantes($tableau, $strictw3c=2, $helptext='', $text='Value')
Show array with constants to edit.
activateModule($value, $withdeps=1, $noconfverification=0)
Enable a module.
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
Add external modules to list of dictionaries.
versiondolibarrarray()
Return version Dolibarr.
activateModulesRequiredByCountry($country_code)
Activate external modules mandatory when country is country_code.
delDocumentModel($name, $type)
Delete document model used by doc generator.
showModulesExludedForExternal($modules)
Show array with constants to edit.
versionphparray()
Return version PHP.
ihm_prepare_head()
Prepare array with list of tabs.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays), to know if a version (a,b,c) is lower than (x,...
modulehelp_prepare_head($object)
Prepare array with list of tabs.
listOfSessions()
Return list of session.
phpinfo_array()
Return the php_info into an array.
dolibarr_get_const($db, $name, $entity=1)
Get the value of a setup constant from database.
modules_prepare_head($nbofactivatedmodules, $nboftotalmodules, $nbmodulesnotautoenabled)
Prepare array with list of tabs.
complete_elementList_with_modules(&$elementList)
Search external modules to complete the list of contact element.
email_admin_prepare_head()
Return array head with list of tabs to view object information.
translation_prepare_head()
Prepare array with list of tabs.
company_admin_prepare_head()
Return array head with list of tabs to view object information.
defaultvalues_prepare_head()
Prepare array with list of tabs.
Class to manage a WYSIWYG editor.
dolKeepOnlyPhpCode($str)
Keep only PHP code part from a HTML string page.
dolGetModulesDirs($subdir='')
Return list of directories that contain modules.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
dolListSessions()
List sessions in db.
dolEncrypt($chain, $key='', $ciphering='', $forceseed='')
Encode a string with a symmetric encryption.
dolDecrypt($chain, $key='')
Decode a string with a symmetric encryption.
checkPHPCode(&$phpfullcodestringold, &$phpfullcodestring)
Check a new string containing only php code (including <php tag)