27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
39 if (isset($versionarray[0])) {
40 $string = $versionarray[0];
42 if (isset($versionarray[1])) {
43 $string .=
'.'.$versionarray[1];
45 if (isset($versionarray[2])) {
46 $string .=
'.'.$versionarray[2];
70 $count1 = count($versionarray1);
71 $count2 = count($versionarray2);
72 $maxcount = max($count1, $count2);
73 while ($level < $maxcount) {
74 $operande1 = isset($versionarray1[$level]) ? $versionarray1[$level] : 0;
75 $operande2 = isset($versionarray2[$level]) ? $versionarray2[$level] : 0;
76 if (preg_match(
'/alpha|dev/i', $operande1)) {
79 if (preg_match(
'/alpha|dev/i', $operande2)) {
82 if (preg_match(
'/beta$/i', $operande1)) {
85 if (preg_match(
'/beta$/i', $operande2)) {
88 if (preg_match(
'/beta([0-9])+/i', $operande1)) {
91 if (preg_match(
'/beta([0-9])+/i', $operande2)) {
94 if (preg_match(
'/rc$/i', $operande1)) {
97 if (preg_match(
'/rc$/i', $operande2)) {
100 if (preg_match(
'/rc([0-9])+/i', $operande1)) {
103 if (preg_match(
'/rc([0-9])+/i', $operande2)) {
108 if ($operande1 < $operande2) {
112 if ($operande1 > $operande2) {
130 return explode(
'.', PHP_VERSION);
141 return explode(
'.', DOL_VERSION);
167 function run_sql($sqlfile, $silent = 1, $entity =
'', $usesavepoint = 1, $handler =
'', $okerror =
'default', $linelengthlimit = 32768, $nocommentremoval = 0, $offsetforchartofaccount = 0, $colspan = 0, $onlysqltoimportwebsite = 0)
169 global $db, $conf, $langs, $user;
171 dol_syslog(
"Admin.lib::run_sql run sql file ".$sqlfile.
" silent=".$silent.
" entity=".$entity.
" usesavepoint=".$usesavepoint.
" handler=".$handler.
" okerror=".$okerror, LOG_DEBUG);
173 if (!is_numeric($linelengthlimit)) {
174 dol_syslog(
"Admin.lib::run_sql param linelengthlimit is not a numeric", LOG_ERR);
185 $versionarray = $db->getVersionArray();
187 $fp = fopen($sqlfile,
"r");
191 if ($linelengthlimit > 0) {
192 $buf = fgets($fp, $linelengthlimit);
199 if (preg_match(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i', $buf, $reg)) {
203 if (!empty($reg[1])) {
204 if (!preg_match(
'/'.preg_quote($reg[1]).
'/i', $db->type)) {
211 if (!empty($reg[2])) {
212 if (is_numeric($reg[2])) {
213 $versionrequest = explode(
'.', $reg[2]);
216 if (!count($versionrequest) || !count($versionarray) ||
versioncompare($versionrequest, $versionarray) > 0) {
221 $dbcollation = strtoupper(preg_replace(
'/_/',
'', $conf->db->dolibarr_main_db_collation));
224 if (empty($conf->db->dolibarr_main_db_collation) || ($reg[2] != $dbcollation)) {
234 $buf = preg_replace(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i',
'', $buf);
240 if ($nocommentremoval || !preg_match(
'/^\s*--/', $buf)) {
241 if (empty($nocommentremoval)) {
242 $buf = preg_replace(
'/([,;ERLT\)])\s*--.*$/i',
'\1', $buf);
244 if ($buffer) $buffer .=
' ';
245 $buffer .= trim($buf);
250 if (preg_match(
'/;/', $buffer)) {
253 $arraysql[$i] = $buffer;
261 $arraysql[$i] = $buffer;
265 dol_syslog(
"Admin.lib::run_sql failed to open file ".$sqlfile, LOG_ERR);
269 $listofmaxrowid = array();
270 foreach ($arraysql as $i => $sql) {
274 while (preg_match(
'/__\+MAX_([A-Za-z0-9_]+)__/i', $newsql, $reg)) {
276 if (!isset($listofmaxrowid[$table])) {
278 $sqlgetrowid =
'SELECT MAX(rowid) as max from '.preg_replace(
'/^llx_/', MAIN_DB_PREFIX, $table);
279 $resql = $db->query($sqlgetrowid);
281 $obj = $db->fetch_object(
$resql);
282 $listofmaxrowid[$table] = $obj->max;
283 if (empty($listofmaxrowid[$table])) {
284 $listofmaxrowid[$table] = 0;
288 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
289 print
'<div class="error">'.$langs->trans(
"Failed to get max rowid for ".$table).
"</div>";
297 $from =
'__+MAX_'.$table.
'__';
298 $to =
'+'.$listofmaxrowid[$table];
299 $newsql = str_replace($from, $to, $newsql);
300 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1).
' (replacing '.$from.
' to '.$to.
')', LOG_DEBUG);
302 $arraysql[$i] = $newsql;
305 if ($offsetforchartofaccount > 0) {
311 $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);
312 $newsql = preg_replace(
'/([,\s])0 \+ '.((
int) $offsetforchartofaccount).
'/ims',
'\1 0', $newsql);
314 $arraysql[$i] = $newsql;
323 $listofinsertedrowid = array();
324 $keyforsql = md5($sqlfile);
325 foreach ($arraysql as $i => $sql) {
328 if ($onlysqltoimportwebsite) {
329 $newsql = str_replace(array(
"\'"),
'__BACKSLASHQUOTE__', $sql);
332 $l = strlen($newsql);
337 $char = $newsql[$is];
344 } elseif (empty($quoteopen)) {
345 $newsqlclean .= $char;
349 $newsqlclean = str_replace(array(
"null"),
'__000__', $newsqlclean);
355 if (preg_match(
'/^--/', $newsqlclean)) {
357 } elseif (preg_match(
'/^UPDATE llx_website SET \w+ = \d+\+\d+ WHERE rowid = \d+;$/', $newsqlclean)) {
359 } elseif (preg_match(
'/^INSERT INTO llx_website_page\([a-z0-9_\s,]+\) VALUES\([0-9_\s,\+]+\);$/', $newsqlclean)) {
367 if (preg_match(
'/^UPDATE llx_website SET \w+ = \'[a-zA-Z,\s]*\' WHERE rowid = \d+;$/', $sql)) {
376 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains non allowed instructions.", LOG_WARNING);
377 dol_syslog(
'$newsqlclean='.$newsqlclean, LOG_DEBUG);
383 if (MAIN_DB_PREFIX !=
'llx_') {
384 $sql = preg_replace(
'/llx_/i', MAIN_DB_PREFIX, $sql);
387 if (!empty($handler)) {
388 $sql = preg_replace(
'/__HANDLER__/i',
"'".$db->escape($handler).
"'", $sql);
391 $newsql = preg_replace(
'/__ENTITY__/i', (!empty($entity) ? $entity : $conf->entity), $sql);
395 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";
397 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1), LOG_DEBUG);
401 if (preg_match_all(
'/__ENCRYPT\(\'([^\']+)\'\)__/i', $newsql, $reg)) {
402 $num = count($reg[0]);
404 for ($j = 0; $j < $num; $j++) {
406 $to = $db->encrypt($reg[1][$j]);
407 $newsql = str_replace($from, $to, $newsql);
413 if (preg_match_all(
'/__DECRYPT\(\'([A-Za-z0-9_]+)\'\)__/i', $newsql, $reg)) {
414 $num = count($reg[0]);
416 for ($j = 0; $j < $num; $j++) {
418 $to = $db->decrypt($reg[1][$j]);
419 $newsql = str_replace($from, $to, $newsql);
425 while (preg_match(
'/__([0-9]+)__/', $newsql, $reg)) {
427 if (empty($listofinsertedrowid[$cursor])) {
429 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
430 print
'<div class="error">'.$langs->trans(
"FileIsNotCorrect").
"</div>";
437 $from =
'__'.$cursor.
'__';
438 $to = $listofinsertedrowid[$cursor];
439 $newsql = str_replace($from, $to, $newsql);
444 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1), LOG_DEBUG);
447 $result = $db->query($newsql, $usesavepoint);
450 print
'<!-- Result = OK -->'.
"\n";
453 if (preg_replace(
'/insert into ([^\s]+)/i', $newsql, $reg)) {
457 $table = preg_replace(
'/([^a-zA-Z_]+)/i',
'', $reg[1]);
458 $insertedrowid = $db->last_insert_id($table);
459 $listofinsertedrowid[$cursorinsert] = $insertedrowid;
460 dol_syslog(
'Admin.lib::run_sql Insert nb '.$cursorinsert.
', done in table '.$table.
', rowid is '.$listofinsertedrowid[$cursorinsert], LOG_DEBUG);
464 $errno = $db->errno();
466 print
'<!-- Result = '.$errno.
' -->'.
"\n";
471 'DB_ERROR_TABLE_ALREADY_EXISTS',
472 'DB_ERROR_COLUMN_ALREADY_EXISTS',
473 'DB_ERROR_KEY_NAME_ALREADY_EXISTS',
474 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS',
475 'DB_ERROR_RECORD_ALREADY_EXISTS',
476 'DB_ERROR_NOSUCHTABLE',
477 'DB_ERROR_NOSUCHFIELD',
478 'DB_ERROR_NO_FOREIGN_KEY_TO_DROP',
479 'DB_ERROR_NO_INDEX_TO_DROP',
480 'DB_ERROR_CANNOT_CREATE',
481 'DB_ERROR_CANT_DROP_PRIMARY_KEY',
482 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS',
485 if ($okerror ==
'none') {
490 if (!in_array($errno, $okerrors)) {
492 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
493 print
'<div class="error">'.$langs->trans(
"Error").
" ".$db->errno().
": ".$newsql.
"<br>".$db->error().
"</div>";
494 print
'</td></tr>'.
"\n";
496 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" Error ".$db->errno().
" ".$newsql.
"<br>".$db->error(), LOG_ERR);
504 print
'<tr><td>'.$langs->trans(
"ProcessMigrateScript").
'</td>';
505 print
'<td class="right">';
507 print
'<span class="ok">'.$langs->trans(
"OK").
'</span>';
509 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
513 print
'<script type="text/javascript">
514 jQuery(document).ready(function() {
515 function init_trrunsql'.$keyforsql.
'()
517 console.log("toggle .trforrunsql'.$keyforsql.
'");
518 jQuery(".trforrunsql'.$keyforsql.
'").toggle();
520 init_trrunsql'.$keyforsql.
'();
521 jQuery(".trforrunsqlshowhide'.$keyforsql.
'").click(function() {
522 init_trrunsql'.$keyforsql.
'();
526 print
' - <a class="trforrunsqlshowhide'.$keyforsql.
'" href="#">'.$langs->trans(
"ShowHideDetails").
'</a>';
529 print
'</td></tr>'.
"\n";
557 dol_print_error(
'',
'Error call dolibar_del_const with parameter name empty');
561 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
562 $sql .=
" WHERE (".$db->decrypt(
'name').
" = '".$db->escape($name).
"'";
563 if (is_numeric($name)) {
564 $sql .=
" OR rowid = ".((int) $name);
568 $sql .=
" AND entity = ".((int) $entity);
571 dol_syslog(
"admin.lib::dolibarr_del_const", LOG_DEBUG);
572 $resql = $db->query($sql);
574 $conf->global->$name =
'';
596 $sql =
"SELECT ".$db->decrypt(
'value').
" as value";
597 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
598 $sql .=
" WHERE name = ".$db->encrypt($name);
599 $sql .=
" AND entity = ".((int) $entity);
601 dol_syslog(
"admin.lib::dolibarr_get_const", LOG_DEBUG);
602 $resql = $db->query($sql);
604 $obj = $db->fetch_object(
$resql);
606 $value = $obj->value;
627 function dolibarr_set_const($db, $name, $value, $type =
'chaine', $visible = 0, $note =
'', $entity = 1)
636 dol_print_error($db,
"Error: Call to function dolibarr_set_const with wrong parameters", LOG_ERR);
644 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
645 $sql .=
" WHERE name = ".$db->encrypt($name);
647 $sql .=
" AND entity = ".((int) $entity);
650 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
651 $resql = $db->query($sql);
653 if (strcmp($value,
'')) {
654 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name,value,type,visible,note,entity)";
656 $sql .= $db->encrypt($name);
657 $sql .=
", ".$db->encrypt($value);
658 $sql .=
",'".$db->escape($type).
"',".((int) $visible).
",'".$db->escape($note).
"',".((int) $entity).
")";
662 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
663 $resql = $db->query($sql);
668 $conf->global->$name = $value;
671 $error = $db->lasterror();
689 global $langs, $conf, $user,
$form;
691 $desc = $langs->trans(
"ModulesDesc",
'{picto}');
692 $desc = str_replace(
'{picto}',
img_picto(
'',
'switch_off'), $desc);
696 $mode = empty($conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT) ?
'commonkanban' :
'common';
697 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=".$mode;
698 if ($nbofactivatedmodules <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) {
700 $head[$h][1] = $langs->trans(
"AvailableModules");
701 $head[$h][1] .=
$form->textwithpicto(
'', $langs->trans(
"YouMustEnableOneModule").
'.<br><br><span class="opacitymedium">'.$desc.
'</span>', 1,
'warning');
704 $head[$h][1] = $langs->trans(
"AvailableModules").
'<span class="badge marginleftonly">'.$nbofactivatedmodules.
' / '.$nboftotalmodules.
'</span>';
706 $head[$h][2] =
'modules';
709 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=marketplace";
710 $head[$h][1] = $langs->trans(
"ModulesMarketPlaces");
711 $head[$h][2] =
'marketplace';
714 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=deploy";
715 $head[$h][1] = $langs->trans(
"AddExtensionThemeModuleOrOther");
716 $head[$h][2] =
'deploy';
719 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=develop";
720 $head[$h][1] = $langs->trans(
"ModulesDevelopYourModule");
721 $head[$h][2] =
'develop';
734 global $langs, $conf, $user;
738 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=other";
739 $head[$h][1] = $langs->trans(
"LanguageAndPresentation");
740 $head[$h][2] =
'other';
743 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=template";
744 $head[$h][1] = $langs->trans(
"SkinAndColors");
745 $head[$h][2] =
'template';
748 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=dashboard";
749 $head[$h][1] = $langs->trans(
"Dashboard");
750 $head[$h][2] =
'dashboard';
753 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=login";
754 $head[$h][1] = $langs->trans(
"LoginPage");
755 $head[$h][2] =
'login';
774 global $db, $langs, $conf, $user;
778 $head[$h][0] = DOL_URL_ROOT.
"/admin/security_other.php";
779 $head[$h][1] = $langs->trans(
"Miscellaneous");
780 $head[$h][2] =
'misc';
783 $head[$h][0] = DOL_URL_ROOT.
"/admin/security.php";
784 $head[$h][1] = $langs->trans(
"Passwords");
785 $head[$h][2] =
'passwords';
788 $head[$h][0] = DOL_URL_ROOT.
"/admin/security_file.php";
789 $head[$h][1] = $langs->trans(
"Files").
' ('.$langs->trans(
"Upload").
')';
790 $head[$h][2] =
'file';
800 $head[$h][0] = DOL_URL_ROOT.
"/admin/proxy.php";
801 $head[$h][1] = $langs->trans(
"ExternalAccess");
802 $head[$h][2] =
'proxy';
805 $head[$h][0] = DOL_URL_ROOT.
"/admin/events.php";
806 $head[$h][1] = $langs->trans(
"Audit");
807 $head[$h][2] =
'audit';
813 $sql =
"SELECT COUNT(r.id) as nb";
814 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r";
815 $sql .=
" WHERE r.libelle NOT LIKE 'tou%'";
816 $sql .=
" AND entity = ".((int) $conf->entity);
817 $sql .=
" AND bydefault = 1";
818 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
819 $sql .=
" AND r.perms NOT LIKE '%_advance'";
821 $resql = $db->query($sql);
823 $obj = $db->fetch_object(
$resql);
831 $head[$h][0] = DOL_URL_ROOT.
"/admin/perms.php";
832 $head[$h][1] = $langs->trans(
"DefaultRights");
834 $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ?
'<span class="badge marginleftonlyshort">'.$nbPerms.
'</span>' :
'');
836 $head[$h][2] =
'default';
849 global $langs, $conf, $user;
854 $object->id = $object->numero;
856 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".$object->id.
'&mode=desc';
857 $head[$h][1] = $langs->trans(
"Description");
858 $head[$h][2] =
'desc';
861 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".$object->id.
'&mode=feature';
862 $head[$h][1] = $langs->trans(
"TechnicalServicesProvided");
863 $head[$h][2] =
'feature';
866 if ($object->isCoreOrExternalModule() ==
'external') {
867 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".$object->id.
'&mode=changelog';
868 $head[$h][1] = $langs->trans(
"ChangeLog");
869 $head[$h][2] =
'changelog';
887 global $langs, $conf, $user;
891 $head[$h][0] = DOL_URL_ROOT.
"/admin/translation.php?mode=searchkey";
892 $head[$h][1] = $langs->trans(
"TranslationKeySearch");
893 $head[$h][2] =
'searchkey';
896 $head[$h][0] = DOL_URL_ROOT.
"/admin/translation.php?mode=overwrite";
897 $head[$h][1] =
'<span class="valignmiddle">'.$langs->trans(
"TranslationOverwriteKey").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
898 $head[$h][2] =
'overwrite';
917 global $langs, $conf, $user;
921 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=createform";
922 $head[$h][1] = $langs->trans(
"DefaultCreateForm");
923 $head[$h][2] =
'createform';
926 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=filters";
927 $head[$h][1] = $langs->trans(
"DefaultSearchFilters");
928 $head[$h][2] =
'filters';
931 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=sortorder";
932 $head[$h][1] = $langs->trans(
"DefaultSortOrder");
933 $head[$h][2] =
'sortorder';
936 if (!empty($conf->use_javascript_ajax)) {
937 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=focus";
938 $head[$h][1] = $langs->trans(
"DefaultFocus");
939 $head[$h][2] =
'focus';
942 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=mandatory";
943 $head[$h][1] = $langs->trans(
"DefaultMandatory");
944 $head[$h][2] =
'mandatory';
971 $arrayofSessions = array();
974 $iniPath = ini_get(
"session.save_path");
976 $sessPath = $iniPath;
979 dol_syslog(
'admin.lib:listOfSessions sessPath='.$sessPath);
983 while (($file = @readdir($dh)) !==
false) {
984 if (preg_match(
'/^sess_/i', $file) && $file !=
"." && $file !=
"..") {
985 $fullpath = $sessPath.$file;
986 if (!@is_dir($fullpath) && is_readable($fullpath)) {
987 $sessValues = file_get_contents($fullpath);
993 if (preg_match(
'/dol_login/i', $sessValues) &&
994 (preg_match(
'/dol_entity\|i:'.$conf->entity.
';/i', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"'.$conf->entity.
'"/i', $sessValues)) &&
995 preg_match(
'/dol_company\|s:([0-9]+):"('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
996 $tmp = explode(
'_', $file);
999 $loginfound = preg_match(
'/dol_login\|s:[0-9]+:"([A-Za-z0-9]+)"/i', $sessValues, $regs);
1001 $arrayofSessions[$idsess][
"login"] = $regs[1];
1003 $arrayofSessions[$idsess][
"age"] = time() - filectime($fullpath);
1004 $arrayofSessions[$idsess][
"creation"] = filectime($fullpath);
1005 $arrayofSessions[$idsess][
"modification"] = filemtime($fullpath);
1006 $arrayofSessions[$idsess][
"raw"] = $sessValues;
1014 return $arrayofSessions;
1027 $sessPath = ini_get(
"session.save_path").
"/";
1028 dol_syslog(
'admin.lib:purgeSessions mysessionid='.$mysessionid.
' sessPath='.$sessPath);
1034 while (($file = @readdir($dh)) !==
false) {
1035 if ($file !=
"." && $file !=
"..") {
1036 $fullpath = $sessPath.$file;
1037 if (!@is_dir($fullpath)) {
1038 $sessValues = file_get_contents($fullpath);
1040 if (preg_match(
'/dol_login/i', $sessValues) &&
1041 preg_match(
'/dol_entity\|s:([0-9]+):"('.$conf->entity.
')"/i', $sessValues) &&
1042 preg_match(
'/dol_company\|s:([0-9]+):"('.$conf->global->MAIN_INFO_SOCIETE_NOM.
')"/i', $sessValues)) {
1043 $tmp = explode(
'_', $file);
1046 if ($idsess != $mysessionid) {
1047 $res = @unlink($fullpath);
1077 global $db, $langs, $conf, $mysoc;
1082 if (empty($value)) {
1083 $ret[
'errors'][] =
'ErrorBadParameter';
1087 $ret = array(
'nbmodules'=>0,
'errors'=>array(),
'nbperms'=>0);
1089 $modFile = $modName.
".class.php";
1096 foreach ($modulesdir as $dir) {
1097 if (file_exists($dir.$modFile)) {
1098 $found = @include_once $dir.$modFile;
1105 $objMod =
new $modName($db);
1109 $vermin = isset($objMod->phpmin) ? $objMod->phpmin : 0;
1111 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequirePHPVersion",
versiontostring($vermin));
1117 $vermin = isset($objMod->need_dolibarr_version) ? $objMod->need_dolibarr_version : 0;
1120 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireDolibarrVersion",
versiontostring($vermin));
1125 if (!empty($objMod->need_javascript_ajax) && empty($conf->use_javascript_ajax)) {
1126 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireJavascript");
1130 $const_name = $objMod->const_name;
1131 if (!empty($conf->global->$const_name)) {
1135 $result = $objMod->init();
1138 $ret[
'errors'][] = $objMod->error;
1141 if (isset($objMod->depends) && is_array($objMod->depends) && !empty($objMod->depends)) {
1144 foreach ($objMod->depends as $key => $modulestring) {
1146 if ((!is_numeric($key)) && !preg_match(
'/^always/', $key) && $mysoc->country_code && !preg_match(
'/^'.$mysoc->country_code.
'/', $key)) {
1147 dol_syslog(
"We are not concerned by dependency with key=".$key.
" because our country is ".$mysoc->country_code);
1151 foreach ($modulesdir as $dir) {
1152 if (file_exists($dir.$modulestring.
".class.php")) {
1154 if (empty($resarray[
'errors'])) {
1157 foreach ($resarray[
'errors'] as $errorMessage) {
1166 $ret[
'nbmodules'] += $resarray[
'nbmodules'];
1167 $ret[
'nbperms'] += $resarray[
'nbperms'];
1169 $ret[
'errors'][] = $langs->trans(
'activateModuleDependNotSatisfied', $objMod->name, $modulestring);
1174 if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && !empty($objMod->conflictwith)) {
1176 $num = count($objMod->conflictwith);
1177 for ($i = 0; $i < $num; $i++) {
1178 foreach ($modulesdir as $dir) {
1179 if (file_exists($dir.$objMod->conflictwith[$i].
".class.php")) {
1188 if (!count($ret[
'errors'])) {
1189 $ret[
'nbmodules']++;
1190 $ret[
'nbperms'] += (is_array($objMod->rights)?count($objMod->rights):0);
1206 global $db, $modules, $conf;
1209 if (empty($value)) {
1210 return 'ErrorBadParameter';
1215 $modFile = $modName.
".class.php";
1222 foreach ($modulesdir as $dir) {
1223 if (file_exists($dir.$modFile)) {
1224 $found = @include_once $dir.$modFile;
1232 $objMod =
new $modName($db);
1233 $result = $objMod->remove();
1235 $ret = $objMod->error;
1241 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
1243 $genericMod->name = preg_replace(
'/^mod/i',
'', $modName);
1244 $genericMod->rights_class = strtolower(preg_replace(
'/^mod/i',
'', $modName));
1245 $genericMod->const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', $modName));
1246 dol_syslog(
"modules::unActivateModule Failed to find module file, we use generic function with name ".$modName);
1247 $genericMod->remove(
'');
1251 if (!$ret && $requiredby && is_object($objMod) && is_array($objMod->requiredby)) {
1252 $countrb = count($objMod->requiredby);
1253 for ($i = 0; $i < $countrb; $i++) {
1281 function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
1283 global $db, $modules, $conf, $langs;
1285 dol_syslog(
"complete_dictionary_with_modules Search external modules to complete the list of dictionnary tables", LOG_DEBUG, 1);
1292 foreach ($modulesdir as $dir) {
1295 dol_syslog(
"Scan directory ".$dir.
" for modules");
1297 if (is_resource($handle)) {
1298 while (($file = readdir($handle)) !==
false) {
1300 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1301 $modName = substr($file, 0,
dol_strlen($file) - 10);
1304 include_once $dir.$file;
1305 $objMod =
new $modName($db);
1307 if ($objMod->numero > 0) {
1308 $j = $objMod->numero;
1313 $modulequalified = 1;
1316 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1318 $modulequalified = 0;
1321 $modulequalified = 0;
1325 $modulequalified = 0;
1328 if ($modulequalified) {
1330 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1331 foreach ($objMod->langfiles as $langfile) {
1332 $langs->load($langfile);
1337 if (empty($objMod->dictionaries) && !empty($objMod->dictionnaries)) {
1338 $objMod->dictionaries = $objMod->dictionnaries;
1341 if (!empty($objMod->dictionaries)) {
1343 $nbtabname = $nbtablib = $nbtabsql = $nbtabsqlsort = $nbtabfield = $nbtabfieldvalue = $nbtabfieldinsert = $nbtabrowid = $nbtabcond = $nbtabfieldcheck = $nbtabhelp = 0;
1344 $tabnamerelwithkey = array();
1345 foreach ($objMod->dictionaries[
'tabname'] as $key => $val) {
1346 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $val);
1348 $taborder[] = max($taborder) + 1;
1350 $tabnamerelwithkey[$key] = $val;
1351 $tabcomplete[$tmptablename][
'picto'] = $objMod->picto;
1353 foreach ($objMod->dictionaries[
'tablib'] as $key => $val) {
1354 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1357 $tabcomplete[$tmptablename][
'lib'] = $val;
1359 foreach ($objMod->dictionaries[
'tabsql'] as $key => $val) {
1360 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1363 $tabcomplete[$tmptablename][
'sql'] = $val;
1365 foreach ($objMod->dictionaries[
'tabsqlsort'] as $key => $val) {
1366 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1368 $tabsqlsort[] = $val;
1369 $tabcomplete[$tmptablename][
'sqlsort'] = $val;
1371 foreach ($objMod->dictionaries[
'tabfield'] as $key => $val) {
1372 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1375 $tabcomplete[$tmptablename][
'field'] = $val;
1377 foreach ($objMod->dictionaries[
'tabfieldvalue'] as $key => $val) {
1378 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1380 $tabfieldvalue[] = $val;
1381 $tabcomplete[$tmptablename][
'value'] = $val;
1383 foreach ($objMod->dictionaries[
'tabfieldinsert'] as $key => $val) {
1384 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1385 $nbtabfieldinsert++;
1386 $tabfieldinsert[] = $val;
1387 $tabcomplete[$tmptablename][
'fieldinsert'] = $val;
1389 foreach ($objMod->dictionaries[
'tabrowid'] as $key => $val) {
1390 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1393 $tabcomplete[$tmptablename][
'rowid'] = $val;
1395 foreach ($objMod->dictionaries[
'tabcond'] as $key => $val) {
1396 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1399 $tabcomplete[$tmptablename][
'rowid'] = $val;
1401 if (!empty($objMod->dictionaries[
'tabhelp'])) {
1402 foreach ($objMod->dictionaries[
'tabhelp'] as $key => $val) {
1403 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1406 $tabcomplete[$tmptablename][
'help'] = $val;
1409 if (!empty($objMod->dictionaries[
'tabfieldcheck'])) {
1410 foreach ($objMod->dictionaries[
'tabfieldcheck'] as $key => $val) {
1411 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1413 $tabcomplete[$tmptablename][
'fieldcheck'] = $val;
1417 if ($nbtabname != $nbtablib || $nbtablib != $nbtabsql || $nbtabsql != $nbtabsqlsort) {
1418 print
'Error in descriptor of module '.$const_name.
'. Array ->dictionaries has not same number of record for key "tabname", "tablib", "tabsql" and "tabsqlsort"';
1428 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1435 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1452 global $db, $conf, $langs;
1456 foreach ($modulesdir as $dir) {
1458 dol_syslog(
"Scan directory ".$dir.
" for modules");
1460 if (is_resource($handle)) {
1461 while (($file = readdir($handle)) !==
false) {
1462 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1463 $modName = substr($file, 0,
dol_strlen($file) - 10);
1466 include_once $dir.$file;
1467 $objMod =
new $modName($db);
1469 $modulequalified = 1;
1472 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1474 if ($objMod->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
1475 $modulequalified = 0;
1477 if ($objMod->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
1478 $modulequalified = 0;
1480 if (!empty($conf->global->$const_name)) {
1481 $modulequalified = 0;
1484 if ($modulequalified) {
1486 if (isset($objMod->automatic_activation) && is_array($objMod->automatic_activation) && isset($objMod->automatic_activation[$country_code])) {
1489 setEventMessages($objMod->automatic_activation[$country_code],
null,
'warnings');
1492 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1499 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1514 global $db, $modules, $conf, $langs;
1517 $filename = array();
1526 dol_syslog(
"complete_elementList_with_modules Search external modules to complete the list of contact element", LOG_DEBUG, 1);
1530 foreach ($modulesdir as $dir) {
1533 dol_syslog(
"Scan directory ".$dir.
" for modules");
1535 if (is_resource($handle)) {
1536 while (($file = readdir($handle)) !==
false) {
1538 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1539 $modName = substr($file, 0,
dol_strlen($file) - 10);
1542 include_once $dir.$file;
1543 $objMod =
new $modName($db);
1545 if ($objMod->numero > 0) {
1546 $j = $objMod->numero;
1551 $modulequalified = 1;
1554 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1555 if ($objMod->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 &&
getDolGlobalString($const_name)) {
1556 $modulequalified = 0;
1558 if ($objMod->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 &&
getDolGlobalString($const_name)) {
1559 $modulequalified = 0;
1562 if (empty($conf->global->$const_name)) {
1563 $modulequalified = 0;
1566 if ($modulequalified) {
1568 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1569 foreach ($objMod->langfiles as $langfile) {
1570 $langs->load($langfile);
1574 $modules[$i] = $objMod;
1575 $filename[$i] = $modName;
1576 $orders[$i] = $objMod->family.
"_".$j;
1580 if (!empty($objMod->module_parts[
'contactelement'])) {
1581 if (is_array($objMod->module_parts[
'contactelement'])) {
1582 foreach ($objMod->module_parts[
'contactelement'] as $elem => $title) {
1583 $elementList[$elem] = $langs->trans($title);
1586 $elementList[$objMod->name] = $langs->trans($objMod->name);
1593 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1600 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1621 global $db, $langs, $conf, $user;
1622 global $_Avery_Labels;
1626 if (empty($strictw3c)) {
1627 dol_syslog(
"Warning: Function form_constantes is calle with parameter strictw3c = 0, this is deprecated. Value must be 2 now.", LOG_DEBUG);
1629 if (!empty($strictw3c) && $strictw3c == 1) {
1630 print
"\n".
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1631 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1632 print
'<input type="hidden" name="action" value="updateall">';
1635 print
'<div class="div-table-responsive-no-min">';
1636 print
'<table class="noborder centpercent">';
1637 print
'<tr class="liste_titre">';
1638 print
'<td class="">'.$langs->trans(
"Description").
'</td>';
1640 $text = $langs->trans($text);
1641 print
$form->textwithpicto($text, $helptext, 1,
'help',
'', 0, 2,
'idhelptext');
1643 if (empty($strictw3c)) {
1644 print
'<td class="center" width="80">'.$langs->trans(
"Action").
'</td>';
1649 foreach ($tableau as $key => $const) {
1652 if (is_numeric($key)) {
1655 if (is_array($const)) {
1656 $type = $const[
'type'];
1657 $label = $const[
'label'];
1667 $sql .=
", ".$db->decrypt(
'name').
" as name";
1668 $sql .=
", ".$db->decrypt(
'value').
" as value";
1671 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1672 $sql .=
" WHERE ".$db->decrypt(
'name').
" = '".$db->escape($const).
"'";
1673 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
1674 $sql .=
" ORDER BY name ASC, entity DESC";
1675 $result = $db->query($sql);
1679 $obj = $db->fetch_object($result);
1682 $obj = (object) array(
'rowid'=>
'',
'name'=>$const,
'value'=>
'',
'type'=>$type,
'note'=>
'');
1685 if (empty($strictw3c)) {
1686 print
"\n".
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1687 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1688 print
'<input type="hidden" name="page_y" value="'.newToken().
'">';
1691 print
'<tr class="oddeven">';
1695 if (empty($strictw3c)) {
1696 print
'<input type="hidden" name="action" value="update">';
1698 print
'<input type="hidden" name="rowid'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.$obj->rowid.
'">';
1699 print
'<input type="hidden" name="constname'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.$const.
'">';
1700 print
'<input type="hidden" name="constnote_'.$obj->name.
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1701 print
'<input type="hidden" name="consttype_'.$obj->name.
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1703 print ($label ? $label : $langs->trans(
'Desc'.$const));
1705 if ($const ==
'ADHERENT_MAILMAN_URL') {
1706 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick1">'.
img_down().
'</a><br>';
1708 print
'<div id="example1" class="hidden">';
1709 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';
1711 } elseif ($const ==
'ADHERENT_MAILMAN_UNSUB_URL') {
1712 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick2">'.
img_down().
'</a><br>';
1713 print
'<div id="example2" class="hidden">';
1714 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';
1717 } elseif ($const ==
'ADHERENT_MAILMAN_LISTS') {
1718 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick3">'.
img_down().
'</a><br>';
1719 print
'<div id="example3" class="hidden">';
1720 print
'mymailmanlist<br>';
1721 print
'mymailmanlist1,mymailmanlist2<br>';
1722 print
'TYPE:Type1:mymailmanlist1,TYPE:Type2:mymailmanlist2<br>';
1724 print
'CATEG:Categ1:mymailmanlist1,CATEG:Categ2:mymailmanlist2<br>';
1728 } elseif ($const ==
'ADHERENT_MAIL_FROM') {
1729 print
' '.img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
1735 if ($const ==
'ADHERENT_CARD_TYPE' || $const ==
'ADHERENT_ETIQUETTE_TYPE') {
1738 require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
1739 $arrayoflabels = array();
1740 foreach (array_keys($_Avery_Labels) as $codecards) {
1741 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
1743 print
$form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayoflabels, ($obj->value ? $obj->value :
'CARD'), 1, 0, 0);
1744 print
'<input type="hidden" name="consttype" value="yesno">';
1745 print
'<input type="hidden" name="constnote'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1749 print
'<input type="hidden" name="consttype'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1750 print
'<input type="hidden" name="constnote'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1751 if ($obj->type ==
'textarea' || in_array($const, array(
'ADHERENT_CARD_TEXT',
'ADHERENT_CARD_TEXT_RIGHT',
'ADHERENT_ETIQUETTE_TEXT'))) {
1752 print
'<textarea class="flat" name="constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" cols="50" rows="5" wrap="soft">'.
"\n";
1754 print
"</textarea>\n";
1755 } elseif ($obj->type ==
'html') {
1756 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1757 $doleditor =
new DolEditor(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $obj->value,
'', 160,
'dolibarr_notes',
'',
false,
false,
isModEnabled(
'fckeditor'), ROWS_5,
'90%');
1758 $doleditor->Create();
1759 } elseif ($obj->type ==
'yesno') {
1760 print
$form->selectyesno(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $obj->value, 1);
1761 } elseif (preg_match(
'/emailtemplate/', $obj->type)) {
1762 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1765 $tmp = explode(
':', $obj->type);
1767 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, -1);
1769 $arrayofmessagename = array();
1770 if (is_array($formmail->lines_model)) {
1771 foreach ($formmail->lines_model as $modelmail) {
1774 if (!empty($arrayofmessagename[$modelmail->label])) {
1775 $moreonlabel =
' <span class="opacitymedium">('.$langs->trans(
"SeveralLangugeVariatFound").
')</span>';
1778 $arrayofmessagename[$modelmail->label.
':'.$tmp[1]] = $langs->trans(preg_replace(
'/\(|\)/',
'', $modelmail->label)).$moreonlabel;
1783 print
$form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayofmessagename, $obj->value.
':'.$tmp[1],
'None', 0, 0,
'', 0, 0, 0,
'',
'', 1);
1784 } elseif (preg_match(
'/MAIL_FROM$/i', $const)) {
1785 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).
'">';
1787 print
'<input type="text" class="flat minwidth300" name="constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1793 if (empty($strictw3c)) {
1794 print
'<td class="center">';
1795 print
'<input type="submit" class="button small reposition" value="'.$langs->trans(
"Update").
'" name="update">';
1801 if (empty($strictw3c)) {
1809 if (!empty($strictw3c) && $strictw3c == 1) {
1810 print
'<div align="center"><input type="submit" class="button small reposition" value="'.$langs->trans(
"Update").
'" name="update"></div>';
1824 global $conf, $langs;
1826 $text = $langs->trans(
"OnlyFollowingModulesAreOpenedToExternalUsers");
1827 $listofmodules = explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
1829 if (!empty($modules)) {
1830 foreach ($modules as $module) {
1831 $moduleconst = $module->const_name;
1832 $modulename = strtolower($module->name);
1836 if (!in_array($modulename, $listofmodules)) {
1847 $text .= $langs->trans(
'Module'.$module->numero.
'Name');
1869 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity, libelle, description)";
1870 $sql .=
" VALUES ('".$db->escape($name).
"','".$db->escape($type).
"',".((int) $conf->entity).
", ";
1871 $sql .= ($label ?
"'".$db->escape($label).
"'" :
'null').
", ";
1872 $sql .= (!empty($description) ?
"'".$db->escape($description).
"'" :
"null");
1875 dol_syslog(
"admin.lib::addDocumentModel", LOG_DEBUG);
1876 $resql = $db->query($sql);
1900 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"document_model";
1901 $sql .=
" WHERE nom = '".$db->escape($name).
"'";
1902 $sql .=
" AND type = '".$db->escape($type).
"'";
1903 $sql .=
" AND entity = ".((int) $conf->entity);
1905 dol_syslog(
"admin.lib::delDocumentModel", LOG_DEBUG);
1906 $resql = $db->query($sql);
1927 $phpinfostring = ob_get_contents();
1930 $info_arr = array();
1931 $info_lines = explode(
"\n", strip_tags($phpinfostring,
"<tr><td><h2>"));
1933 foreach ($info_lines as $line) {
1936 preg_match(
"~<h2>(.*)</h2>~", $line, $title) ? $cat = $title[1] :
null;
1938 if (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
1939 $info_arr[trim($cat)][trim($val[1])] = $val[2];
1940 } elseif (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
1941 $info_arr[trim($cat)][trim($val[1])] = array(
"local" => $val[2],
"master" => $val[3]);
1954 global $langs, $conf;
1959 $head[$h][0] = DOL_URL_ROOT.
"/admin/company.php";
1960 $head[$h][1] = $langs->trans(
"Company");
1961 $head[$h][2] =
'company';
1964 $head[$h][0] = DOL_URL_ROOT.
"/admin/openinghours.php";
1965 $head[$h][1] = $langs->trans(
"OpeningHours");
1966 $head[$h][2] =
'openinghours';
1969 $head[$h][0] = DOL_URL_ROOT.
"/admin/accountant.php";
1970 $head[$h][1] = $langs->trans(
"Accountant");
1971 $head[$h][2] =
'accountant';
1974 $head[$h][0] = DOL_URL_ROOT.
"/admin/company_socialnetworks.php";
1975 $head[$h][1] = $langs->trans(
"SocialNetworksInformation");
1976 $head[$h][2] =
'socialnetworks';
1993 global $langs, $conf, $user;
1998 if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
1999 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails.php";
2000 $head[$h][1] = $langs->trans(
"OutGoingEmailSetup");
2001 $head[$h][2] =
'common';
2005 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_emailing.php";
2006 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"EMailing"));
2007 $head[$h][2] =
'common_emailing';
2012 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ticket.php";
2013 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"Ticket"));
2014 $head[$h][2] =
'common_ticket';
2020 if (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates') {
2021 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_senderprofile_list.php";
2022 $head[$h][1] = $langs->trans(
"EmailSenderProfiles");
2023 $head[$h][2] =
'senderprofiles';
2027 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_templates.php";
2028 $head[$h][1] = $langs->trans(
"EMailTemplates");
2029 $head[$h][2] =
'templates';