31require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
43 if (isset($versionarray[0])) {
44 $string = $versionarray[0];
46 if (isset($versionarray[1])) {
47 $string .=
'.'.$versionarray[1];
49 if (isset($versionarray[2])) {
50 $string .=
'.'.$versionarray[2];
76 $count1 = count($versionarray1);
77 $count2 = count($versionarray2);
78 $maxcount = max($count1, $count2);
79 while ($level < $maxcount) {
80 $operande1 = isset($versionarray1[$level]) ? $versionarray1[$level] : 0;
81 $operande2 = isset($versionarray2[$level]) ? $versionarray2[$level] : 0;
82 if (preg_match(
'/alpha|dev/i', $operande1)) {
85 if (preg_match(
'/alpha|dev/i', $operande2)) {
88 if (preg_match(
'/beta$/i', $operande1)) {
91 if (preg_match(
'/beta$/i', $operande2)) {
94 if (preg_match(
'/beta([0-9])+/i', $operande1)) {
97 if (preg_match(
'/beta([0-9])+/i', $operande2)) {
100 if (preg_match(
'/rc$/i', $operande1)) {
103 if (preg_match(
'/rc$/i', $operande2)) {
106 if (preg_match(
'/rc([0-9])+/i', $operande1)) {
109 if (preg_match(
'/rc([0-9])+/i', $operande2)) {
114 if ($operande1 < $operande2) {
118 if ($operande1 > $operande2) {
136 return explode(
'.', PHP_VERSION);
147 return preg_split(
'/[\-\.]/', DOL_VERSION);
174function run_sql($sqlfile, $silent = 1, $entity = 0, $usesavepoint = 1, $handler =
'', $okerror =
'default', $linelengthlimit = 32768, $nocommentremoval = 0, $offsetforchartofaccount = 0, $colspan = 0, $onlysqltoimportwebsite = 0, $database =
'')
176 global $db,
$conf, $langs;
178 dol_syslog(
"Admin.lib::run_sql run sql file ".$sqlfile.
" silent=".$silent.
" entity=".$entity.
" usesavepoint=".$usesavepoint.
" handler=".$handler.
" okerror=".$okerror, LOG_DEBUG);
180 if (!is_numeric($linelengthlimit)) {
181 dol_syslog(
"Admin.lib::run_sql param linelengthlimit is not a numeric", LOG_ERR);
192 $versionarray = $db->getVersionArray();
196 $fp = fopen($sqlfile,
"r");
200 if ($linelengthlimit > 0) {
201 $buf = fgets($fp, $linelengthlimit);
208 if (preg_match(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i', $buf, $reg)) {
212 if (!empty($reg[1])) {
213 if (!preg_match(
'/'.preg_quote($reg[1],
'/').
'/i', $db->type)) {
220 if (!empty($reg[2])) {
221 if (is_numeric($reg[2])) {
222 $versionrequest = explode(
'.', $reg[2]);
223 if (!count($versionrequest) || !count($versionarray) ||
versioncompare($versionrequest, $versionarray) > 0) {
227 $dbcollation = strtoupper(preg_replace(
'/_/',
'', (
string)
$conf->db->dolibarr_main_db_collation));
228 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(
'/([,;ERLT05\)])\s+--\s.*$/i',
'\1', $buf);
246 $buf = preg_replace(
'/([,;ERLT05\)])\s+--$/i',
'\1', $buf);
251 $buffer .= trim($buf);
256 if (preg_match(
'/;\s*$/', $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 $keyforsqlfile = 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) ? ((
int) $entity) : (string) ((
int)
$conf->entity)), $sql);
422 print
'<tr class="trforrunsql'.$keyforsqlfile.
'"><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);
490 $errno = $db->errno();
492 print
'<!-- Result = '.$errno.
' -->'.
"\n";
497 'DB_ERROR_TABLE_ALREADY_EXISTS',
498 'DB_ERROR_COLUMN_ALREADY_EXISTS',
499 'DB_ERROR_KEY_NAME_ALREADY_EXISTS',
500 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS',
501 'DB_ERROR_RECORD_ALREADY_EXISTS',
502 'DB_ERROR_NOSUCHTABLE',
503 'DB_ERROR_NOSUCHFIELD',
504 'DB_ERROR_NO_FOREIGN_KEY_TO_DROP',
505 'DB_ERROR_NO_INDEX_TO_DROP',
506 'DB_ERROR_CANNOT_CREATE',
507 'DB_ERROR_CANT_DROP_PRIMARY_KEY',
508 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS',
515 if (preg_match(
'/^\s*ALTER\s+TABLE\s+[^\s]+_categorie_mo\s.*REFERENCES\s+[^\s(]+_mrp_mo\s*\(/i', $newsql)) {
516 $okerrors[] =
'DB_ERROR_CANNOT_ADD_FOREIGN_KEY_CONSTRAINT';
519 if ($okerror ==
'none') {
524 if (!in_array($errno, $okerrors)) {
526 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
527 print
'<div class="error">'.$langs->trans(
"Error").
" ".$db->errno().
" (Req ".($i + 1).
"): ".$newsql.
"<br>".$db->error().
"</div>";
528 print
'</td></tr>'.
"\n";
530 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" Error ".$db->errno().
" ".$newsql.
"<br>".$db->error(), LOG_ERR);
538 print
'<tr><td>'.$langs->trans(
"ProcessMigrateScript").
'</td>';
539 print
'<td class="right">';
541 print
'<span class="ok">'.$langs->trans(
"Success").
'</span>';
543 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
547 print
'<script type="text/javascript">
548 jQuery(document).ready(function() {
549 function init_trrunsql'.$keyforsqlfile.
'()
551 console.log("toggle .trforrunsql'.$keyforsqlfile.
'");
552 jQuery(".trforrunsql'.$keyforsqlfile.
'").toggle();
554 init_trrunsql'.$keyforsqlfile.
'();
555 jQuery(".trforrunsqlshowhide'.$keyforsqlfile.
'").click(function() {
556 init_trrunsql'.$keyforsqlfile.
'();
560 if (count($arraysql)) {
561 print
' - <a class="reposition trforrunsqlshowhide'.$keyforsqlfile.
' reposition" href="#" title="'.($langs->trans(
"ShowHideTheNRequests", count($arraysql))).
'">'.$langs->trans(
"ShowHideDetails").
'</a>';
563 print
' - <span class="opacitymedium">'.$langs->trans(
"ScriptIsEmpty").
'</span>';
567 print
'</td></tr>'.
"\n";
592 global
$conf, $hookmanager;
595 dol_print_error(
null,
'Error call dolibar_del_const with parameter name empty');
598 if (! is_object($hookmanager)) {
599 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
608 $reshook = $hookmanager->executeHooks(
'dolibarrDelConst', $parameters);
613 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
614 $sql .=
" WHERE (".$db->decrypt(
'name').
" = '".$db->escape((
string) $name).
"'";
615 if (is_numeric($name)) {
616 $sql .=
" OR rowid = ".((int) $name);
620 $sql .=
" AND entity = ".((int) $entity);
623 dol_syslog(
"admin.lib::dolibarr_del_const", LOG_DEBUG);
624 $resql = $db->query($sql);
626 $conf->global->$name =
'';
629 dol_print_error($db);
650 $sql =
"SELECT ".$db->sanitize($db->decrypt(
'value')).
" as value";
651 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
652 $sql .=
" WHERE name = '".$db->escape($db->encrypt($name, 0)).
"'";
653 $sql .=
" AND entity = ".((int) $entity);
655 $resql = $db->query($sql);
657 $obj = $db->fetch_object($resql);
659 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
681function dolibarr_set_const($db, $name, $value, $type =
'chaine', $visible = 0, $note =
'', $entity = 1)
683 global
$conf, $hookmanager, $user;
687 $value = (string) $value;
691 dol_print_error($db,
"Error: Call to function dolibarr_set_const with wrong parameters");
694 if (! is_object($hookmanager)) {
695 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
699 $value = (string) $value;
705 'visible' => $visible,
710 $reshook = $hookmanager->executeHooks(
'dolibarrSetConst', $parameters);
717 $userid = (!empty($user) && is_object($user) && $user->id > 0) ? (
int) $user->id : 0;
721 $sql =
"SELECT fk_user_creat FROM ".MAIN_DB_PREFIX.
"const";
722 $sql .=
" WHERE name = ".$db->encrypt($name);
724 $sql .=
" AND entity = ".((int) $entity);
726 $resql = $db->query($sql);
728 $obj = $db->fetch_object($resql);
729 if ($obj && $obj->fk_user_creat > 0) {
730 $fk_user_creat = (int) $obj->fk_user_creat;
733 if (empty($fk_user_creat)) {
734 $fk_user_creat = $userid;
739 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
740 $sql .=
" WHERE name = ".$db->encrypt($name);
742 $sql .=
" AND entity = ".((int) $entity);
745 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
746 $resql = $db->query($sql);
748 if (strcmp($value,
'')) {
749 $tmpname = preg_replace(
'/(_TEST|_PROD)$/',
'', $name);
750 if (!preg_match(
'/^(MAIN_LOGEVENTS|MAIN_AGENDA_ACTIONAUTO)/', $name)
751 && (preg_match(
'/(_KEY|_EXPORTKEY|_SECUREKEY|_SERVERKEY|_PASS|_PASSWORD|_PW|_PW_TICKET|_PW_EMAILING|_SECRET|_TOKEN|_REFRESH)$/', $tmpname))) {
755 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
761 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name, value, type, visible, note, entity, fk_user_creat, fk_user_modif)";
763 $sql .= $db->encrypt($name);
764 $sql .=
", ".$db->encrypt($newvalue);
765 $sql .=
", '".$db->escape($type).
"', ".((int) $visible).
", '".$db->escape($note).
"', ".((int) $entity);
766 $sql .=
", ".($fk_user_creat > 0 ? (int) $fk_user_creat :
"NULL");
767 $sql .=
", ".($userid > 0 ? (int) $userid :
"NULL").
")";
771 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
772 $resql = $db->query($sql);
778 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name, value, type, visible, note, entity)";
780 $sql .= $db->encrypt($name);
781 $sql .=
", ".$db->encrypt($newvalue);
782 $sql .=
", '".$db->escape($type).
"', ".((int) $visible).
", '".$db->escape($note).
"', ".((int) $entity).
")";
784 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
785 $resql = $db->query($sql);
791 $conf->global->$name = $value;
812 global $langs, $form;
814 $desc = $langs->trans(
"ModulesDesc",
'{picto}');
815 $desc = str_replace(
'{picto}', img_picto(
'',
'switch_off'), $desc);
821 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' => $mode]);
822 if ($nbmodulesnotautoenabled <
getDolGlobalInt(
'MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) {
824 $head[$h][1] = $langs->trans(
"AvailableModules");
825 $head[$h][1] .= $form->textwithpicto(
'', $langs->trans(
"YouMustEnableOneModule").
'.<br><br><span class="opacitymedium">'.$desc.
'</span>', 1,
'warning');
828 $head[$h][1] = $langs->trans(
"AvailableModules").
'<span class="badge marginleftonly">'.$nbofactivatedmodules.
' / '.$nboftotalmodules.
'</span>';
830 $head[$h][2] =
'modules';
833 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'marketplace']);
834 $head[$h][1] = $langs->trans(
"ModulesMarketPlaces");
835 $head[$h][2] =
'marketplace';
838 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'deploy']);
839 $head[$h][1] = $langs->trans(
"AddExtensionThemeModuleOrOther");
840 $head[$h][2] =
'deploy';
843 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'develop']);
844 $head[$h][1] = $langs->trans(
"ModulesDevelopYourModule");
845 $head[$h][2] =
'develop';
858 global $langs,
$conf;
862 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'other']);
863 $head[$h][1] = $langs->trans(
"LanguageAndPresentation");
864 $head[$h][2] =
'other';
867 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'template']);
868 $head[$h][1] = $langs->trans(
"SkinAndColors");
869 $head[$h][2] =
'template';
872 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'dashboard']);
873 $head[$h][1] = $langs->trans(
"Dashboard");
874 $head[$h][2] =
'dashboard';
877 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'login']);
878 $head[$h][1] = $langs->trans(
"LoginPage");
879 $head[$h][2] =
'login';
882 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'css']);
883 $head[$h][1] = $langs->trans(
"CSSPage");
884 $head[$h][2] =
'css';
910 global $db, $langs,
$conf;
914 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_other.php");
915 $head[$h][1] = $langs->trans(
"Miscellaneous");
916 $head[$h][2] =
'misc';
919 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_captcha.php");
920 $head[$h][1] = $langs->trans(
"Captcha");
921 $head[$h][2] =
'captcha';
924 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security.php");
925 $head[$h][1] = $langs->trans(
"Passwords");
926 $head[$h][2] =
'passwords';
929 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_file.php");
930 $head[$h][1] = $langs->trans(
"Files").
' ('.$langs->trans(
"UploadName").
' | '.$langs->trans(
"Download").
')';
931 $head[$h][2] =
'file';
941 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/proxy.php");
942 $head[$h][1] = $langs->trans(
"ExternalAccess");
943 $head[$h][2] =
'proxy';
946 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/events.php");
947 $head[$h][1] = $langs->trans(
"Audit");
948 $head[$h][2] =
'audit';
951 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/openid_connect.php");
952 $head[$h][1] = $langs->trans(
"OpenIDconnectSetup");
953 $head[$h][2] =
'openid';
959 $sql =
"SELECT COUNT(r.id) as nb";
960 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r";
961 $sql .=
" WHERE r.libelle NOT LIKE 'tou%'";
962 $sql .=
" AND entity = ".((int)
$conf->entity);
963 $sql .=
" AND bydefault = 1";
965 $sql .=
" AND r.perms NOT LIKE '%_advance'";
967 $resql = $db->query($sql);
969 $obj = $db->fetch_object($resql);
974 dol_print_error($db);
978 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/perms.php");
979 $head[$h][1] = $langs->trans(
"DefaultRights");
981 $head[$h][1] .= (!
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
'<span class="badge marginleftonlyshort">'.$nbPerms.
'</span>' :
'');
983 $head[$h][2] =
'default';
987 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_headers_http.php");
988 $head[$h][1] = $langs->trans(
"MainHttpSecurityHeaders");
989 $head[$h][2] =
'headers_http';
1003 global $langs,
$conf;
1010 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'desc']);
1011 $head[$h][1] = $langs->trans(
"Description");
1012 $head[$h][2] =
'desc';
1015 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'feature']);
1016 $head[$h][1] = $langs->trans(
"TechnicalServicesProvided");
1017 $head[$h][2] =
'feature';
1020 if (
$object->isCoreOrExternalModule() ==
'external') {
1021 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'changelog']);
1022 $head[$h][1] = $langs->trans(
"ChangeLog");
1023 $head[$h][2] =
'changelog';
1041 global $langs,
$conf;
1045 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/translation.php', [
'mode' =>
'searchkey']);
1046 $head[$h][1] = $langs->trans(
"TranslationKeySearch");
1047 $head[$h][2] =
'searchkey';
1050 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/translation.php', [
'mode' =>
'overwrite']);
1051 $head[$h][1] =
'<span class="valignmiddle">'.$langs->trans(
"TranslationOverwriteKey").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
1052 $head[$h][2] =
'overwrite';
1071 global $langs,
$conf;
1075 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=createform";
1076 $head[$h][1] = $langs->trans(
"DefaultCreateForm");
1077 $head[$h][2] =
'createform';
1080 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=filters";
1081 $head[$h][1] = $langs->trans(
"DefaultSearchFilters");
1082 $head[$h][2] =
'filters';
1085 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=sortorder";
1086 $head[$h][1] = $langs->trans(
"DefaultSortOrder");
1087 $head[$h][2] =
'sortorder';
1090 if (!empty(
$conf->use_javascript_ajax)) {
1091 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=focus";
1092 $head[$h][1] = $langs->trans(
"DefaultFocus");
1093 $head[$h][2] =
'focus';
1096 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=mandatory";
1097 $head[$h][1] = $langs->trans(
"DefaultMandatory");
1098 $head[$h][2] =
'mandatory';
1123 global
$conf, $php_session_save_handler;
1125 $arrayofSessions = array();
1127 if (!empty($php_session_save_handler) && $php_session_save_handler ==
'db') {
1128 require_once DOL_DOCUMENT_ROOT.
'/core/lib/phpsessionin'.$php_session_save_handler.
'.lib.php';
1133 $iniPath = ini_get(
"session.save_path");
1135 $sessPath = $iniPath;
1138 dol_syslog(
'admin.lib:listOfSessions sessPath='.$sessPath);
1142 while (($file = @readdir($dh)) !==
false) {
1143 if (preg_match(
'/^sess_/i', $file) && $file !=
"." && $file !=
"..") {
1144 $fullpath = $sessPath.$file;
1145 if (!@is_dir($fullpath) && is_readable($fullpath)) {
1146 $sessValues = file_get_contents($fullpath);
1152 if (preg_match(
'/dol_login/i', $sessValues) &&
1153 (preg_match(
'/dol_entity\|i:'.
$conf->entity.
';/i', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"'.
$conf->entity.
'"/i', $sessValues)) &&
1154 preg_match(
'/dol_company\|s:([0-9]+):"('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1155 $tmp = explode(
'_', $file);
1158 $arrayofSessions[$idsess][
"login"] =
'';
1159 $loginfound = preg_match(
'/dol_login\|s:[0-9]+:"([^"]+)"/i', $sessValues, $regs);
1161 $arrayofSessions[$idsess][
"login"] = (string) $regs[1];
1163 $arrayofSessions[$idsess][
"age"] = time() - filectime($fullpath);
1164 $arrayofSessions[$idsess][
"creation"] = filectime($fullpath);
1165 $arrayofSessions[$idsess][
"modification"] = filemtime($fullpath);
1166 $arrayofSessions[$idsess][
"user_agent"] =
null;
1167 $arrayofSessions[$idsess][
"remote_ip"] =
null;
1168 $arrayofSessions[$idsess][
"raw"] = $sessValues;
1176 return $arrayofSessions;
1189 $sessPath = ini_get(
"session.save_path").
"/";
1190 dol_syslog(
'admin.lib:purgeSessions mysessionid='.$mysessionid.
' sessPath='.$sessPath);
1196 while (($file = @readdir($dh)) !==
false) {
1197 if ($file !=
"." && $file !=
"..") {
1198 $fullpath = $sessPath.$file;
1199 if (!@is_dir($fullpath)) {
1200 $sessValues = file_get_contents($fullpath);
1202 if (preg_match(
'/dol_login/i', $sessValues) &&
1203 (preg_match(
'/dol_entity\|i:('.
$conf->entity.
')/', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"('.
$conf->entity.
')"/i', $sessValues)) &&
1204 preg_match(
'/dol_company\|s:([0-9]+):"(' .
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1205 $tmp = explode(
'_', $file);
1208 if ($idsess != $mysessionid) {
1209 $res = @unlink($fullpath);
1239function activateModule($value, $withdeps = 1, $noconfverification = 0, $options =
'')
1246 if (empty($value)) {
1247 $ret[
'errors'] = array(
'ErrorBadParameter');
1251 $ret = array(
'nbmodules' => 0,
'errors' => array(),
'nbperms' => 0);
1253 $modFile = $modName.
".class.php";
1260 foreach ($modulesdir as $dir) {
1261 if (file_exists($dir.$modFile)) {
1262 $found = @include_once $dir.$modFile;
1269 $objMod =
new $modName($db);
1270 '@phan-var-force DolibarrModules $objMod';
1275 $vermin = isset($objMod->phpmin) ? $objMod->phpmin : 0;
1277 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequirePHPVersion",
versiontostring($vermin));
1283 $vermin = isset($objMod->need_dolibarr_version) ? $objMod->need_dolibarr_version : 0;
1286 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireDolibarrVersion",
versiontostring($vermin));
1291 if (!empty($objMod->need_javascript_ajax) && empty(
$conf->use_javascript_ajax)) {
1292 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireJavascript");
1295 $const_name = $objMod->const_name;
1296 if ($noconfverification == 0) {
1302 $result = $objMod->init($options);
1305 $ret[
'errors'][] = $objMod->error;
1308 if (isset($objMod->depends) && is_array($objMod->depends) && !empty($objMod->depends)) {
1311 foreach ($objMod->depends as $key => $modulestringorarray) {
1313 if ((!is_numeric($key)) && !preg_match(
'/^always/', $key) &&
$mysoc->country_code && !preg_match(
'/^'.
$mysoc->country_code.
'/', $key)) {
1314 dol_syslog(
"We are not concerned by dependency with key=".$key.
" because our country is ".
$mysoc->country_code);
1318 if (!is_array($modulestringorarray)) {
1319 $modulestringorarray = array($modulestringorarray);
1322 foreach ($modulestringorarray as $modulestring) {
1325 $resarray = array();
1326 foreach ($modulesdir as $dir) {
1327 if (file_exists($dir.$modulestring.
".class.php")) {
1328 $resarray = activateModule($modulestring, 1, 0, $options);
1329 if (empty($resarray[
'errors'])) {
1332 $activateerr = implode(
', ', $resarray[
'errors']);
1333 foreach ($resarray[
'errors'] as $errorMessage) {
1342 $ret[
'nbmodules'] += $resarray[
'nbmodules'];
1343 $ret[
'nbperms'] += $resarray[
'nbperms'];
1346 $ret[
'errors'][] = $activateerr;
1348 $ret[
'errors'][] = $langs->trans(
'activateModuleDependNotSatisfied', $objMod->name, $modulestring, $objMod->name).
'<br>'.$langs->trans(
'activateModuleDependNotSatisfied2', $modulestring, $objMod->name);
1354 if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && !empty($objMod->conflictwith)) {
1356 $num = count($objMod->conflictwith);
1357 for ($i = 0; $i < $num; $i++) {
1358 foreach ($modulesdir as $dir) {
1359 if (file_exists($dir.$objMod->conflictwith[$i].
".class.php")) {
1360 unActivateModule($objMod->conflictwith[$i], 0);
1368 if (!count($ret[
'errors'])) {
1369 $ret[
'nbmodules']++;
1370 $ret[
'nbperms'] += (is_array($objMod->rights) ? count($objMod->rights) : 0);
1385function unActivateModule($value, $requiredby = 1, $options =
'')
1389 dol_syslog(
"unActivateModule value=".$value, LOG_INFO);
1392 if (empty($value)) {
1393 return 'ErrorBadParameter';
1398 $modFile = $modName.
".class.php";
1405 foreach ($modulesdir as $dir) {
1406 if (file_exists($dir.$modFile)) {
1407 $found = @include_once $dir.$modFile;
1415 $objMod =
new $modName($db);
1416 '@phan-var-force DolibarrModules $objMod';
1419 $result = $objMod->remove($options);
1421 $ret = $objMod->error;
1426 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
1428 $genericMod->name = preg_replace(
'/^mod/i',
'', $modName);
1429 $genericMod->rights_class = strtolower(preg_replace(
'/^mod/i',
'', $modName));
1430 $genericMod->const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', $modName));
1431 dol_syslog(
"modules::unActivateModule Failed to find module file, we use generic function with name ".$modName);
1432 $genericMod->remove(
'');
1436 if (!$ret && $requiredby && isset($objMod) && is_object($objMod) && is_array($objMod->requiredby)) {
1437 $countrb = count($objMod->requiredby);
1438 for ($i = 0; $i < $countrb; $i++) {
1440 unActivateModule($objMod->requiredby[$i], $requiredby, $options);
1466function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
1470 dol_syslog(
"complete_dictionary_with_modules Search external modules to complete the list of dictionary tables", LOG_DEBUG, 1);
1477 foreach ($modulesdir as $dir) {
1480 dol_syslog(
"Scan directory ".$dir.
" for modules");
1482 if (is_resource($handle)) {
1483 while (($file = readdir($handle)) !==
false) {
1489 if ($modName ===
'modFournisseur' &&
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1490 dol_syslog(
"Module modFournisseur skipped because MAIN_USE_NEW_SUPPLIERMOD is enabled", LOG_DEBUG);
1493 if (in_array($modName, [
'modSupplierInvoice',
'modSupplierOrder']) && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1494 dol_syslog(
"Module ".$modName.
" skipped because MAIN_USE_NEW_SUPPLIERMOD is disabled", LOG_DEBUG);
1498 include_once $dir.$file;
1499 $objMod =
new $modName($db);
1500 '@phan-var-force DolibarrModules $objMod';
1503 if ($objMod->numero > 0) {
1504 $j = $objMod->numero;
1509 $modulequalified = 1;
1512 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1514 $modulequalified = 0;
1517 $modulequalified = 0;
1521 $modulequalified = 0;
1524 if ($modulequalified) {
1526 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1527 foreach ($objMod->langfiles as $langfile) {
1528 $langs->load($langfile);
1535 if (empty($objMod->dictionaries) && !empty($objMod->{
"dictionnaries"})) {
1537 $objMod->dictionaries = $objMod->{
"dictionnaries"};
1541 if (!empty($objMod->dictionaries)) {
1543 $nbtabname = $nbtablib = $nbtabsqlsort = $nbtabfield = $nbtabfieldvalue = $nbtabfieldinsert = $nbtabrowid = $nbtabcond = $nbtabfieldcheck = $nbtabhelp = $nbtabsql = 0;
1544 $tabnamerelwithkey = array();
1545 foreach ($objMod->dictionaries[
'tabname'] as $key => $val) {
1546 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $val);
1548 $taborder[] = max($taborder) + 1;
1550 $tabnamerelwithkey[$key] = $val;
1551 $tabcomplete[$tmptablename][
'picto'] = $objMod->picto;
1553 foreach ($objMod->dictionaries[
'tablib'] as $key => $val) {
1554 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1557 $tabcomplete[$tmptablename][
'lib'] = $val;
1559 foreach ($objMod->dictionaries[
'tabsql'] as $key => $val) {
1560 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1563 $tabcomplete[$tmptablename][
'sql'] = $val;
1565 foreach ($objMod->dictionaries[
'tabsqlsort'] as $key => $val) {
1566 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1568 $tabsqlsort[] = $val;
1569 $tabcomplete[$tmptablename][
'sqlsort'] = $val;
1571 foreach ($objMod->dictionaries[
'tabfield'] as $key => $val) {
1572 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1575 $tabcomplete[$tmptablename][
'field'] = $val;
1577 foreach ($objMod->dictionaries[
'tabfieldvalue'] as $key => $val) {
1578 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1580 $tabfieldvalue[] = $val;
1581 $tabcomplete[$tmptablename][
'value'] = $val;
1583 foreach ($objMod->dictionaries[
'tabfieldinsert'] as $key => $val) {
1584 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1585 $nbtabfieldinsert++;
1586 $tabfieldinsert[] = $val;
1587 $tabcomplete[$tmptablename][
'fieldinsert'] = $val;
1589 foreach ($objMod->dictionaries[
'tabrowid'] as $key => $val) {
1590 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1592 $tabrowid[] = (int) $val;
1593 $tabcomplete[$tmptablename][
'rowid'] = (int) $val;
1595 foreach ($objMod->dictionaries[
'tabcond'] as $key => $val) {
1596 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1599 $tabcomplete[$tmptablename][
'cond'] = $val;
1601 if (!empty($objMod->dictionaries[
'tabhelp'])) {
1602 foreach ($objMod->dictionaries[
'tabhelp'] as $key => $val) {
1603 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1606 $tabcomplete[$tmptablename][
'help'] = $val;
1609 if (!empty($objMod->dictionaries[
'tabfieldcheck'])) {
1610 foreach ($objMod->dictionaries[
'tabfieldcheck'] as $key => $val) {
1611 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1613 $tabcomplete[$tmptablename][
'fieldcheck'] = $val;
1617 if ($nbtabname != $nbtablib || $nbtablib != $nbtabsql || $nbtabsql != $nbtabsqlsort) {
1618 print
'Error in descriptor of module '.$const_name.
'. Array ->dictionaries has not same number of record for key "tabname", "tablib", "tabsql" and "tabsqlsort"';
1628 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1635 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1650function activateModulesRequiredByCountry($country_code)
1656 foreach ($modulesdir as $dir) {
1658 dol_syslog(
"Scan directory ".$dir.
" for modules");
1660 if (is_resource($handle)) {
1661 while (($file = readdir($handle)) !==
false) {
1666 if ($modName ===
'modFournisseur' &&
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1667 dol_syslog(
"Module modFournisseur skipped because MAIN_USE_NEW_SUPPLIERMOD is enabled", LOG_DEBUG);
1670 if (in_array($modName, [
'modSupplierInvoice',
'modSupplierOrder']) && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1671 dol_syslog(
"Module ".$modName.
" skipped because MAIN_USE_NEW_SUPPLIERMOD is disabled", LOG_DEBUG);
1675 include_once $dir.$file;
1676 $objMod =
new $modName($db);
1677 '@phan-var-force DolibarrModules $objMod';
1680 $modulequalified = 1;
1683 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1685 if ($objMod->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
1686 $modulequalified = 0;
1688 if ($objMod->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
1689 $modulequalified = 0;
1692 $modulequalified = 0;
1695 if ($modulequalified) {
1697 if (isset($objMod->automatic_activation[$country_code])) {
1698 activateModule($modName, 1, 0);
1700 setEventMessages($objMod->automatic_activation[$country_code],
null,
'warnings');
1703 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1710 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1723function complete_elementList_with_modules(&$elementList)
1725 global $db, $modules,
$conf, $langs;
1728 $filename = array();
1737 dol_syslog(
"complete_elementList_with_modules Search external modules to complete the list of contact element", LOG_DEBUG, 1);
1741 foreach ($modulesdir as $dir) {
1744 dol_syslog(
"Scan directory ".$dir.
" for modules");
1746 if (is_resource($handle)) {
1747 while (($file = readdir($handle)) !==
false) {
1753 include_once $dir.$file;
1754 $objMod =
new $modName($db);
1757 if ($objMod->numero > 0) {
1758 $j = $objMod->numero;
1763 $modulequalified = 1;
1766 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1768 $modulequalified = 0;
1771 $modulequalified = 0;
1775 $modulequalified = 0;
1778 if ($modulequalified) {
1780 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1781 foreach ($objMod->langfiles as $langfile) {
1782 $langs->load($langfile);
1786 $modules[$i] = $objMod;
1787 $filename[$i] = $modName;
1788 $orders[$i] = $objMod->family.
"_".$j;
1792 if (!empty($objMod->module_parts[
'contactelement'])) {
1793 if (is_array($objMod->module_parts[
'contactelement'])) {
1794 foreach ($objMod->module_parts[
'contactelement'] as $elem => $title) {
1795 $elementList[$elem] = $langs->trans($title);
1798 $elementList[$objMod->name] = $langs->trans($objMod->name);
1805 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1812 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1833 global $db, $langs,
$conf, $user;
1834 global $_Avery_Labels;
1836 $form =
new Form($db);
1838 print
'<div class="div-table-responsive-no-min">';
1839 print
'<table class="noborder centpercent">';
1840 print
'<tr class="liste_titre">';
1841 print
'<td class="">'.$langs->trans(
"Description").
'</td>';
1844 $text = $langs->trans($text);
1845 print $form->textwithpicto($text, $helptext, 1,
'help',
'', 0, 2,
'idhelptext');
1850 foreach ($tableau as $key => $const) {
1853 if (is_array($const)) {
1854 $type = $const[
'type'];
1855 $label = $const[
'label'];
1864 $sql .=
", ".$db->decrypt(
'name').
" as name";
1865 $sql .=
", ".$db->decrypt(
'value').
" as value";
1868 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1869 $sql .=
" WHERE ".$db->decrypt(
'name').
" = '".$db->escape($const).
"'";
1870 $sql .=
" AND entity IN (0, ".((int)
$conf->entity).
")";
1871 $sql .=
" ORDER BY name ASC, entity DESC";
1872 $result = $db->query($sql);
1877 $obj = $db->fetch_object($result);
1880 $obj = (object) array(
'rowid' =>
'',
'name' => $const,
'value' =>
'',
'type' => $type,
'note' =>
'');
1883 print
'<tr class="oddeven">';
1887 print
'<input type="hidden" name="rowid[]" value="'.$obj->rowid.
'">';
1888 print
'<input type="hidden" name="constname[]" value="'.$const.
'">';
1889 print
'<input type="hidden" name="constnote_'.$obj->name.
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1890 print
'<input type="hidden" name="consttype_'.$obj->name.
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1893 $tmparray = explode(
':', $obj->type);
1894 if (!empty($tmparray[1])) {
1895 $picto = preg_replace(
'/_send$/',
'', $tmparray[1]);
1897 print img_picto(
'', $picto,
'class="pictofixedwidth"');
1899 if (!empty($tableau[$key][
'tooltip'])) {
1900 print $form->textwithpicto($label ? $label : $langs->trans(
'Desc'.$const), $tableau[$key][
'tooltip']);
1902 print($label ? $label : $langs->trans(
'Desc'.$const));
1905 if ($const ==
'ADHERENT_MAILMAN_URL') {
1906 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick1">'.
img_down().
'</a><br>';
1908 print
'<div id="example1" class="hidden">';
1909 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';
1911 } elseif ($const ==
'ADHERENT_MAILMAN_UNSUB_URL') {
1912 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick2">'.
img_down().
'</a><br>';
1913 print
'<div id="example2" class="hidden">';
1914 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';
1917 } elseif ($const ==
'ADHERENT_MAILMAN_LISTS') {
1918 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick3">'.
img_down().
'</a><br>';
1919 print
'<div id="example3" class="hidden">';
1920 print
'mymailmanlist<br>';
1921 print
'mymailmanlist1,mymailmanlist2<br>';
1922 print
'TYPE:Type1:mymailmanlist1,TYPE:Type2:mymailmanlist2<br>';
1924 print
'CATEG:Categ1:mymailmanlist1,CATEG:Categ2:mymailmanlist2<br>';
1928 } elseif (in_array($const, [
'ADHERENT_MAIL_FROM',
'ADHERENT_CC_MAIL_FROM'])) {
1929 print
' '.img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
1935 if ($const ==
'ADHERENT_CARD_TYPE' || $const ==
'ADHERENT_ETIQUETTE_TYPE') {
1938 require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
1939 $arrayoflabels = array();
1940 foreach (array_keys($_Avery_Labels) as $codecards) {
1941 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
1943 print $form->selectarray(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $arrayoflabels, ($obj->value ? $obj->value :
'CARD'), 1, 0, 0);
1944 print
'<input type="hidden" name="consttype" value="yesno">';
1945 print
'<input type="hidden" name="constnote[]" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1949 print
'<input type="hidden" name="consttype'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1950 print
'<input type="hidden" name="constnote'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1951 if ($obj->type ==
'textarea' || in_array($const, array(
'ADHERENT_CARD_TEXT',
'ADHERENT_CARD_TEXT_RIGHT',
'ADHERENT_ETIQUETTE_TEXT'))) {
1952 print
'<textarea class="flat" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" cols="50" rows="5" wrap="soft">'.
"\n";
1954 print
"</textarea>\n";
1955 } elseif ($obj->type ==
'html') {
1956 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1957 $doleditor =
new DolEditor(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $obj->value,
'', 160,
'dolibarr_notes',
'',
false,
false,
isModEnabled(
'fckeditor'), ROWS_5,
'90%');
1958 $doleditor->Create();
1959 } elseif ($obj->type ==
'yesno') {
1960 print $form->selectyesno(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $obj->value, 1,
false, 0, 1);
1961 } elseif (preg_match(
'/emailtemplate/', $obj->type)) {
1962 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1965 $tmp = explode(
':', $obj->type);
1967 $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, -1);
1969 $arrayofmessagename = array();
1970 if (is_array($formmail->lines_model)) {
1971 foreach ($formmail->lines_model as $modelmail) {
1973 if (!empty($arrayofmessagename[$modelmail->label])) {
1974 $moreonlabel =
' <span class="opacitymedium">('.$langs->trans(
"SeveralLangugeVariatFound").
')</span>';
1977 $arrayofmessagename[$modelmail->label.
':'.$tmp[1]] = $langs->trans(preg_replace(
'/\(|\)/',
'', $modelmail->label)).$moreonlabel;
1981 print $form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayofmessagename, $obj->value.
':'.$tmp[1],
'None', 0, 0,
'', 0, 0, 0,
'',
'', 1);
1983 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/admin/mails_templates.php', [
'action' =>
'create',
'type_template' => $tmp[1],
'backtopage' =>
dolBuildUrl($_SERVER[
"PHP_SELF"])]).
'">'.img_picto(
'',
'add').
'</a>';
1984 } elseif (preg_match(
'/MAIL_FROM$/i', $const)) {
1985 print img_picto(
'',
'email',
'class="pictofixedwidth"').
'<input type="text" class="flat minwidth300" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1987 print
'<input type="text" class="flat minwidth300" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.
dol_escape_htmltag($obj->value).
'">';
2010 $text = $langs->transnoentitiesnoconv(
"OnlyFollowingModulesAreOpenedToExternalUsers");
2014 if (!empty($modules)) {
2016 foreach ($tmpmodules as
$module) {
2017 $moduleconst =
$module->const_name;
2018 $modulename = strtolower(
$module->name);
2022 if (!in_array($modulename, $listofmodules)) {
2034 $tmptext = $langs->transnoentitiesnoconv(
'Module'.
$module->numero.
'Name');
2035 if ($tmptext !=
'Module'.
$module->numero.
'Name') {
2036 $text .= $langs->transnoentitiesnoconv(
'Module'.
$module->numero.
'Name');
2038 $text .= $langs->transnoentitiesnoconv(
$module->name);
2062 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity, libelle, description)";
2063 $sql .=
" VALUES ('".$db->escape($name).
"','".$db->escape($type).
"',".((int)
$conf->entity).
", ";
2064 $sql .= ($label ?
"'".$db->escape($label).
"'" :
'null').
", ";
2065 $sql .= (!empty($description) ?
"'".$db->escape($description).
"'" :
"null");
2068 dol_syslog(
"admin.lib::addDocumentModel", LOG_DEBUG);
2069 $resql = $db->query($sql);
2074 dol_print_error($db);
2093 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"document_model";
2094 $sql .=
" WHERE nom = '".$db->escape($name).
"'";
2095 $sql .=
" AND type = '".$db->escape($type).
"'";
2096 $sql .=
" AND entity = ".((int)
$conf->entity);
2098 dol_syslog(
"admin.lib::delDocumentModel", LOG_DEBUG);
2099 $resql = $db->query($sql);
2104 dol_print_error($db);
2128function printDocumentModelList($type, $moduledir, $constpdf, $title, array $features, $excludedisabled =
false, $constpdfdefault =
'', $usedefault = 1, $actionunset =
'')
2130 global $db, $langs,
$conf;
2132 $form =
new Form($db);
2133 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
2138 $sql =
"SELECT nom";
2139 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
2140 $sql .=
" WHERE type = '".$db->escape($type).
"'";
2141 $sql .=
" AND entity = ".((int)
$conf->entity);
2142 $resql = $db->query($sql);
2145 $num_rows = $db->num_rows($resql);
2146 while ($i < $num_rows) {
2147 $array = $db->fetch_array($resql);
2148 if (is_array($array)) {
2149 array_push($def, $array[0]);
2154 dol_print_error($db);
2157 print
'<div class="div-table-responsive-no-min">';
2158 print
'<table class="noborder centpercent">';
2159 print
'<tr class="liste_titre">';
2160 print
'<td>'.$langs->trans(
"Name").
'</td>';
2161 print
'<td>'.$langs->trans(
"Description").
'</td>';
2162 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
2164 print
'<td class="center" width="60">'.$langs->trans(
"Default").
'</td>';
2166 print
'<td class="center" width="60">'.$langs->trans(
"ShortInfo").
'</td>';
2167 print
'<td class="center" width="60">'.$langs->trans(
"Preview").
'</td>';
2172 foreach ($dirmodels as $reldir) {
2173 foreach (array(
'',
'/doc') as $valdir) {
2174 $realpath = $reldir.
"core/modules/".$moduledir.$valdir;
2178 $handle = opendir($dir);
2179 if (is_resource($handle)) {
2180 $filelist = array();
2181 while (($file = readdir($handle)) !==
false) {
2182 $filelist[] = $file;
2187 foreach ($filelist as $file) {
2188 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
2189 if (file_exists($dir.
'/'.$file)) {
2193 require_once $dir.
'/'.$file;
2194 $module =
new $classname($db);
2196 '@phan-var-force CommonDocGenerator $module';
2199 $modulequalified = 1;
2201 $modulequalified = 0;
2204 $modulequalified = 0;
2206 if ($excludedisabled &&
$module->version ==
'disabled') {
2207 $modulequalified = 0;
2210 if ($modulequalified) {
2211 print
'<tr class="oddeven"><td>';
2213 print
"</td><td>\n";
2214 if (method_exists(
$module,
'info')) {
2222 if (in_array($name, $def)) {
2223 print
'<td class="center">'.
"\n";
2224 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.
$module->scandir.
'&label='.urlencode(
$module->name).
'">';
2225 print img_picto($langs->trans(
"Enabled"),
'switch_on');
2230 print
'<td class="center">'.
"\n";
2231 print img_picto(
dol_escape_htmltag($langs->trans(
"ErrorModuleRequirePHPVersion", implode(
'.',
$module->phpmin))),
'switch_off',
'class="opacitymedium"');
2234 print
'<td class="center">'.
"\n";
2235 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode(
$module->scandir).
'&label='.urlencode(
$module->name).
'">'.img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
2242 print
'<td class="center">';
2245 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action='.$actionunset.
'&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode(
$module->scandir).
'&label='.urlencode(
$module->name).
'" alt="'.$langs->trans(
"Disable").
'">'.img_picto($langs->trans(
"Default"),
'on').
'</a>';
2247 print img_picto($langs->trans(
"Default"),
'on');
2250 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode(
$module->scandir).
'&label='.urlencode(
$module->name).
'" alt="'.$langs->trans(
"Default").
'">'.img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
2256 $htmltooltip =
''.$langs->trans(
"Name").
': '.
$module->name;
2257 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.(
$module->type ?
$module->type : $langs->trans(
"Unknown"));
2259 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.
$module->page_largeur.
'/'.
$module->page_hauteur;
2261 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
2263 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
2264 foreach ($features as $key => $property) {
2265 $htmltooltip .=
'<br>'.$langs->trans($key).
': '.yn(
$module->$property, 1, 1);
2268 print
'<td class="center">';
2269 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
2273 print
'<td class="center">';
2275 print
'<a href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], array(
'action' =>
'specimen',
'module' => $name),
true).
'">'.img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
2277 print img_object($langs->transnoentitiesnoconv(
"PreviewNotAvailable"),
'generic');
2310function printNumberingModuleList($moduledir, $prefix, $constname, $title, $specimenobject, $actionname =
'setmod')
2314 $form =
new Form($db);
2315 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
2319 print
'<div class="div-table-responsive-no-min">';
2320 print
'<table class="noborder centpercent">';
2321 print
'<tr class="liste_titre">';
2322 print
'<td>'.$langs->trans(
"Name").
'</td>';
2323 print
'<td>'.$langs->trans(
"Description").
'</td>';
2324 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
2325 print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
2326 print
'<td class="center" width="60">'.$langs->trans(
"ShortInfo").
'</td>';
2331 $arrayofmodules = array();
2333 foreach ($dirmodels as $reldir) {
2337 $handle = opendir($dir);
2338 if (is_resource($handle)) {
2339 while (($file = readdir($handle)) !==
false) {
2343 require_once $dir.
'/'.$file.
'.php';
2346 '@phan-var-force CommonNumRefGenerator $module';
2359 '@phan-var-force CommonNumRefGenerator[] $arrayofmodules';
2361 foreach ($arrayofmodules as
$module) {
2373 print
'<tr class="oddeven"><td>'.$module->getName($langs).
"</td>\n";
2379 print
'<td class="nowrap">';
2381 if (preg_match(
'/^Error/', $tmp)) {
2382 $langs->load(
"errors");
2383 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
2384 } elseif ($tmp ==
'NotConfigured') {
2385 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
2391 print
'<td class="center">';
2393 print img_picto($langs->trans(
"Activated"),
'switch_on');
2395 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action='.$actionname.
'&token='.
newToken().
'&value='.urlencode($file).
'">';
2396 print img_picto($langs->trans(
"Disabled"),
'switch_off');
2403 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.
$module->getVersion().
'</b><br>';
2405 if ((
string) $nextval != $langs->trans(
"NotAvailable")) {
2406 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
2408 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
2409 $nextval = $langs->trans($nextval);
2411 $htmltooltip .= $nextval.
'<br>';
2413 $htmltooltip .= $langs->trans(
$module->error).
'<br>';
2417 print
'<td class="center">';
2418 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
2439 $phpinfostring = ob_get_contents();
2442 $info_arr = array();
2443 $info_lines = explode(
"\n", strip_tags($phpinfostring,
"<tr><td><h2>"));
2445 foreach ($info_lines as $line) {
2448 preg_match(
"~<h2>(.*)</h2>~", $line, $title) ? $cat = $title[1] :
null;
2450 if (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2451 $info_arr[trim($cat)][trim($val[1])] = $val[2];
2452 } elseif (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2453 $info_arr[trim($cat)][trim($val[1])] = array(
"local" => $val[2],
"master" => $val[3]);
2466 global $langs,
$conf;
2471 $head[$h][0] = DOL_URL_ROOT.
"/admin/company.php";
2472 $head[$h][1] = $langs->trans(
"MyOrganization");
2473 $head[$h][2] =
'company';
2476 $head[$h][0] = DOL_URL_ROOT.
"/admin/company_socialnetworks.php";
2477 $head[$h][1] = $langs->trans(
"SocialNetworksInformation");
2478 $head[$h][2] =
'socialnetworks';
2481 $head[$h][0] = DOL_URL_ROOT.
"/admin/openinghours.php";
2482 $head[$h][1] = $langs->trans(
"OpeningHours");
2483 $head[$h][2] =
'openinghours';
2486 $head[$h][0] = DOL_URL_ROOT.
"/admin/subcontractors.php";
2487 $head[$h][1] = $langs->trans(
"Subcontractors");
2488 $head[$h][2] =
'subcontractors';
2505 global $langs,
$conf, $user;
2510 if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
2511 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails.php";
2512 $head[$h][1] = $langs->trans(
"OutGoingEmailSetup");
2513 $head[$h][2] =
'common';
2517 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_emailing.php";
2518 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"EMailing"));
2519 $head[$h][2] =
'common_emailing';
2524 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ticket.php";
2525 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"Ticket"));
2526 $head[$h][2] =
'common_ticket';
2530 if (!
getDolGlobalString(
'MAIN_MAIL_HIDE_CUSTOM_SENDING_METHOD_FOR_PASSWORD_RESET')) {
2531 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_passwordreset.php";
2532 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"PasswordReset"));
2533 $head[$h][2] =
'common_passwordreset';
2539 if (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates') {
2540 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_senderprofile_list.php";
2541 $head[$h][1] = $langs->trans(
"EmailSenderProfiles");
2542 $head[$h][2] =
'senderprofiles';
2546 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_templates.php";
2547 $head[$h][1] = $langs->trans(
"EMailTemplates");
2548 $head[$h][2] =
'templates';
2551 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ingoing.php";
2552 $head[$h][1] = $langs->trans(
"InGoingEmailSetup", $langs->transnoentitiesnoconv(
"EMailing"));
2553 $head[$h][2] =
'common_ingoing';
2570 "child-src" => array(
"label" =>
"child-src",
"data-directivetype" =>
"fetch"),
2571 "connect-src" => array(
"label" =>
"connect-src",
"data-directivetype" =>
"fetch"),
2572 "default-src" => array(
"label" =>
"default-src",
"data-directivetype" =>
"fetch"),
2573 "fenced-frame-src" => array(
"label" =>
"fenced-frame-src",
"data-directivetype" =>
"fetch"),
2574 "font-src" => array(
"label" =>
"font-src",
"data-directivetype" =>
"fetch"),
2575 "frame-src" => array(
"label" =>
"frame-src",
"data-directivetype" =>
"fetch"),
2576 "img-src" => array(
"label" =>
"img-src",
"data-directivetype" =>
"fetch"),
2577 "manifest-src" => array(
"label" =>
"manifest-src",
"data-directivetype" =>
"fetch"),
2578 "media-src" => array(
"label" =>
"media-src",
"data-directivetype" =>
"fetch"),
2579 "object-src" => array(
"label" =>
"object-src",
"data-directivetype" =>
"fetch"),
2580 "prefetch-src" => array(
"label" =>
"prefetch-src",
"data-directivetype" =>
"fetch"),
2581 "script-src" => array(
"label" =>
"script-src",
"data-directivetype" =>
"fetch"),
2582 "script-src-elem" => array(
"label" =>
"script-src-elem",
"data-directivetype" =>
"fetch"),
2583 "script-src-attr" => array(
"label" =>
"script-src-attr",
"data-directivetype" =>
"fetch"),
2584 "style-src" => array(
"label" =>
"style-src",
"data-directivetype" =>
"fetch"),
2585 "style-src-elem" => array(
"label" =>
"style-src-elem",
"data-directivetype" =>
"fetch"),
2586 "style-src-attr" => array(
"label" =>
"style-src-attr",
"data-directivetype" =>
"fetch"),
2587 "worker-src" => array(
"label" =>
"worker-src",
"data-directivetype" =>
"fetch"),
2589 "base-uri" => array(
"label" =>
"base-uri",
"data-directivetype" =>
"document"),
2590 "sandbox" => array(
"label" =>
"sandbox",
"data-directivetype" =>
"document"),
2592 "form-action" => array(
"label" =>
"form-action",
"data-directivetype" =>
"navigation"),
2593 "frame-ancestors" => array(
"label" =>
"frame-ancestors",
"data-directivetype" =>
"navigation"),
2595 "report-to" => array(
"label" =>
"report-to",
"data-directivetype" =>
"reporting"),
2597 "require-trusted-types-for" => array(
"label" =>
"require-trusted-types-for",
"data-directivetype" =>
"require-trusted-types-for"),
2598 "trusted-types" => array(
"label" =>
"trusted-types",
"data-directivetype" =>
"trusted-types"),
2599 "upgrade-insecure-requests" => array(
"label" =>
"upgrade-insecure-requests",
"data-directivetype" =>
"none"),
2613 "*" => array(
"label" =>
"*",
"data-sourcetype" =>
"select"),
2614 "blob" => array(
"label" =>
"blob:",
"data-sourcetype" =>
"blob"),
2615 "data" => array(
"label" =>
"data:",
"data-sourcetype" =>
"data"),
2616 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2617 "unsafe-eval" => array(
"label" =>
"unsafe-eval",
"data-sourcetype" =>
"quoted"),
2618 "wasm-unsafe-eval" => array(
"label" =>
"wasm-unsafe-eval",
"data-sourcetype" =>
"quoted"),
2619 "unsafe-inline" => array(
"label" =>
"unsafe-inline",
"data-sourcetype" =>
"quoted"),
2620 "unsafe-hashes" => array(
"label" =>
"unsafe-hashes",
"data-sourcetype" =>
"quoted"),
2621 "inline-speculation-rules" => array(
"label" =>
"inline-speculation-rules",
"data-sourcetype" =>
"quoted"),
2622 "strict-dynamic" => array(
"label" =>
"strict-dynamic",
"data-sourcetype" =>
"quoted"),
2623 "report-sample" => array(
"label" =>
"report-sample",
"data-sourcetype" =>
"quoted"),
2624 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2625 "scheme-source" => array(
"label" =>
"scheme-source",
"data-sourcetype" =>
"input"),
2628 "document" => array(
2629 "none" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2630 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2631 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2632 "scheme-source" => array(
"label" =>
"scheme-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2635 "navigation" => array(
2636 "none" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2637 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2638 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2639 "scheme-source" => array(
"label" =>
"scheme-source",
"data-sourcetype" =>
"input"),
2642 "reporting" => array(
2643 "report-to" => array(
"label" =>
"report-to",
"data-sourcetype" =>
"input"),
2646 "require-trusted-types-for" => array(
2647 "script" => array(
"label" =>
"script",
"data-sourcetype" =>
"select"),
2649 "trusted-types" => array(
2650 "policyName" => array(
"label" =>
"policyName",
"data-sourcetype" =>
"input"),
2651 "none" => array(
"label" =>
"none",
"data-sourcetype" =>
"quoted"),
2652 "allow-duplicates" => array(
"label" =>
"allow-duplicates",
"data-sourcetype" =>
"quoted"),
2665 $forceCSPArr = array();
2667 $sourceCSPArrflatten = array();
2670 foreach ($sourceCSPArr as $key => $arr) {
2671 $sourceCSPArrflatten = array_merge($sourceCSPArrflatten, array_keys($arr));
2674 $forceCSP = preg_replace(
'/;base64,/',
"__semicolumnbase64__", $forceCSP);
2675 $securitypolicies = explode(
";", $forceCSP);
2678 foreach ($securitypolicies as $key => $securitypolicy) {
2679 if ($securitypolicy ==
"") {
2682 $securitypolicy = preg_replace(
'/__semicolumnbase64__/',
";base64,", $securitypolicy);
2683 $securitypolicyarr = explode(
" ", $securitypolicy);
2684 $directive = array_shift($securitypolicyarr);
2686 while ($directive ==
"") {
2687 $directive = array_shift($securitypolicyarr);
2689 if (empty($directive)) {
2692 $sources = $securitypolicyarr;
2693 if (empty($sources)) {
2694 $forceCSPArr[$directive] = array();
2697 foreach ($sources as $key2 => $source) {
2698 $source = str_replace(
"'",
"", $source);
2699 if (empty($source)) {
2702 if (empty($forceCSPArr[$directive])) {
2703 $forceCSPArr[$directive] = array($source);
2705 $forceCSPArr[$directive][] = $source;
2710 return $forceCSPArr;
if(! $sortfield) if(! $sortorder) $object
versiontostring($versionarray)
Return a version in a string from a version into an array.
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.
form_constantes($tableau, $strictw3c=2, $helptext='', $text='')
Show array with constants to edit.
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.
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
versiondolibarrarray()
Return version Dolibarr.
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.
GetContentPolicySources()
Prepare array of sources for HTTP headers.
GetContentPolicyToArray($forceCSP)
Transform a Content Security Policy to an array.
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.
GetContentPolicyDirectives()
Prepare array of directives for HTTP headers.
Class to manage a WYSIWYG editor.
if(! $sortfield) if(! $sortorder) $module
dolKeepOnlyPhpCode($str)
Keep only PHP code part from a HTML string page.
dolGetModulesDirs($subdir='')
Return list of directories that contain modules.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
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...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
dolListSessions()
List sessions in db.
$conf db name
Only used if Module[ID]Name translation string is not found.
dolDecrypt($chain, $key='', $patterntotest='')
Decode a string with a symmetric encryption.
dolEncrypt($chain, $key='', $ciphering='', $forceseed='', $obfuscationmode='dolcrypt')
Encode a string with a symmetric encryption.
checkPHPCode(&$phpfullcodestringold, &$phpfullcodestring)
Check that the new string $phpfullcodestring contains only php code (including <php tag)