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];
73 $count1 = count($versionarray1);
74 $count2 = count($versionarray2);
75 $maxcount = max($count1, $count2);
76 while ($level < $maxcount) {
77 $operande1 = isset($versionarray1[$level]) ? $versionarray1[$level] : 0;
78 $operande2 = isset($versionarray2[$level]) ? $versionarray2[$level] : 0;
79 if (preg_match(
'/alpha|dev/i', $operande1)) {
82 if (preg_match(
'/alpha|dev/i', $operande2)) {
85 if (preg_match(
'/beta$/i', $operande1)) {
88 if (preg_match(
'/beta$/i', $operande2)) {
91 if (preg_match(
'/beta([0-9])+/i', $operande1)) {
94 if (preg_match(
'/beta([0-9])+/i', $operande2)) {
97 if (preg_match(
'/rc$/i', $operande1)) {
100 if (preg_match(
'/rc$/i', $operande2)) {
103 if (preg_match(
'/rc([0-9])+/i', $operande1)) {
106 if (preg_match(
'/rc([0-9])+/i', $operande2)) {
111 if ($operande1 < $operande2) {
115 if ($operande1 > $operande2) {
133 return explode(
'.', PHP_VERSION);
144 return explode(
'.', DOL_VERSION);
171function run_sql($sqlfile, $silent = 1, $entity = 0, $usesavepoint = 1, $handler =
'', $okerror =
'default', $linelengthlimit = 32768, $nocommentremoval = 0, $offsetforchartofaccount = 0, $colspan = 0, $onlysqltoimportwebsite = 0, $database =
'')
173 global $db, $conf, $langs, $user;
175 dol_syslog(
"Admin.lib::run_sql run sql file ".$sqlfile.
" silent=".$silent.
" entity=".$entity.
" usesavepoint=".$usesavepoint.
" handler=".$handler.
" okerror=".$okerror, LOG_DEBUG);
177 if (!is_numeric($linelengthlimit)) {
178 dol_syslog(
"Admin.lib::run_sql param linelengthlimit is not a numeric", LOG_ERR);
189 $versionarray = $db->getVersionArray();
191 $fp = fopen($sqlfile,
"r");
195 if ($linelengthlimit > 0) {
196 $buf = fgets($fp, $linelengthlimit);
203 if (preg_match(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i', $buf, $reg)) {
207 if (!empty($reg[1])) {
208 if (!preg_match(
'/'.preg_quote($reg[1]).
'/i', $db->type)) {
215 if (!empty($reg[2])) {
216 if (is_numeric($reg[2])) {
217 $versionrequest = explode(
'.', $reg[2]);
220 if (!count($versionrequest) || !count($versionarray) ||
versioncompare($versionrequest, $versionarray) > 0) {
224 $dbcollation = strtoupper(preg_replace(
'/_/',
'', $conf->db->dolibarr_main_db_collation));
227 if (empty($conf->db->dolibarr_main_db_collation) || ($reg[2] != $dbcollation)) {
237 $buf = preg_replace(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i',
'', $buf);
243 if ($nocommentremoval || !preg_match(
'/^\s*--/', $buf)) {
244 if (empty($nocommentremoval)) {
245 $buf = preg_replace(
'/([,;ERLT\)])\s*--.*$/i',
'\1', $buf);
250 $buffer .= trim($buf);
255 if (preg_match(
'/;/', $buffer)) {
258 $arraysql[$i] = $buffer;
266 $arraysql[$i] = $buffer;
270 dol_syslog(
"Admin.lib::run_sql failed to open file ".$sqlfile, LOG_ERR);
274 $listofmaxrowid = array();
275 foreach ($arraysql as $i => $sql) {
279 while (preg_match(
'/__\+MAX_([A-Za-z0-9_]+)__/i', $newsql, $reg)) {
281 if (!isset($listofmaxrowid[$table])) {
283 $sqlgetrowid =
'SELECT MAX(rowid) as max from '.preg_replace(
'/^llx_/', MAIN_DB_PREFIX, $table);
284 $resql = $db->query($sqlgetrowid);
286 $obj = $db->fetch_object($resql);
287 $listofmaxrowid[$table] = $obj->max;
288 if (empty($listofmaxrowid[$table])) {
289 $listofmaxrowid[$table] = 0;
293 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
294 print
'<div class="error">'.$langs->trans(
"Failed to get max rowid for ".$table).
"</div>";
302 $from =
'__+MAX_'.$table.
'__';
303 $to =
'+'.$listofmaxrowid[$table];
304 $newsql = str_replace($from, $to, $newsql);
305 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1).
' (replacing '.$from.
' to '.$to.
')', LOG_DEBUG);
307 $arraysql[$i] = $newsql;
310 if ($offsetforchartofaccount > 0) {
316 $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);
317 $newsql = preg_replace(
'/([,\s])0 \+ '.((
int) $offsetforchartofaccount).
'/ims',
'\1 0', $newsql);
319 $arraysql[$i] = $newsql;
328 $listofinsertedrowid = array();
329 $keyforsql = md5($sqlfile);
330 foreach ($arraysql as $i => $sql) {
333 if ($onlysqltoimportwebsite) {
334 $newsql = str_replace(array(
"\'"),
'__BACKSLASHQUOTE__', $sql);
337 $l = strlen($newsql);
342 $char = $newsql[$is];
349 } elseif (empty($quoteopen)) {
350 $newsqlclean .= $char;
354 $newsqlclean = str_replace(array(
"null"),
'__000__', $newsqlclean);
360 if (preg_match(
'/^--/', $newsqlclean)) {
362 } elseif (preg_match(
'/^UPDATE llx_website SET \w+ = \d+\+\d+ WHERE rowid = \d+;$/', $newsqlclean)) {
364 } elseif (preg_match(
'/^INSERT INTO llx_website_page\([a-z0-9_\s,]+\) VALUES\([0-9_\s,\+]+\);$/', $newsqlclean)) {
372 if (preg_match(
'/^UPDATE llx_website SET \w+ = \'[a-zA-Z,\s]*\' WHERE rowid = \d+;$/', $sql)) {
382 $errorphpcheck =
checkPHPCode($extractphpold, $extractphp);
383 if ($errorphpcheck) {
387 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains PHP code and checking this code returns errorphpcheck='.$errorphpcheck.'", LOG_WARNING);
397 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains non allowed instructions.", LOG_WARNING);
398 dol_syslog(
'$newsqlclean='.$newsqlclean, LOG_DEBUG);
404 if (MAIN_DB_PREFIX !=
'llx_') {
405 $sql = preg_replace(
'/llx_/i', MAIN_DB_PREFIX, $sql);
408 if (!empty($handler)) {
409 $sql = preg_replace(
'/__HANDLER__/i',
"'".$db->escape($handler).
"'", $sql);
412 if (!empty($database)) {
413 $sql = preg_replace(
'/__DATABASE__/i', $db->escape($database), $sql);
416 $newsql = preg_replace(
'/__ENTITY__/i', (!empty($entity) ? $entity : (string) $conf->entity), $sql);
420 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";
422 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1), LOG_DEBUG);
426 if (preg_match_all(
'/__ENCRYPT\(\'([^\']+)\'\)__/i', $newsql, $reg)) {
427 $num = count($reg[0]);
429 for ($j = 0; $j < $num; $j++) {
431 $to = $db->encrypt($reg[1][$j]);
432 $newsql = str_replace($from, $to, $newsql);
438 if (preg_match_all(
'/__DECRYPT\(\'([A-Za-z0-9_]+)\'\)__/i', $newsql, $reg)) {
439 $num = count($reg[0]);
441 for ($j = 0; $j < $num; $j++) {
443 $to = $db->decrypt($reg[1][$j]);
444 $newsql = str_replace($from, $to, $newsql);
450 while (preg_match(
'/__([0-9]+)__/', $newsql, $reg)) {
452 if (empty($listofinsertedrowid[$cursor])) {
454 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
455 print
'<div class="error">'.$langs->trans(
"FileIsNotCorrect").
"</div>";
462 $from =
'__'.$cursor.
'__';
463 $to = $listofinsertedrowid[$cursor];
464 $newsql = str_replace($from, $to, $newsql);
469 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1), LOG_DEBUG);
472 $result = $db->query($newsql, $usesavepoint);
475 print
'<!-- Result = OK -->'.
"\n";
478 if (preg_replace(
'/insert into ([^\s]+)/i', $newsql, $reg)) {
482 $table = preg_replace(
'/([^a-zA-Z_]+)/i',
'', $reg[1]);
483 $insertedrowid = $db->last_insert_id($table);
484 $listofinsertedrowid[$cursorinsert] = $insertedrowid;
485 dol_syslog(
'Admin.lib::run_sql Insert nb '.$cursorinsert.
', done in table '.$table.
', rowid is '.$listofinsertedrowid[$cursorinsert], LOG_DEBUG);
489 $errno = $db->errno();
491 print
'<!-- Result = '.$errno.
' -->'.
"\n";
496 'DB_ERROR_TABLE_ALREADY_EXISTS',
497 'DB_ERROR_COLUMN_ALREADY_EXISTS',
498 'DB_ERROR_KEY_NAME_ALREADY_EXISTS',
499 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS',
500 'DB_ERROR_RECORD_ALREADY_EXISTS',
501 'DB_ERROR_NOSUCHTABLE',
502 'DB_ERROR_NOSUCHFIELD',
503 'DB_ERROR_NO_FOREIGN_KEY_TO_DROP',
504 'DB_ERROR_NO_INDEX_TO_DROP',
505 'DB_ERROR_CANNOT_CREATE',
506 'DB_ERROR_CANT_DROP_PRIMARY_KEY',
507 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS',
510 if ($okerror ==
'none') {
515 if (!in_array($errno, $okerrors)) {
517 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
518 print
'<div class="error">'.$langs->trans(
"Error").
" ".$db->errno().
" (Req ".($i + 1).
"): ".$newsql.
"<br>".$db->error().
"</div>";
519 print
'</td></tr>'.
"\n";
521 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" Error ".$db->errno().
" ".$newsql.
"<br>".$db->error(), LOG_ERR);
529 print
'<tr><td>'.$langs->trans(
"ProcessMigrateScript").
'</td>';
530 print
'<td class="right">';
532 print
'<span class="ok">'.$langs->trans(
"OK").
'</span>';
534 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
538 print
'<script type="text/javascript">
539 jQuery(document).ready(function() {
540 function init_trrunsql'.$keyforsql.
'()
542 console.log("toggle .trforrunsql'.$keyforsql.
'");
543 jQuery(".trforrunsql'.$keyforsql.
'").toggle();
545 init_trrunsql'.$keyforsql.
'();
546 jQuery(".trforrunsqlshowhide'.$keyforsql.
'").click(function() {
547 init_trrunsql'.$keyforsql.
'();
551 if (count($arraysql)) {
552 print
' - <a class="trforrunsqlshowhide'.$keyforsql.
'" href="#" title="'.($langs->trans(
"ShowHideTheNRequests", count($arraysql))).
'">'.$langs->trans(
"ShowHideDetails").
'</a>';
554 print
' - <span class="opacitymedium">'.$langs->trans(
"ScriptIsEmpty").
'</span>';
558 print
'</td></tr>'.
"\n";
583 global $conf, $hookmanager;
586 dol_print_error(
null,
'Error call dolibar_del_const with parameter name empty');
589 if (! is_object($hookmanager)) {
590 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
599 $reshook = $hookmanager->executeHooks(
'dolibarrDelConst', $parameters);
604 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
605 $sql .=
" WHERE (".$db->decrypt(
'name').
" = '".$db->escape((
string) $name).
"'";
606 if (is_numeric($name)) {
607 $sql .=
" OR rowid = ".((int) $name);
611 $sql .=
" AND entity = ".((int) $entity);
614 dol_syslog(
"admin.lib::dolibarr_del_const", LOG_DEBUG);
615 $resql = $db->query($sql);
617 $conf->global->$name =
'';
639 $sql =
"SELECT ".$db->decrypt(
'value').
" as value";
640 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
641 $sql .=
" WHERE name = ".$db->encrypt($name);
642 $sql .=
" AND entity = ".((int) $entity);
644 dol_syslog(
"admin.lib::dolibarr_get_const", LOG_DEBUG);
645 $resql = $db->query($sql);
647 $obj = $db->fetch_object($resql);
649 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
671function dolibarr_set_const($db, $name, $value, $type =
'chaine', $visible = 0, $note =
'', $entity = 1)
673 global $conf, $hookmanager;
677 $value = (string) $value;
681 dol_print_error($db,
"Error: Call to function dolibarr_set_const with wrong parameters");
684 if (! is_object($hookmanager)) {
685 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
689 $value = (string) $value;
695 'visible' => $visible,
700 $reshook = $hookmanager->executeHooks(
'dolibarrSetConst', $parameters);
709 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
710 $sql .=
" WHERE name = ".$db->encrypt($name);
712 $sql .=
" AND entity = ".((int) $entity);
715 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
716 $resql = $db->query($sql);
718 if (strcmp($value,
'')) {
719 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))) {
724 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
730 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name, value, type, visible, note, entity)";
732 $sql .= $db->encrypt($name);
733 $sql .=
", ".$db->encrypt($newvalue);
734 $sql .=
", '".$db->escape($type).
"', ".((int) $visible).
", '".$db->escape($note).
"', ".((int) $entity).
")";
738 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
739 $resql = $db->query($sql);
744 $conf->global->$name = $value;
765 global $langs, $form;
767 $desc = $langs->trans(
"ModulesDesc",
'{picto}');
768 $desc = str_replace(
'{picto}',
img_picto(
'',
'switch_off'), $desc);
773 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=".$mode;
774 if ($nbmodulesnotautoenabled <=
getDolGlobalInt(
'MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) {
776 $head[$h][1] = $langs->trans(
"AvailableModules");
777 $head[$h][1] .= $form->textwithpicto(
'', $langs->trans(
"YouMustEnableOneModule").
'.<br><br><span class="opacitymedium">'.$desc.
'</span>', 1,
'warning');
780 $head[$h][1] = $langs->trans(
"AvailableModules").
'<span class="badge marginleftonly">'.$nbofactivatedmodules.
' / '.$nboftotalmodules.
'</span>';
782 $head[$h][2] =
'modules';
785 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=marketplace";
786 $head[$h][1] = $langs->trans(
"ModulesMarketPlaces");
787 $head[$h][2] =
'marketplace';
790 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=deploy";
791 $head[$h][1] = $langs->trans(
"AddExtensionThemeModuleOrOther");
792 $head[$h][2] =
'deploy';
795 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=develop";
796 $head[$h][1] = $langs->trans(
"ModulesDevelopYourModule");
797 $head[$h][2] =
'develop';
810 global $langs, $conf, $user;
814 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=other";
815 $head[$h][1] = $langs->trans(
"LanguageAndPresentation");
816 $head[$h][2] =
'other';
819 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=template";
820 $head[$h][1] = $langs->trans(
"SkinAndColors");
821 $head[$h][2] =
'template';
824 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=dashboard";
825 $head[$h][1] = $langs->trans(
"Dashboard");
826 $head[$h][2] =
'dashboard';
829 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=login";
830 $head[$h][1] = $langs->trans(
"LoginPage");
831 $head[$h][2] =
'login';
834 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=css";
835 $head[$h][1] = $langs->trans(
"CSSPage");
836 $head[$h][2] =
'css';
855 global $db, $langs, $conf, $user;
859 $head[$h][0] = DOL_URL_ROOT.
"/admin/security_other.php";
860 $head[$h][1] = $langs->trans(
"Miscellaneous");
861 $head[$h][2] =
'misc';
864 $head[$h][0] = DOL_URL_ROOT.
"/admin/security_captcha.php";
865 $head[$h][1] = $langs->trans(
"Captcha");
866 $head[$h][2] =
'captcha';
869 $head[$h][0] = DOL_URL_ROOT.
"/admin/security.php";
870 $head[$h][1] = $langs->trans(
"Passwords");
871 $head[$h][2] =
'passwords';
874 $head[$h][0] = DOL_URL_ROOT.
"/admin/security_file.php";
875 $head[$h][1] = $langs->trans(
"Files").
' ('.$langs->trans(
"Upload").
')';
876 $head[$h][2] =
'file';
886 $head[$h][0] = DOL_URL_ROOT.
"/admin/proxy.php";
887 $head[$h][1] = $langs->trans(
"ExternalAccess");
888 $head[$h][2] =
'proxy';
891 $head[$h][0] = DOL_URL_ROOT.
"/admin/events.php";
892 $head[$h][1] = $langs->trans(
"Audit");
893 $head[$h][2] =
'audit';
899 $sql =
"SELECT COUNT(r.id) as nb";
900 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r";
901 $sql .=
" WHERE r.libelle NOT LIKE 'tou%'";
902 $sql .=
" AND entity = ".((int) $conf->entity);
903 $sql .=
" AND bydefault = 1";
905 $sql .=
" AND r.perms NOT LIKE '%_advance'";
907 $resql = $db->query($sql);
909 $obj = $db->fetch_object($resql);
918 $head[$h][0] = DOL_URL_ROOT.
"/admin/perms.php";
919 $head[$h][1] = $langs->trans(
"DefaultRights");
921 $head[$h][1] .= (!
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
'<span class="badge marginleftonlyshort">'.$nbPerms.
'</span>' :
'');
923 $head[$h][2] =
'default';
938 global $langs, $conf;
945 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".
$object->id.
'&mode=desc';
946 $head[$h][1] = $langs->trans(
"Description");
947 $head[$h][2] =
'desc';
950 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".
$object->id.
'&mode=feature';
951 $head[$h][1] = $langs->trans(
"TechnicalServicesProvided");
952 $head[$h][2] =
'feature';
955 if (
$object->isCoreOrExternalModule() ==
'external') {
956 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".
$object->id.
'&mode=changelog';
957 $head[$h][1] = $langs->trans(
"ChangeLog");
958 $head[$h][2] =
'changelog';
976 global $langs, $conf;
980 $head[$h][0] = DOL_URL_ROOT.
"/admin/translation.php?mode=searchkey";
981 $head[$h][1] = $langs->trans(
"TranslationKeySearch");
982 $head[$h][2] =
'searchkey';
985 $head[$h][0] = DOL_URL_ROOT.
"/admin/translation.php?mode=overwrite";
986 $head[$h][1] =
'<span class="valignmiddle">'.$langs->trans(
"TranslationOverwriteKey").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
987 $head[$h][2] =
'overwrite';
1006 global $langs, $conf, $user;
1010 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=createform";
1011 $head[$h][1] = $langs->trans(
"DefaultCreateForm");
1012 $head[$h][2] =
'createform';
1015 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=filters";
1016 $head[$h][1] = $langs->trans(
"DefaultSearchFilters");
1017 $head[$h][2] =
'filters';
1020 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=sortorder";
1021 $head[$h][1] = $langs->trans(
"DefaultSortOrder");
1022 $head[$h][2] =
'sortorder';
1025 if (!empty($conf->use_javascript_ajax)) {
1026 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=focus";
1027 $head[$h][1] = $langs->trans(
"DefaultFocus");
1028 $head[$h][2] =
'focus';
1031 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=mandatory";
1032 $head[$h][1] = $langs->trans(
"DefaultMandatory");
1033 $head[$h][2] =
'mandatory';
1060 $arrayofSessions = array();
1063 $iniPath = ini_get(
"session.save_path");
1065 $sessPath = $iniPath;
1068 dol_syslog(
'admin.lib:listOfSessions sessPath='.$sessPath);
1072 while (($file = @readdir($dh)) !==
false) {
1073 if (preg_match(
'/^sess_/i', $file) && $file !=
"." && $file !=
"..") {
1074 $fullpath = $sessPath.$file;
1075 if (!@is_dir($fullpath) && is_readable($fullpath)) {
1076 $sessValues = file_get_contents($fullpath);
1082 if (preg_match(
'/dol_login/i', $sessValues) &&
1083 (preg_match(
'/dol_entity\|i:'.$conf->entity.
';/i', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"'.$conf->entity.
'"/i', $sessValues)) &&
1084 preg_match(
'/dol_company\|s:([0-9]+):"('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1085 $tmp = explode(
'_', $file);
1088 $loginfound = preg_match(
'/dol_login\|s:[0-9]+:"([A-Za-z0-9]+)"/i', $sessValues, $regs);
1090 $arrayofSessions[$idsess][
"login"] = $regs[1];
1092 $arrayofSessions[$idsess][
"age"] = time() - filectime($fullpath);
1093 $arrayofSessions[$idsess][
"creation"] = filectime($fullpath);
1094 $arrayofSessions[$idsess][
"modification"] = filemtime($fullpath);
1095 $arrayofSessions[$idsess][
"raw"] = $sessValues;
1103 return $arrayofSessions;
1116 $sessPath = ini_get(
"session.save_path").
"/";
1117 dol_syslog(
'admin.lib:purgeSessions mysessionid='.$mysessionid.
' sessPath='.$sessPath);
1123 while (($file = @readdir($dh)) !==
false) {
1124 if ($file !=
"." && $file !=
"..") {
1125 $fullpath = $sessPath.$file;
1126 if (!@is_dir($fullpath)) {
1127 $sessValues = file_get_contents($fullpath);
1129 if (preg_match(
'/dol_login/i', $sessValues) &&
1130 preg_match(
'/dol_entity\|s:([0-9]+):"('.$conf->entity.
')"/i', $sessValues) &&
1131 preg_match(
'/dol_company\|s:([0-9]+):"(' .
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1132 $tmp = explode(
'_', $file);
1135 if ($idsess != $mysessionid) {
1136 $res = @unlink($fullpath);
1167 global $db, $langs, $conf, $mysoc;
1172 if (empty($value)) {
1173 $ret[
'errors'] = array(
'ErrorBadParameter');
1177 $ret = array(
'nbmodules' => 0,
'errors' => array(),
'nbperms' => 0);
1179 $modFile = $modName.
".class.php";
1186 foreach ($modulesdir as $dir) {
1187 if (file_exists($dir.$modFile)) {
1188 $found = @include_once $dir.$modFile;
1195 $objMod =
new $modName($db);
1196 '@phan-var-force DolibarrModules $objMod';
1200 $vermin = isset($objMod->phpmin) ? $objMod->phpmin : 0;
1202 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequirePHPVersion",
versiontostring($vermin));
1208 $vermin = isset($objMod->need_dolibarr_version) ? $objMod->need_dolibarr_version : 0;
1211 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireDolibarrVersion",
versiontostring($vermin));
1216 if (!empty($objMod->need_javascript_ajax) && empty($conf->use_javascript_ajax)) {
1217 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireJavascript");
1221 $const_name = $objMod->const_name;
1222 if ($noconfverification == 0) {
1228 $result = $objMod->init();
1231 $ret[
'errors'][] = $objMod->error;
1234 if (isset($objMod->depends) && is_array($objMod->depends) && !empty($objMod->depends)) {
1237 foreach ($objMod->depends as $key => $modulestringorarray) {
1239 if ((!is_numeric($key)) && !preg_match(
'/^always/', $key) && $mysoc->country_code && !preg_match(
'/^'.$mysoc->country_code.
'/', $key)) {
1240 dol_syslog(
"We are not concerned by dependency with key=".$key.
" because our country is ".$mysoc->country_code);
1244 if (!is_array($modulestringorarray)) {
1245 $modulestringorarray = array($modulestringorarray);
1248 foreach ($modulestringorarray as $modulestring) {
1251 foreach ($modulesdir as $dir) {
1252 if (file_exists($dir.$modulestring.
".class.php")) {
1254 if (empty($resarray[
'errors'])) {
1257 $activateerr = implode(
', ', $resarray[
'errors']);
1258 foreach ($resarray[
'errors'] as $errorMessage) {
1267 $ret[
'nbmodules'] += $resarray[
'nbmodules'];
1268 $ret[
'nbperms'] += $resarray[
'nbperms'];
1271 $ret[
'errors'][] = $activateerr;
1273 $ret[
'errors'][] = $langs->trans(
'activateModuleDependNotSatisfied', $objMod->name, $modulestring);
1279 if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && !empty($objMod->conflictwith)) {
1281 $num = count($objMod->conflictwith);
1282 for ($i = 0; $i < $num; $i++) {
1283 foreach ($modulesdir as $dir) {
1284 if (file_exists($dir.$objMod->conflictwith[$i].
".class.php")) {
1293 if (!count($ret[
'errors'])) {
1294 $ret[
'nbmodules']++;
1295 $ret[
'nbperms'] += (is_array($objMod->rights) ? count($objMod->rights) : 0);
1311 global $db, $modules, $conf;
1314 if (empty($value)) {
1315 return 'ErrorBadParameter';
1320 $modFile = $modName.
".class.php";
1327 foreach ($modulesdir as $dir) {
1328 if (file_exists($dir.$modFile)) {
1329 $found = @include_once $dir.$modFile;
1337 $objMod =
new $modName($db);
1338 '@phan-var-force DolibarrModules $objMod';
1339 $result = $objMod->remove();
1341 $ret = $objMod->error;
1346 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
1348 $genericMod->name = preg_replace(
'/^mod/i',
'', $modName);
1349 $genericMod->rights_class = strtolower(preg_replace(
'/^mod/i',
'', $modName));
1350 $genericMod->const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', $modName));
1351 dol_syslog(
"modules::unActivateModule Failed to find module file, we use generic function with name ".$modName);
1352 $genericMod->remove(
'');
1356 if (!$ret && $requiredby && isset($objMod) && is_object($objMod) && is_array($objMod->requiredby)) {
1357 $countrb = count($objMod->requiredby);
1358 for ($i = 0; $i < $countrb; $i++) {
1386function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
1390 dol_syslog(
"complete_dictionary_with_modules Search external modules to complete the list of dictionary tables", LOG_DEBUG, 1);
1397 foreach ($modulesdir as $dir) {
1400 dol_syslog(
"Scan directory ".$dir.
" for modules");
1402 if (is_resource($handle)) {
1403 while (($file = readdir($handle)) !==
false) {
1405 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1406 $modName = substr($file, 0,
dol_strlen($file) - 10);
1409 include_once $dir.$file;
1410 $objMod =
new $modName($db);
1411 '@phan-var-force DolibarrModules $objMod';
1413 if ($objMod->numero > 0) {
1414 $j = $objMod->numero;
1419 $modulequalified = 1;
1422 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1424 $modulequalified = 0;
1427 $modulequalified = 0;
1431 $modulequalified = 0;
1434 if ($modulequalified) {
1436 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1437 foreach ($objMod->langfiles as $langfile) {
1438 $langs->load($langfile);
1445 if (empty($objMod->dictionaries) && !empty($objMod->{
"dictionnaries"})) {
1447 $objMod->dictionaries = $objMod->{
"dictionnaries"};
1451 if (!empty($objMod->dictionaries)) {
1453 $nbtabname = $nbtablib = $nbtabsql = $nbtabsqlsort = $nbtabfield = $nbtabfieldvalue = $nbtabfieldinsert = $nbtabrowid = $nbtabcond = $nbtabfieldcheck = $nbtabhelp = 0;
1454 $tabnamerelwithkey = array();
1455 foreach ($objMod->dictionaries[
'tabname'] as $key => $val) {
1456 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $val);
1458 $taborder[] = max($taborder) + 1;
1460 $tabnamerelwithkey[$key] = $val;
1461 $tabcomplete[$tmptablename][
'picto'] = $objMod->picto;
1463 foreach ($objMod->dictionaries[
'tablib'] as $key => $val) {
1464 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1467 $tabcomplete[$tmptablename][
'lib'] = $val;
1469 foreach ($objMod->dictionaries[
'tabsql'] as $key => $val) {
1470 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1473 $tabcomplete[$tmptablename][
'sql'] = $val;
1475 foreach ($objMod->dictionaries[
'tabsqlsort'] as $key => $val) {
1476 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1478 $tabsqlsort[] = $val;
1479 $tabcomplete[$tmptablename][
'sqlsort'] = $val;
1481 foreach ($objMod->dictionaries[
'tabfield'] as $key => $val) {
1482 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1485 $tabcomplete[$tmptablename][
'field'] = $val;
1487 foreach ($objMod->dictionaries[
'tabfieldvalue'] as $key => $val) {
1488 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1490 $tabfieldvalue[] = $val;
1491 $tabcomplete[$tmptablename][
'value'] = $val;
1493 foreach ($objMod->dictionaries[
'tabfieldinsert'] as $key => $val) {
1494 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1495 $nbtabfieldinsert++;
1496 $tabfieldinsert[] = $val;
1497 $tabcomplete[$tmptablename][
'fieldinsert'] = $val;
1499 foreach ($objMod->dictionaries[
'tabrowid'] as $key => $val) {
1500 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1503 $tabcomplete[$tmptablename][
'rowid'] = $val;
1505 foreach ($objMod->dictionaries[
'tabcond'] as $key => $val) {
1506 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1509 $tabcomplete[$tmptablename][
'cond'] = $val;
1511 if (!empty($objMod->dictionaries[
'tabhelp'])) {
1512 foreach ($objMod->dictionaries[
'tabhelp'] as $key => $val) {
1513 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1516 $tabcomplete[$tmptablename][
'help'] = $val;
1519 if (!empty($objMod->dictionaries[
'tabfieldcheck'])) {
1520 foreach ($objMod->dictionaries[
'tabfieldcheck'] as $key => $val) {
1521 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1523 $tabcomplete[$tmptablename][
'fieldcheck'] = $val;
1527 if ($nbtabname != $nbtablib || $nbtablib != $nbtabsql || $nbtabsql != $nbtabsqlsort) {
1528 print
'Error in descriptor of module '.$const_name.
'. Array ->dictionaries has not same number of record for key "tabname", "tablib", "tabsql" and "tabsqlsort"';
1538 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1545 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1562 global $db, $conf, $langs;
1566 foreach ($modulesdir as $dir) {
1568 dol_syslog(
"Scan directory ".$dir.
" for modules");
1570 if (is_resource($handle)) {
1571 while (($file = readdir($handle)) !==
false) {
1572 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1573 $modName = substr($file, 0,
dol_strlen($file) - 10);
1576 include_once $dir.$file;
1577 $objMod =
new $modName($db);
1578 '@phan-var-force DolibarrModules $objMod';
1580 $modulequalified = 1;
1583 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1585 if ($objMod->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
1586 $modulequalified = 0;
1588 if ($objMod->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
1589 $modulequalified = 0;
1592 $modulequalified = 0;
1595 if ($modulequalified) {
1597 if (property_exists($objMod,
'automatic_activation') && isset($objMod->automatic_activation) && is_array($objMod->automatic_activation) && isset($objMod->automatic_activation[$country_code])) {
1600 setEventMessages($objMod->automatic_activation[$country_code],
null,
'warnings');
1603 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1610 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1625 global $db, $modules, $conf, $langs;
1628 $filename = array();
1637 dol_syslog(
"complete_elementList_with_modules Search external modules to complete the list of contact element", LOG_DEBUG, 1);
1641 foreach ($modulesdir as $dir) {
1644 dol_syslog(
"Scan directory ".$dir.
" for modules");
1646 if (is_resource($handle)) {
1647 while (($file = readdir($handle)) !==
false) {
1649 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1650 $modName = substr($file, 0,
dol_strlen($file) - 10);
1653 include_once $dir.$file;
1654 $objMod =
new $modName($db);
1656 if ($objMod->numero > 0) {
1657 $j = $objMod->numero;
1662 $modulequalified = 1;
1665 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1667 $modulequalified = 0;
1670 $modulequalified = 0;
1674 $modulequalified = 0;
1677 if ($modulequalified) {
1679 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1680 foreach ($objMod->langfiles as $langfile) {
1681 $langs->load($langfile);
1685 $modules[$i] = $objMod;
1686 $filename[$i] = $modName;
1687 $orders[$i] = $objMod->family.
"_".$j;
1691 if (!empty($objMod->module_parts[
'contactelement'])) {
1692 if (is_array($objMod->module_parts[
'contactelement'])) {
1693 foreach ($objMod->module_parts[
'contactelement'] as $elem => $title) {
1694 $elementList[$elem] = $langs->trans($title);
1697 $elementList[$objMod->name] = $langs->trans($objMod->name);
1704 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1711 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1732 global $db, $langs, $conf, $user;
1733 global $_Avery_Labels;
1735 $form =
new Form($db);
1737 if (empty($strictw3c)) {
1738 dol_syslog(
"Warning: Function 'form_constantes' was called with parameter strictw3c = 0, this is deprecated. Value must be 2 now.", LOG_WARNING);
1740 if (!empty($strictw3c) && $strictw3c == 1) {
1741 print
"\n".
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1742 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1743 print
'<input type="hidden" name="action" value="updateall">';
1746 print
'<div class="div-table-responsive-no-min">';
1747 print
'<table class="noborder centpercent">';
1748 print
'<tr class="liste_titre">';
1749 print
'<td class="">'.$langs->trans(
"Description").
'</td>';
1751 $text = $langs->trans($text);
1752 print $form->textwithpicto($text, $helptext, 1,
'help',
'', 0, 2,
'idhelptext');
1754 if (empty($strictw3c)) {
1755 print
'<td class="center" width="80">'.$langs->trans(
"Action").
'</td>';
1760 foreach ($tableau as $key => $const) {
1763 if (is_numeric($key)) {
1766 if (is_array($const)) {
1767 $type = $const[
'type'];
1768 $label = $const[
'label'];
1777 $sql .=
", ".$db->decrypt(
'name').
" as name";
1778 $sql .=
", ".$db->decrypt(
'value').
" as value";
1781 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1782 $sql .=
" WHERE ".$db->decrypt(
'name').
" = '".$db->escape($const).
"'";
1783 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
1784 $sql .=
" ORDER BY name ASC, entity DESC";
1785 $result = $db->query($sql);
1790 $obj = $db->fetch_object($result);
1793 $obj = (object) array(
'rowid' =>
'',
'name' => $const,
'value' =>
'',
'type' => $type,
'note' =>
'');
1796 if (empty($strictw3c)) {
1797 print
"\n".
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1798 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1799 print
'<input type="hidden" name="page_y" value="'.newToken().
'">';
1800 print
'<input type="hidden" name="action" value="update">';
1803 print
'<tr class="oddeven">';
1807 print
'<input type="hidden" name="rowid'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.$obj->rowid.
'">';
1808 print
'<input type="hidden" name="constname'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.$const.
'">';
1809 print
'<input type="hidden" name="constnote_'.$obj->name.
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1810 print
'<input type="hidden" name="consttype_'.$obj->name.
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1813 $tmparray = explode(
':', $obj->type);
1814 if (!empty($tmparray[1])) {
1815 $picto = preg_replace(
'/_send$/',
'', $tmparray[1]);
1817 print
img_picto(
'', $picto,
'class="pictofixedwidth"');
1819 if (!empty($tableau[$key][
'tooltip'])) {
1820 print $form->textwithpicto($label ? $label : $langs->trans(
'Desc'.$const), $tableau[$key][
'tooltip']);
1822 print($label ? $label : $langs->trans(
'Desc'.$const));
1825 if ($const ==
'ADHERENT_MAILMAN_URL') {
1826 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick1">'.
img_down().
'</a><br>';
1828 print
'<div id="example1" class="hidden">';
1829 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';
1831 } elseif ($const ==
'ADHERENT_MAILMAN_UNSUB_URL') {
1832 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick2">'.
img_down().
'</a><br>';
1833 print
'<div id="example2" class="hidden">';
1834 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';
1837 } elseif ($const ==
'ADHERENT_MAILMAN_LISTS') {
1838 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick3">'.
img_down().
'</a><br>';
1839 print
'<div id="example3" class="hidden">';
1840 print
'mymailmanlist<br>';
1841 print
'mymailmanlist1,mymailmanlist2<br>';
1842 print
'TYPE:Type1:mymailmanlist1,TYPE:Type2:mymailmanlist2<br>';
1843 if (isModEnabled(
'category')) {
1844 print
'CATEG:Categ1:mymailmanlist1,CATEG:Categ2:mymailmanlist2<br>';
1848 } elseif (in_array($const, [
'ADHERENT_MAIL_FROM',
'ADHERENT_CC_MAIL_FROM'])) {
1849 print
' '.img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
1855 if ($const ==
'ADHERENT_CARD_TYPE' || $const ==
'ADHERENT_ETIQUETTE_TYPE') {
1858 require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
1859 $arrayoflabels = array();
1860 foreach (array_keys($_Avery_Labels) as $codecards) {
1861 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
1863 print $form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayoflabels, ($obj->value ? $obj->value :
'CARD'), 1, 0, 0);
1864 print
'<input type="hidden" name="consttype" value="yesno">';
1865 print
'<input type="hidden" name="constnote'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1869 print
'<input type="hidden" name="consttype'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1870 print
'<input type="hidden" name="constnote'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1871 if ($obj->type ==
'textarea' || in_array($const, array(
'ADHERENT_CARD_TEXT',
'ADHERENT_CARD_TEXT_RIGHT',
'ADHERENT_ETIQUETTE_TEXT'))) {
1872 print
'<textarea class="flat" name="constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" cols="50" rows="5" wrap="soft">'.
"\n";
1874 print
"</textarea>\n";
1875 } elseif ($obj->type ==
'html') {
1876 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1877 $doleditor =
new DolEditor(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $obj->value,
'', 160,
'dolibarr_notes',
'',
false,
false, isModEnabled(
'fckeditor'), ROWS_5,
'90%');
1878 $doleditor->Create();
1879 } elseif ($obj->type ==
'yesno') {
1880 print $form->selectyesno(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $obj->value, 1,
false, 0, 1);
1881 } elseif (preg_match(
'/emailtemplate/', $obj->type)) {
1882 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1885 $tmp = explode(
':', $obj->type);
1887 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, -1);
1889 $arrayofmessagename = array();
1890 if (is_array($formmail->lines_model)) {
1891 foreach ($formmail->lines_model as $modelmail) {
1894 if (!empty($arrayofmessagename[$modelmail->label])) {
1895 $moreonlabel =
' <span class="opacitymedium">('.$langs->trans(
"SeveralLangugeVariatFound").
')</span>';
1898 $arrayofmessagename[$modelmail->label.
':'.$tmp[1]] = $langs->trans(preg_replace(
'/\(|\)/',
'', $modelmail->label)).$moreonlabel;
1903 print $form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayofmessagename, $obj->value.
':'.$tmp[1],
'None', 0, 0,
'', 0, 0, 0,
'',
'', 1);
1904 } elseif (preg_match(
'/MAIL_FROM$/i', $const)) {
1905 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).
'">';
1907 print
'<input type="text" class="flat minwidth300" name="constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1913 if (empty($strictw3c)) {
1914 print
'<td class="center">';
1915 print
'<input type="submit" class="button small reposition" value="'.$langs->trans(
"Update").
'" name="update">';
1921 if (empty($strictw3c)) {
1929 if (!empty($strictw3c) && $strictw3c == 1) {
1930 print
'<div align="center"><input type="submit" class="button small reposition" value="'.$langs->trans(
"Update").
'" name="update"></div>';
1944 global $conf, $langs;
1946 $text = $langs->trans(
"OnlyFollowingModulesAreOpenedToExternalUsers");
1950 if (!empty($modules)) {
1952 foreach ($tmpmodules as $module) {
1953 $moduleconst = $module->const_name;
1954 $modulename = strtolower($module->name);
1958 if (!in_array($modulename, $listofmodules)) {
1970 $tmptext = $langs->trans(
'Module'.$module->numero.
'Name');
1971 if ($tmptext !=
'Module'.$module->numero.
'Name') {
1972 $text .= $langs->trans(
'Module'.$module->numero.
'Name');
1974 $text .= $langs->trans($module->name);
1998 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity, libelle, description)";
1999 $sql .=
" VALUES ('".$db->escape($name).
"','".$db->escape($type).
"',".((int) $conf->entity).
", ";
2000 $sql .= ($label ?
"'".$db->escape($label).
"'" :
'null').
", ";
2001 $sql .= (!empty($description) ?
"'".$db->escape($description).
"'" :
"null");
2004 dol_syslog(
"admin.lib::addDocumentModel", LOG_DEBUG);
2005 $resql = $db->query($sql);
2029 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"document_model";
2030 $sql .=
" WHERE nom = '".$db->escape($name).
"'";
2031 $sql .=
" AND type = '".$db->escape($type).
"'";
2032 $sql .=
" AND entity = ".((int) $conf->entity);
2034 dol_syslog(
"admin.lib::delDocumentModel", LOG_DEBUG);
2035 $resql = $db->query($sql);
2056 $phpinfostring = ob_get_contents();
2059 $info_arr = array();
2060 $info_lines = explode(
"\n", strip_tags($phpinfostring,
"<tr><td><h2>"));
2062 foreach ($info_lines as $line) {
2065 preg_match(
"~<h2>(.*)</h2>~", $line, $title) ? $cat = $title[1] :
null;
2067 if (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2068 $info_arr[trim($cat)][trim($val[1])] = $val[2];
2069 } elseif (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2070 $info_arr[trim($cat)][trim($val[1])] = array(
"local" => $val[2],
"master" => $val[3]);
2083 global $langs, $conf;
2088 $head[$h][0] = DOL_URL_ROOT.
"/admin/company.php";
2089 $head[$h][1] = $langs->trans(
"Company");
2090 $head[$h][2] =
'company';
2093 $head[$h][0] = DOL_URL_ROOT.
"/admin/company_socialnetworks.php";
2094 $head[$h][1] = $langs->trans(
"SocialNetworksInformation");
2095 $head[$h][2] =
'socialnetworks';
2098 $head[$h][0] = DOL_URL_ROOT.
"/admin/openinghours.php";
2099 $head[$h][1] = $langs->trans(
"OpeningHours");
2100 $head[$h][2] =
'openinghours';
2103 $head[$h][0] = DOL_URL_ROOT.
"/admin/accountant.php";
2104 $head[$h][1] = $langs->trans(
"Accountant");
2105 $head[$h][2] =
'accountant';
2122 global $langs, $conf, $user;
2127 if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
2128 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails.php";
2129 $head[$h][1] = $langs->trans(
"OutGoingEmailSetup");
2130 $head[$h][2] =
'common';
2133 if (isModEnabled(
'mailing')) {
2134 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_emailing.php";
2135 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"EMailing"));
2136 $head[$h][2] =
'common_emailing';
2140 if (isModEnabled(
'ticket')) {
2141 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ticket.php";
2142 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"Ticket"));
2143 $head[$h][2] =
'common_ticket';
2147 if (
getDolGlobalString(
'MAIN_MAIL_ALLOW_CUSTOM_SENDING_METHOD_FOR_PASSWORD_RESET')) {
2148 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_passwordreset.php";
2149 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"PasswordReset"));
2150 $head[$h][2] =
'common_passwordreset';
2156 if (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates') {
2157 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_senderprofile_list.php";
2158 $head[$h][1] = $langs->trans(
"EmailSenderProfiles");
2159 $head[$h][2] =
'senderprofiles';
2163 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_templates.php";
2164 $head[$h][1] = $langs->trans(
"EMailTemplates");
2165 $head[$h][2] =
'templates';
2168 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ingoing.php";
2169 $head[$h][1] = $langs->trans(
"InGoingEmailSetup", $langs->transnoentitiesnoconv(
"EMailing"));
2170 $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).
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.
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)
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...
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)
dolKeepOnlyPhpCode($str)
Keep only PHP code part from a HTML string page.