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, $user;
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();
193 $fp = fopen($sqlfile,
"r");
197 if ($linelengthlimit > 0) {
198 $buf = fgets($fp, $linelengthlimit);
205 if (preg_match(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i', $buf, $reg)) {
209 if (!empty($reg[1])) {
210 if (!preg_match(
'/'.preg_quote($reg[1]).
'/i', $db->type)) {
217 if (!empty($reg[2])) {
218 if (is_numeric($reg[2])) {
219 $versionrequest = explode(
'.', $reg[2]);
222 if (!count($versionrequest) || !count($versionarray) ||
versioncompare($versionrequest, $versionarray) > 0) {
226 $dbcollation = strtoupper(preg_replace(
'/_/',
'',
$conf->db->dolibarr_main_db_collation));
229 if (empty(
$conf->db->dolibarr_main_db_collation) || ($reg[2] != $dbcollation)) {
239 $buf = preg_replace(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i',
'', $buf);
245 if ($nocommentremoval || !preg_match(
'/^\s*--/', $buf)) {
246 if (empty($nocommentremoval)) {
247 $buf = preg_replace(
'/([,;ERLT0\)])\s+--.*$/i',
'\1', $buf);
252 $buffer .= trim($buf);
257 if (preg_match(
'/;/', $buffer)) {
260 $arraysql[$i] = $buffer;
268 $arraysql[$i] = $buffer;
272 dol_syslog(
"Admin.lib::run_sql failed to open file ".$sqlfile, LOG_ERR);
276 $listofmaxrowid = array();
277 foreach ($arraysql as $i => $sql) {
281 while (preg_match(
'/__\+MAX_([A-Za-z0-9_]+)__/i', $newsql, $reg)) {
283 if (!isset($listofmaxrowid[$table])) {
285 $sqlgetrowid =
'SELECT MAX(rowid) as max from '.preg_replace(
'/^llx_/', MAIN_DB_PREFIX, $table);
286 $resql = $db->query($sqlgetrowid);
288 $obj = $db->fetch_object($resql);
289 $listofmaxrowid[$table] = $obj->max;
290 if (empty($listofmaxrowid[$table])) {
291 $listofmaxrowid[$table] = 0;
295 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
296 print
'<div class="error">'.$langs->trans(
"Failed to get max rowid for ".$table).
"</div>";
304 $from =
'__+MAX_'.$table.
'__';
305 $to =
'+'.$listofmaxrowid[$table];
306 $newsql = str_replace($from, $to, $newsql);
307 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1).
' (replacing '.$from.
' to '.$to.
')', LOG_DEBUG);
309 $arraysql[$i] = $newsql;
312 if ($offsetforchartofaccount > 0) {
318 $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);
319 $newsql = preg_replace(
'/([,\s])0 \+ '.((
int) $offsetforchartofaccount).
'/ims',
'\1 0', $newsql);
321 $arraysql[$i] = $newsql;
330 $listofinsertedrowid = array();
331 $keyforsql = md5($sqlfile);
332 foreach ($arraysql as $i => $sql) {
335 if ($onlysqltoimportwebsite) {
336 $newsql = str_replace(array(
"\'"),
'__BACKSLASHQUOTE__', $sql);
339 $l = strlen($newsql);
344 $char = $newsql[$is];
351 } elseif (empty($quoteopen)) {
352 $newsqlclean .= $char;
356 $newsqlclean = str_replace(array(
"null"),
'__000__', $newsqlclean);
362 if (preg_match(
'/^--/', $newsqlclean)) {
364 } elseif (preg_match(
'/^UPDATE llx_website SET \w+ = \d+\+\d+ WHERE rowid = \d+;$/', $newsqlclean)) {
366 } elseif (preg_match(
'/^INSERT INTO llx_website_page\([a-z0-9_\s,]+\) VALUES\([0-9_\s,\+]+\);$/', $newsqlclean)) {
374 if (preg_match(
'/^UPDATE llx_website SET \w+ = \'[a-zA-Z,\s]*\' WHERE rowid = \d+;$/', $sql)) {
384 $errorphpcheck =
checkPHPCode($extractphpold, $extractphp);
385 if ($errorphpcheck) {
389 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains PHP code and checking this code returns errorphpcheck='.$errorphpcheck.'", LOG_WARNING);
399 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains non allowed instructions.", LOG_WARNING);
400 dol_syslog(
'$newsqlclean='.$newsqlclean, LOG_DEBUG);
406 if (MAIN_DB_PREFIX !=
'llx_') {
407 $sql = preg_replace(
'/llx_/i', MAIN_DB_PREFIX, $sql);
410 if (!empty($handler)) {
411 $sql = preg_replace(
'/__HANDLER__/i',
"'".$db->escape($handler).
"'", $sql);
414 if (!empty($database)) {
415 $sql = preg_replace(
'/__DATABASE__/i', $db->escape($database), $sql);
418 $newsql = preg_replace(
'/__ENTITY__/i', (!empty($entity) ? $entity : (string)
$conf->entity), $sql);
422 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";
424 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1), LOG_DEBUG);
428 if (preg_match_all(
'/__ENCRYPT\(\'([^\']+)\'\)__/i', $newsql, $reg)) {
429 $num = count($reg[0]);
431 for ($j = 0; $j < $num; $j++) {
433 $to = $db->encrypt($reg[1][$j]);
434 $newsql = str_replace($from, $to, $newsql);
440 if (preg_match_all(
'/__DECRYPT\(\'([A-Za-z0-9_]+)\'\)__/i', $newsql, $reg)) {
441 $num = count($reg[0]);
443 for ($j = 0; $j < $num; $j++) {
445 $to = $db->decrypt($reg[1][$j]);
446 $newsql = str_replace($from, $to, $newsql);
452 while (preg_match(
'/__([0-9]+)__/', $newsql, $reg)) {
454 if (empty($listofinsertedrowid[$cursor])) {
456 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
457 print
'<div class="error">'.$langs->trans(
"FileIsNotCorrect").
"</div>";
464 $from =
'__'.$cursor.
'__';
465 $to = $listofinsertedrowid[$cursor];
466 $newsql = str_replace($from, $to, $newsql);
471 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1), LOG_DEBUG);
474 $result = $db->query($newsql, $usesavepoint);
477 print
'<!-- Result = OK -->'.
"\n";
480 if (preg_replace(
'/insert into ([^\s]+)/i', $newsql, $reg)) {
484 $table = preg_replace(
'/([^a-zA-Z_]+)/i',
'', $reg[1]);
485 $insertedrowid = $db->last_insert_id($table);
486 $listofinsertedrowid[$cursorinsert] = $insertedrowid;
487 dol_syslog(
'Admin.lib::run_sql Insert nb '.$cursorinsert.
', done in table '.$table.
', rowid is '.$listofinsertedrowid[$cursorinsert], LOG_DEBUG);
491 $errno = $db->errno();
493 print
'<!-- Result = '.$errno.
' -->'.
"\n";
498 'DB_ERROR_TABLE_ALREADY_EXISTS',
499 'DB_ERROR_COLUMN_ALREADY_EXISTS',
500 'DB_ERROR_KEY_NAME_ALREADY_EXISTS',
501 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS',
502 'DB_ERROR_RECORD_ALREADY_EXISTS',
503 'DB_ERROR_NOSUCHTABLE',
504 'DB_ERROR_NOSUCHFIELD',
505 'DB_ERROR_NO_FOREIGN_KEY_TO_DROP',
506 'DB_ERROR_NO_INDEX_TO_DROP',
507 'DB_ERROR_CANNOT_CREATE',
508 'DB_ERROR_CANT_DROP_PRIMARY_KEY',
509 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS',
512 if ($okerror ==
'none') {
517 if (!in_array($errno, $okerrors)) {
519 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
520 print
'<div class="error">'.$langs->trans(
"Error").
" ".$db->errno().
" (Req ".($i + 1).
"): ".$newsql.
"<br>".$db->error().
"</div>";
521 print
'</td></tr>'.
"\n";
523 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" Error ".$db->errno().
" ".$newsql.
"<br>".$db->error(), LOG_ERR);
531 print
'<tr><td>'.$langs->trans(
"ProcessMigrateScript").
'</td>';
532 print
'<td class="right">';
534 print
'<span class="ok">'.$langs->trans(
"OK").
'</span>';
536 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
540 print
'<script type="text/javascript">
541 jQuery(document).ready(function() {
542 function init_trrunsql'.$keyforsql.
'()
544 console.log("toggle .trforrunsql'.$keyforsql.
'");
545 jQuery(".trforrunsql'.$keyforsql.
'").toggle();
547 init_trrunsql'.$keyforsql.
'();
548 jQuery(".trforrunsqlshowhide'.$keyforsql.
'").click(function() {
549 init_trrunsql'.$keyforsql.
'();
553 if (count($arraysql)) {
554 print
' - <a class="trforrunsqlshowhide'.$keyforsql.
'" href="#" title="'.($langs->trans(
"ShowHideTheNRequests", count($arraysql))).
'">'.$langs->trans(
"ShowHideDetails").
'</a>';
556 print
' - <span class="opacitymedium">'.$langs->trans(
"ScriptIsEmpty").
'</span>';
560 print
'</td></tr>'.
"\n";
585 global
$conf, $hookmanager;
588 dol_print_error(
null,
'Error call dolibar_del_const with parameter name empty');
591 if (! is_object($hookmanager)) {
592 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
601 $reshook = $hookmanager->executeHooks(
'dolibarrDelConst', $parameters);
606 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
607 $sql .=
" WHERE (".$db->decrypt(
'name').
" = '".$db->escape((
string) $name).
"'";
608 if (is_numeric($name)) {
609 $sql .=
" OR rowid = ".((int) $name);
613 $sql .=
" AND entity = ".((int) $entity);
616 dol_syslog(
"admin.lib::dolibarr_del_const", LOG_DEBUG);
617 $resql = $db->query($sql);
619 $conf->global->$name =
'';
641 $sql =
"SELECT ".$db->decrypt(
'value').
" as value";
642 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
643 $sql .=
" WHERE name = ".$db->encrypt($name);
644 $sql .=
" AND entity = ".((int) $entity);
646 dol_syslog(
"admin.lib::dolibarr_get_const", LOG_DEBUG);
647 $resql = $db->query($sql);
649 $obj = $db->fetch_object($resql);
651 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
673function dolibarr_set_const($db, $name, $value, $type =
'chaine', $visible = 0, $note =
'', $entity = 1)
675 global
$conf, $hookmanager;
679 $value = (string) $value;
683 dol_print_error($db,
"Error: Call to function dolibarr_set_const with wrong parameters");
686 if (! is_object($hookmanager)) {
687 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
691 $value = (string) $value;
697 'visible' => $visible,
702 $reshook = $hookmanager->executeHooks(
'dolibarrSetConst', $parameters);
711 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
712 $sql .=
" WHERE name = ".$db->encrypt($name);
714 $sql .=
" AND entity = ".((int) $entity);
717 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
718 $resql = $db->query($sql);
720 if (strcmp($value,
'')) {
721 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))) {
726 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
732 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name, value, type, visible, note, entity)";
734 $sql .= $db->encrypt($name);
735 $sql .=
", ".$db->encrypt($newvalue);
736 $sql .=
", '".$db->escape($type).
"', ".((int) $visible).
", '".$db->escape($note).
"', ".((int) $entity).
")";
740 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
741 $resql = $db->query($sql);
746 $conf->global->$name = $value;
767 global $langs, $form;
769 $desc = $langs->trans(
"ModulesDesc",
'{picto}');
770 $desc = str_replace(
'{picto}',
img_picto(
'',
'switch_off'), $desc);
775 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=".$mode;
776 if ($nbmodulesnotautoenabled <=
getDolGlobalInt(
'MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) {
778 $head[$h][1] = $langs->trans(
"AvailableModules");
779 $head[$h][1] .= $form->textwithpicto(
'', $langs->trans(
"YouMustEnableOneModule").
'.<br><br><span class="opacitymedium">'.$desc.
'</span>', 1,
'warning');
782 $head[$h][1] = $langs->trans(
"AvailableModules").
'<span class="badge marginleftonly">'.$nbofactivatedmodules.
' / '.$nboftotalmodules.
'</span>';
784 $head[$h][2] =
'modules';
787 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=marketplace";
788 $head[$h][1] = $langs->trans(
"ModulesMarketPlaces");
789 $head[$h][2] =
'marketplace';
792 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=deploy";
793 $head[$h][1] = $langs->trans(
"AddExtensionThemeModuleOrOther");
794 $head[$h][2] =
'deploy';
797 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=develop";
798 $head[$h][1] = $langs->trans(
"ModulesDevelopYourModule");
799 $head[$h][2] =
'develop';
812 global $langs,
$conf, $user;
816 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=other";
817 $head[$h][1] = $langs->trans(
"LanguageAndPresentation");
818 $head[$h][2] =
'other';
821 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=template";
822 $head[$h][1] = $langs->trans(
"SkinAndColors");
823 $head[$h][2] =
'template';
826 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=dashboard";
827 $head[$h][1] = $langs->trans(
"Dashboard");
828 $head[$h][2] =
'dashboard';
831 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=login";
832 $head[$h][1] = $langs->trans(
"LoginPage");
833 $head[$h][2] =
'login';
836 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=css";
837 $head[$h][1] = $langs->trans(
"CSSPage");
838 $head[$h][2] =
'css';
857 global $db, $langs,
$conf, $user;
861 $head[$h][0] = DOL_URL_ROOT.
"/admin/security_other.php";
862 $head[$h][1] = $langs->trans(
"Miscellaneous");
863 $head[$h][2] =
'misc';
866 $head[$h][0] = DOL_URL_ROOT.
"/admin/security_captcha.php";
867 $head[$h][1] = $langs->trans(
"Captcha");
868 $head[$h][2] =
'captcha';
871 $head[$h][0] = DOL_URL_ROOT.
"/admin/security.php";
872 $head[$h][1] = $langs->trans(
"Passwords");
873 $head[$h][2] =
'passwords';
876 $head[$h][0] = DOL_URL_ROOT.
"/admin/security_file.php";
877 $head[$h][1] = $langs->trans(
"Files").
' ('.$langs->trans(
"Upload").
')';
878 $head[$h][2] =
'file';
888 $head[$h][0] = DOL_URL_ROOT.
"/admin/proxy.php";
889 $head[$h][1] = $langs->trans(
"ExternalAccess");
890 $head[$h][2] =
'proxy';
893 $head[$h][0] = DOL_URL_ROOT.
"/admin/events.php";
894 $head[$h][1] = $langs->trans(
"Audit");
895 $head[$h][2] =
'audit';
901 $sql =
"SELECT COUNT(r.id) as nb";
902 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r";
903 $sql .=
" WHERE r.libelle NOT LIKE 'tou%'";
904 $sql .=
" AND entity = ".((int)
$conf->entity);
905 $sql .=
" AND bydefault = 1";
907 $sql .=
" AND r.perms NOT LIKE '%_advance'";
909 $resql = $db->query($sql);
911 $obj = $db->fetch_object($resql);
920 $head[$h][0] = DOL_URL_ROOT.
"/admin/perms.php";
921 $head[$h][1] = $langs->trans(
"DefaultRights");
923 $head[$h][1] .= (!
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
'<span class="badge marginleftonlyshort">'.$nbPerms.
'</span>' :
'');
925 $head[$h][2] =
'default';
940 global $langs,
$conf;
947 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".
$object->id.
'&mode=desc';
948 $head[$h][1] = $langs->trans(
"Description");
949 $head[$h][2] =
'desc';
952 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".
$object->id.
'&mode=feature';
953 $head[$h][1] = $langs->trans(
"TechnicalServicesProvided");
954 $head[$h][2] =
'feature';
957 if (
$object->isCoreOrExternalModule() ==
'external') {
958 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".
$object->id.
'&mode=changelog';
959 $head[$h][1] = $langs->trans(
"ChangeLog");
960 $head[$h][2] =
'changelog';
978 global $langs,
$conf;
982 $head[$h][0] = DOL_URL_ROOT.
"/admin/translation.php?mode=searchkey";
983 $head[$h][1] = $langs->trans(
"TranslationKeySearch");
984 $head[$h][2] =
'searchkey';
987 $head[$h][0] = DOL_URL_ROOT.
"/admin/translation.php?mode=overwrite";
988 $head[$h][1] =
'<span class="valignmiddle">'.$langs->trans(
"TranslationOverwriteKey").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
989 $head[$h][2] =
'overwrite';
1008 global $langs,
$conf, $user;
1012 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=createform";
1013 $head[$h][1] = $langs->trans(
"DefaultCreateForm");
1014 $head[$h][2] =
'createform';
1017 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=filters";
1018 $head[$h][1] = $langs->trans(
"DefaultSearchFilters");
1019 $head[$h][2] =
'filters';
1022 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=sortorder";
1023 $head[$h][1] = $langs->trans(
"DefaultSortOrder");
1024 $head[$h][2] =
'sortorder';
1027 if (!empty(
$conf->use_javascript_ajax)) {
1028 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=focus";
1029 $head[$h][1] = $langs->trans(
"DefaultFocus");
1030 $head[$h][2] =
'focus';
1033 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=mandatory";
1034 $head[$h][1] = $langs->trans(
"DefaultMandatory");
1035 $head[$h][2] =
'mandatory';
1062 $arrayofSessions = array();
1065 $iniPath = ini_get(
"session.save_path");
1067 $sessPath = $iniPath;
1070 dol_syslog(
'admin.lib:listOfSessions sessPath='.$sessPath);
1074 while (($file = @readdir($dh)) !==
false) {
1075 if (preg_match(
'/^sess_/i', $file) && $file !=
"." && $file !=
"..") {
1076 $fullpath = $sessPath.$file;
1077 if (!@is_dir($fullpath) && is_readable($fullpath)) {
1078 $sessValues = file_get_contents($fullpath);
1084 if (preg_match(
'/dol_login/i', $sessValues) &&
1085 (preg_match(
'/dol_entity\|i:'.
$conf->entity.
';/i', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"'.
$conf->entity.
'"/i', $sessValues)) &&
1086 preg_match(
'/dol_company\|s:([0-9]+):"('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1087 $tmp = explode(
'_', $file);
1090 $loginfound = preg_match(
'/dol_login\|s:[0-9]+:"([A-Za-z0-9]+)"/i', $sessValues, $regs);
1092 $arrayofSessions[$idsess][
"login"] = $regs[1];
1094 $arrayofSessions[$idsess][
"age"] = time() - filectime($fullpath);
1095 $arrayofSessions[$idsess][
"creation"] = filectime($fullpath);
1096 $arrayofSessions[$idsess][
"modification"] = filemtime($fullpath);
1097 $arrayofSessions[$idsess][
"raw"] = $sessValues;
1105 return $arrayofSessions;
1118 $sessPath = ini_get(
"session.save_path").
"/";
1119 dol_syslog(
'admin.lib:purgeSessions mysessionid='.$mysessionid.
' sessPath='.$sessPath);
1125 while (($file = @readdir($dh)) !==
false) {
1126 if ($file !=
"." && $file !=
"..") {
1127 $fullpath = $sessPath.$file;
1128 if (!@is_dir($fullpath)) {
1129 $sessValues = file_get_contents($fullpath);
1131 if (preg_match(
'/dol_login/i', $sessValues) &&
1132 (preg_match(
'/dol_entity\|i:('.
$conf->entity.
')/', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"('.
$conf->entity.
')"/i', $sessValues)) &&
1133 preg_match(
'/dol_company\|s:([0-9]+):"(' .
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1134 $tmp = explode(
'_', $file);
1137 if ($idsess != $mysessionid) {
1138 $res = @unlink($fullpath);
1169 global $db, $langs,
$conf, $mysoc;
1174 if (empty($value)) {
1175 $ret[
'errors'] = array(
'ErrorBadParameter');
1179 $ret = array(
'nbmodules' => 0,
'errors' => array(),
'nbperms' => 0);
1181 $modFile = $modName.
".class.php";
1188 foreach ($modulesdir as $dir) {
1189 if (file_exists($dir.$modFile)) {
1190 $found = @include_once $dir.$modFile;
1197 $objMod =
new $modName($db);
1198 '@phan-var-force DolibarrModules $objMod';
1202 $vermin = isset($objMod->phpmin) ? $objMod->phpmin : 0;
1204 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequirePHPVersion",
versiontostring($vermin));
1210 $vermin = isset($objMod->need_dolibarr_version) ? $objMod->need_dolibarr_version : 0;
1213 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireDolibarrVersion",
versiontostring($vermin));
1218 if (!empty($objMod->need_javascript_ajax) && empty(
$conf->use_javascript_ajax)) {
1219 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireJavascript");
1223 $const_name = $objMod->const_name;
1224 if ($noconfverification == 0) {
1230 $result = $objMod->init();
1233 $ret[
'errors'][] = $objMod->error;
1236 if (isset($objMod->depends) && is_array($objMod->depends) && !empty($objMod->depends)) {
1239 foreach ($objMod->depends as $key => $modulestringorarray) {
1241 if ((!is_numeric($key)) && !preg_match(
'/^always/', $key) && $mysoc->country_code && !preg_match(
'/^'.$mysoc->country_code.
'/', $key)) {
1242 dol_syslog(
"We are not concerned by dependency with key=".$key.
" because our country is ".$mysoc->country_code);
1246 if (!is_array($modulestringorarray)) {
1247 $modulestringorarray = array($modulestringorarray);
1250 foreach ($modulestringorarray as $modulestring) {
1253 foreach ($modulesdir as $dir) {
1254 if (file_exists($dir.$modulestring.
".class.php")) {
1256 if (empty($resarray[
'errors'])) {
1259 $activateerr = implode(
', ', $resarray[
'errors']);
1260 foreach ($resarray[
'errors'] as $errorMessage) {
1269 $ret[
'nbmodules'] += $resarray[
'nbmodules'];
1270 $ret[
'nbperms'] += $resarray[
'nbperms'];
1273 $ret[
'errors'][] = $activateerr;
1275 $ret[
'errors'][] = $langs->trans(
'activateModuleDependNotSatisfied', $objMod->name, $modulestring, $objMod->name).
'<br>'.$langs->trans(
'activateModuleDependNotSatisfied2', $modulestring, $objMod->name);
1281 if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && !empty($objMod->conflictwith)) {
1283 $num = count($objMod->conflictwith);
1284 for ($i = 0; $i < $num; $i++) {
1285 foreach ($modulesdir as $dir) {
1286 if (file_exists($dir.$objMod->conflictwith[$i].
".class.php")) {
1295 if (!count($ret[
'errors'])) {
1296 $ret[
'nbmodules']++;
1297 $ret[
'nbperms'] += (is_array($objMod->rights) ? count($objMod->rights) : 0);
1313 global $db, $modules,
$conf;
1316 if (empty($value)) {
1317 return 'ErrorBadParameter';
1322 $modFile = $modName.
".class.php";
1329 foreach ($modulesdir as $dir) {
1330 if (file_exists($dir.$modFile)) {
1331 $found = @include_once $dir.$modFile;
1339 $objMod =
new $modName($db);
1340 '@phan-var-force DolibarrModules $objMod';
1341 $result = $objMod->remove();
1343 $ret = $objMod->error;
1348 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
1350 $genericMod->name = preg_replace(
'/^mod/i',
'', $modName);
1351 $genericMod->rights_class = strtolower(preg_replace(
'/^mod/i',
'', $modName));
1352 $genericMod->const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', $modName));
1353 dol_syslog(
"modules::unActivateModule Failed to find module file, we use generic function with name ".$modName);
1354 $genericMod->remove(
'');
1358 if (!$ret && $requiredby && isset($objMod) && is_object($objMod) && is_array($objMod->requiredby)) {
1359 $countrb = count($objMod->requiredby);
1360 for ($i = 0; $i < $countrb; $i++) {
1388function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
1392 dol_syslog(
"complete_dictionary_with_modules Search external modules to complete the list of dictionary tables", LOG_DEBUG, 1);
1399 foreach ($modulesdir as $dir) {
1402 dol_syslog(
"Scan directory ".$dir.
" for modules");
1404 if (is_resource($handle)) {
1405 while (($file = readdir($handle)) !==
false) {
1407 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1408 $modName = substr($file, 0,
dol_strlen($file) - 10);
1411 include_once $dir.$file;
1412 $objMod =
new $modName($db);
1413 '@phan-var-force DolibarrModules $objMod';
1415 if ($objMod->numero > 0) {
1416 $j = $objMod->numero;
1421 $modulequalified = 1;
1424 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1426 $modulequalified = 0;
1429 $modulequalified = 0;
1433 $modulequalified = 0;
1436 if ($modulequalified) {
1438 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1439 foreach ($objMod->langfiles as $langfile) {
1440 $langs->load($langfile);
1447 if (empty($objMod->dictionaries) && !empty($objMod->{
"dictionnaries"})) {
1449 $objMod->dictionaries = $objMod->{
"dictionnaries"};
1453 if (!empty($objMod->dictionaries)) {
1455 $nbtabname = $nbtablib = $nbtabsql = $nbtabsqlsort = $nbtabfield = $nbtabfieldvalue = $nbtabfieldinsert = $nbtabrowid = $nbtabcond = $nbtabfieldcheck = $nbtabhelp = 0;
1456 $tabnamerelwithkey = array();
1457 foreach ($objMod->dictionaries[
'tabname'] as $key => $val) {
1458 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $val);
1460 $taborder[] = max($taborder) + 1;
1462 $tabnamerelwithkey[$key] = $val;
1463 $tabcomplete[$tmptablename][
'picto'] = $objMod->picto;
1465 foreach ($objMod->dictionaries[
'tablib'] as $key => $val) {
1466 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1469 $tabcomplete[$tmptablename][
'lib'] = $val;
1471 foreach ($objMod->dictionaries[
'tabsql'] as $key => $val) {
1472 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1475 $tabcomplete[$tmptablename][
'sql'] = $val;
1477 foreach ($objMod->dictionaries[
'tabsqlsort'] as $key => $val) {
1478 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1480 $tabsqlsort[] = $val;
1481 $tabcomplete[$tmptablename][
'sqlsort'] = $val;
1483 foreach ($objMod->dictionaries[
'tabfield'] as $key => $val) {
1484 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1487 $tabcomplete[$tmptablename][
'field'] = $val;
1489 foreach ($objMod->dictionaries[
'tabfieldvalue'] as $key => $val) {
1490 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1492 $tabfieldvalue[] = $val;
1493 $tabcomplete[$tmptablename][
'value'] = $val;
1495 foreach ($objMod->dictionaries[
'tabfieldinsert'] as $key => $val) {
1496 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1497 $nbtabfieldinsert++;
1498 $tabfieldinsert[] = $val;
1499 $tabcomplete[$tmptablename][
'fieldinsert'] = $val;
1501 foreach ($objMod->dictionaries[
'tabrowid'] as $key => $val) {
1502 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1505 $tabcomplete[$tmptablename][
'rowid'] = $val;
1507 foreach ($objMod->dictionaries[
'tabcond'] as $key => $val) {
1508 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1511 $tabcomplete[$tmptablename][
'cond'] = $val;
1513 if (!empty($objMod->dictionaries[
'tabhelp'])) {
1514 foreach ($objMod->dictionaries[
'tabhelp'] as $key => $val) {
1515 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1518 $tabcomplete[$tmptablename][
'help'] = $val;
1521 if (!empty($objMod->dictionaries[
'tabfieldcheck'])) {
1522 foreach ($objMod->dictionaries[
'tabfieldcheck'] as $key => $val) {
1523 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1525 $tabcomplete[$tmptablename][
'fieldcheck'] = $val;
1529 if ($nbtabname != $nbtablib || $nbtablib != $nbtabsql || $nbtabsql != $nbtabsqlsort) {
1530 print
'Error in descriptor of module '.$const_name.
'. Array ->dictionaries has not same number of record for key "tabname", "tablib", "tabsql" and "tabsqlsort"';
1540 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1547 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1564 global $db,
$conf, $langs;
1568 foreach ($modulesdir as $dir) {
1570 dol_syslog(
"Scan directory ".$dir.
" for modules");
1572 if (is_resource($handle)) {
1573 while (($file = readdir($handle)) !==
false) {
1574 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1575 $modName = substr($file, 0,
dol_strlen($file) - 10);
1578 include_once $dir.$file;
1579 $objMod =
new $modName($db);
1580 '@phan-var-force DolibarrModules $objMod';
1582 $modulequalified = 1;
1585 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1587 if ($objMod->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
1588 $modulequalified = 0;
1590 if ($objMod->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
1591 $modulequalified = 0;
1594 $modulequalified = 0;
1597 if ($modulequalified) {
1599 if (property_exists($objMod,
'automatic_activation') && isset($objMod->automatic_activation) && is_array($objMod->automatic_activation) && isset($objMod->automatic_activation[$country_code])) {
1602 setEventMessages($objMod->automatic_activation[$country_code],
null,
'warnings');
1605 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1612 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1627 global $db, $modules,
$conf, $langs;
1630 $filename = array();
1639 dol_syslog(
"complete_elementList_with_modules Search external modules to complete the list of contact element", LOG_DEBUG, 1);
1643 foreach ($modulesdir as $dir) {
1646 dol_syslog(
"Scan directory ".$dir.
" for modules");
1648 if (is_resource($handle)) {
1649 while (($file = readdir($handle)) !==
false) {
1651 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1652 $modName = substr($file, 0,
dol_strlen($file) - 10);
1655 include_once $dir.$file;
1656 $objMod =
new $modName($db);
1658 if ($objMod->numero > 0) {
1659 $j = $objMod->numero;
1664 $modulequalified = 1;
1667 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1669 $modulequalified = 0;
1672 $modulequalified = 0;
1676 $modulequalified = 0;
1679 if ($modulequalified) {
1681 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1682 foreach ($objMod->langfiles as $langfile) {
1683 $langs->load($langfile);
1687 $modules[$i] = $objMod;
1688 $filename[$i] = $modName;
1689 $orders[$i] = $objMod->family.
"_".$j;
1693 if (!empty($objMod->module_parts[
'contactelement'])) {
1694 if (is_array($objMod->module_parts[
'contactelement'])) {
1695 foreach ($objMod->module_parts[
'contactelement'] as $elem => $title) {
1696 $elementList[$elem] = $langs->trans($title);
1699 $elementList[$objMod->name] = $langs->trans($objMod->name);
1706 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1713 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1734 global $db, $langs,
$conf, $user;
1735 global $_Avery_Labels;
1737 $form =
new Form($db);
1739 if (empty($strictw3c)) {
1740 dol_syslog(
"Warning: Function 'form_constantes' was called with parameter strictw3c = 0, this is deprecated. Value must be 2 now.", LOG_WARNING);
1742 if (!empty($strictw3c) && $strictw3c == 1) {
1743 print
"\n".
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1744 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1745 print
'<input type="hidden" name="action" value="updateall">';
1748 print
'<div class="div-table-responsive-no-min">';
1749 print
'<table class="noborder centpercent">';
1750 print
'<tr class="liste_titre">';
1751 print
'<td class="">'.$langs->trans(
"Description").
'</td>';
1753 $text = $langs->trans($text);
1754 print $form->textwithpicto($text, $helptext, 1,
'help',
'', 0, 2,
'idhelptext');
1756 if (empty($strictw3c)) {
1757 print
'<td class="center" width="80">'.$langs->trans(
"Action").
'</td>';
1762 foreach ($tableau as $key => $const) {
1765 if (is_numeric($key)) {
1768 if (is_array($const)) {
1769 $type = $const[
'type'];
1770 $label = $const[
'label'];
1779 $sql .=
", ".$db->decrypt(
'name').
" as name";
1780 $sql .=
", ".$db->decrypt(
'value').
" as value";
1783 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1784 $sql .=
" WHERE ".$db->decrypt(
'name').
" = '".$db->escape($const).
"'";
1785 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
1786 $sql .=
" ORDER BY name ASC, entity DESC";
1787 $result = $db->query($sql);
1792 $obj = $db->fetch_object($result);
1795 $obj = (object) array(
'rowid' =>
'',
'name' => $const,
'value' =>
'',
'type' => $type,
'note' =>
'');
1798 if (empty($strictw3c)) {
1799 print
"\n".
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1800 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1801 print
'<input type="hidden" name="page_y" value="'.newToken().
'">';
1802 print
'<input type="hidden" name="action" value="update">';
1805 print
'<tr class="oddeven">';
1809 print
'<input type="hidden" name="rowid'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.$obj->rowid.
'">';
1810 print
'<input type="hidden" name="constname'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.$const.
'">';
1811 print
'<input type="hidden" name="constnote_'.$obj->name.
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1812 print
'<input type="hidden" name="consttype_'.$obj->name.
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1815 $tmparray = explode(
':', $obj->type);
1816 if (!empty($tmparray[1])) {
1817 $picto = preg_replace(
'/_send$/',
'', $tmparray[1]);
1819 print
img_picto(
'', $picto,
'class="pictofixedwidth"');
1821 if (!empty($tableau[$key][
'tooltip'])) {
1822 print $form->textwithpicto($label ? $label : $langs->trans(
'Desc'.$const), $tableau[$key][
'tooltip']);
1824 print($label ? $label : $langs->trans(
'Desc'.$const));
1827 if ($const ==
'ADHERENT_MAILMAN_URL') {
1828 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick1">'.
img_down().
'</a><br>';
1830 print
'<div id="example1" class="hidden">';
1831 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';
1833 } elseif ($const ==
'ADHERENT_MAILMAN_UNSUB_URL') {
1834 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick2">'.
img_down().
'</a><br>';
1835 print
'<div id="example2" class="hidden">';
1836 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';
1839 } elseif ($const ==
'ADHERENT_MAILMAN_LISTS') {
1840 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick3">'.
img_down().
'</a><br>';
1841 print
'<div id="example3" class="hidden">';
1842 print
'mymailmanlist<br>';
1843 print
'mymailmanlist1,mymailmanlist2<br>';
1844 print
'TYPE:Type1:mymailmanlist1,TYPE:Type2:mymailmanlist2<br>';
1845 if (isModEnabled(
'category')) {
1846 print
'CATEG:Categ1:mymailmanlist1,CATEG:Categ2:mymailmanlist2<br>';
1850 } elseif (in_array($const, [
'ADHERENT_MAIL_FROM',
'ADHERENT_CC_MAIL_FROM'])) {
1851 print
' '.img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
1857 if ($const ==
'ADHERENT_CARD_TYPE' || $const ==
'ADHERENT_ETIQUETTE_TYPE') {
1860 require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
1861 $arrayoflabels = array();
1862 foreach (array_keys($_Avery_Labels) as $codecards) {
1863 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
1865 print $form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayoflabels, ($obj->value ? $obj->value :
'CARD'), 1, 0, 0);
1866 print
'<input type="hidden" name="consttype" value="yesno">';
1867 print
'<input type="hidden" name="constnote'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1871 print
'<input type="hidden" name="consttype'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1872 print
'<input type="hidden" name="constnote'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1873 if ($obj->type ==
'textarea' || in_array($const, array(
'ADHERENT_CARD_TEXT',
'ADHERENT_CARD_TEXT_RIGHT',
'ADHERENT_ETIQUETTE_TEXT'))) {
1874 print
'<textarea class="flat" name="constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" cols="50" rows="5" wrap="soft">'.
"\n";
1876 print
"</textarea>\n";
1877 } elseif ($obj->type ==
'html') {
1878 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1879 $doleditor =
new DolEditor(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $obj->value,
'', 160,
'dolibarr_notes',
'',
false,
false, isModEnabled(
'fckeditor'), ROWS_5,
'90%');
1880 $doleditor->Create();
1881 } elseif ($obj->type ==
'yesno') {
1882 print $form->selectyesno(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $obj->value, 1,
false, 0, 1);
1883 } elseif (preg_match(
'/emailtemplate/', $obj->type)) {
1884 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1887 $tmp = explode(
':', $obj->type);
1889 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, -1);
1891 $arrayofmessagename = array();
1892 if (is_array($formmail->lines_model)) {
1893 foreach ($formmail->lines_model as $modelmail) {
1896 if (!empty($arrayofmessagename[$modelmail->label])) {
1897 $moreonlabel =
' <span class="opacitymedium">('.$langs->trans(
"SeveralLangugeVariatFound").
')</span>';
1900 $arrayofmessagename[$modelmail->label.
':'.$tmp[1]] = $langs->trans(preg_replace(
'/\(|\)/',
'', $modelmail->label)).$moreonlabel;
1905 print $form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayofmessagename, $obj->value.
':'.$tmp[1],
'None', 0, 0,
'', 0, 0, 0,
'',
'', 1);
1907 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>';
1908 } elseif (preg_match(
'/MAIL_FROM$/i', $const)) {
1909 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).
'">';
1911 print
'<input type="text" class="flat minwidth300" name="constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1917 if (empty($strictw3c)) {
1918 print
'<td class="center">';
1919 print
'<input type="submit" class="button small reposition" value="'.$langs->trans(
"Update").
'" name="update">';
1925 if (empty($strictw3c)) {
1933 if (!empty($strictw3c) && $strictw3c == 1) {
1934 print
'<div align="center"><input type="submit" class="button small reposition" value="'.$langs->trans(
"Update").
'" name="update"></div>';
1950 $text = $langs->transnoentitiesnoconv(
"OnlyFollowingModulesAreOpenedToExternalUsers");
1954 if (!empty($modules)) {
1956 foreach ($tmpmodules as $module) {
1957 $moduleconst = $module->const_name;
1958 $modulename = strtolower($module->name);
1962 if (!in_array($modulename, $listofmodules)) {
1974 $tmptext = $langs->transnoentitiesnoconv(
'Module'.$module->numero.
'Name');
1975 if ($tmptext !=
'Module'.$module->numero.
'Name') {
1976 $text .= $langs->transnoentitiesnoconv(
'Module'.$module->numero.
'Name');
1978 $text .= $langs->transnoentitiesnoconv($module->name);
2002 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity, libelle, description)";
2003 $sql .=
" VALUES ('".$db->escape($name).
"','".$db->escape($type).
"',".((int)
$conf->entity).
", ";
2004 $sql .= ($label ?
"'".$db->escape($label).
"'" :
'null').
", ";
2005 $sql .= (!empty($description) ?
"'".$db->escape($description).
"'" :
"null");
2008 dol_syslog(
"admin.lib::addDocumentModel", LOG_DEBUG);
2009 $resql = $db->query($sql);
2033 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"document_model";
2034 $sql .=
" WHERE nom = '".$db->escape($name).
"'";
2035 $sql .=
" AND type = '".$db->escape($type).
"'";
2036 $sql .=
" AND entity = ".((int)
$conf->entity);
2038 dol_syslog(
"admin.lib::delDocumentModel", LOG_DEBUG);
2039 $resql = $db->query($sql);
2060 $phpinfostring = ob_get_contents();
2063 $info_arr = array();
2064 $info_lines = explode(
"\n", strip_tags($phpinfostring,
"<tr><td><h2>"));
2066 foreach ($info_lines as $line) {
2069 preg_match(
"~<h2>(.*)</h2>~", $line, $title) ? $cat = $title[1] :
null;
2071 if (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2072 $info_arr[trim($cat)][trim($val[1])] = $val[2];
2073 } elseif (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2074 $info_arr[trim($cat)][trim($val[1])] = array(
"local" => $val[2],
"master" => $val[3]);
2087 global $langs,
$conf;
2092 $head[$h][0] = DOL_URL_ROOT.
"/admin/company.php";
2093 $head[$h][1] = $langs->trans(
"Company");
2094 $head[$h][2] =
'company';
2097 $head[$h][0] = DOL_URL_ROOT.
"/admin/company_socialnetworks.php";
2098 $head[$h][1] = $langs->trans(
"SocialNetworksInformation");
2099 $head[$h][2] =
'socialnetworks';
2102 $head[$h][0] = DOL_URL_ROOT.
"/admin/openinghours.php";
2103 $head[$h][1] = $langs->trans(
"OpeningHours");
2104 $head[$h][2] =
'openinghours';
2107 $head[$h][0] = DOL_URL_ROOT.
"/admin/accountant.php";
2108 $head[$h][1] = $langs->trans(
"Accountant");
2109 $head[$h][2] =
'accountant';
2126 global $langs,
$conf, $user;
2131 if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
2132 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails.php";
2133 $head[$h][1] = $langs->trans(
"OutGoingEmailSetup");
2134 $head[$h][2] =
'common';
2137 if (isModEnabled(
'mailing')) {
2138 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_emailing.php";
2139 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"EMailing"));
2140 $head[$h][2] =
'common_emailing';
2144 if (isModEnabled(
'ticket')) {
2145 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ticket.php";
2146 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"Ticket"));
2147 $head[$h][2] =
'common_ticket';
2151 if (!
getDolGlobalString(
'MAIN_MAIL_HIDE_CUSTOM_SENDING_METHOD_FOR_PASSWORD_RESET')) {
2152 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_passwordreset.php";
2153 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"PasswordReset"));
2154 $head[$h][2] =
'common_passwordreset';
2160 if (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates') {
2161 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_senderprofile_list.php";
2162 $head[$h][1] = $langs->trans(
"EmailSenderProfiles");
2163 $head[$h][2] =
'senderprofiles';
2167 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_templates.php";
2168 $head[$h][1] = $langs->trans(
"EMailTemplates");
2169 $head[$h][2] =
'templates';
2172 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ingoing.php";
2173 $head[$h][1] = $langs->trans(
"InGoingEmailSetup", $langs->transnoentitiesnoconv(
"EMailing"));
2174 $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.
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...
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.