64 public $editor_squarred_logo;
92 public $module_position =
'50';
109 public $dirs = array();
114 public $boxes = array();
120 public $const = array();
125 public $cronjobs = array();
135 public $rights_admin_allowed;
140 public $rights_class;
142 const URL_FOR_BLACKLISTED_MODULES =
'https://www.dolibarr.org/modules-blacklist.php';
147 const KEY_DEFAULT = 3;
148 const KEY_FIRST_LEVEL = 4;
149 const KEY_SECOND_LEVEL = 5;
150 const KEY_MODULE = 6;
151 const KEY_ENABLED = 7;
156 public $menu = array();
185 public $module_parts = array();
212 public $version_if_core = 0;
218 public $lastVersion =
'';
224 public $needUpdate =
false;
239 public $descriptionlong;
244 public $dictionaries = array();
261 public $export_label;
271 public $export_enabled;
275 public $export_permission;
279 public $export_fields_array;
283 public $export_TypeFields_array;
287 public $export_entities_array;
291 public $export_aggregate_array;
295 public $export_examplevalues_array;
299 public $export_help_array;
306 public $export_special_array;
313 public $export_dependencies_array;
317 public $export_sql_start;
321 public $export_sql_end;
325 public $export_sql_order;
338 public $import_label;
347 public $import_entities_array;
351 public $import_tables_array;
355 public $import_tables_creator_array;
359 public $import_fields_array;
363 public $import_fieldshidden_array;
367 public $import_convertvalue_array;
371 public $import_regex_array;
375 public $import_examplevalues_array;
379 public $import_updatekeys_array;
383 public $import_run_sql_after_array;
387 public $import_TypeFields_array;
391 public $import_help_array;
401 public $always_enabled;
411 public $automatic_activation = array();
416 public $core_enabled;
432 public $config_page_url;
455 public $conflictwith;
467 public $warnings_activation;
474 public $warnings_activation_ext;
481 public $warnings_unactivation;
498 public $need_dolibarr_version;
504 public $max_dolibarr_version;
509 public $need_javascript_ajax;
514 public $enabled_bydefault;
519 public $hidden =
false;
524 public $url_last_version;
553 protected function _init($array_sql, $options =
'')
577 if (!$err && !preg_match(
'/newboxdefonly/', $options)) {
582 if (!$err && !preg_match(
'/noboxes/', $options)) {
607 $num = count($array_sql);
608 for ($i = 0; $i < $num; $i++) {
610 $val = $array_sql[$i];
613 if (is_array($val)) {
615 $ignoreerror = $val[
'ignoreerror'] ?? 0;
618 $sql = str_replace(
'__ENTITY__', (
string)
$conf->entity, $sql);
620 dol_syslog(get_class($this).
"::_init ignoreerror=".$ignoreerror, LOG_DEBUG);
621 $result = $this->db->query($sql, $ignoreerror);
624 $this->error = $this->db->lasterror();
627 dol_syslog(get_class($this).
"::_init Warning ".$this->db->lasterror(), LOG_WARNING);
637 $moduleNameInConf = strtolower(preg_replace(
'/^MAIN_MODULE_/',
'', $this->const_name));
639 if ($moduleNameInConf ===
'propale') {
640 $moduleNameInConf =
'propal';
641 } elseif ($moduleNameInConf ===
'supplierproposal') {
642 $moduleNameInConf =
'supplier_proposal';
645 $conf->modules[$moduleNameInConf] = $moduleNameInConf;
649 $this->db->rollback();
663 protected function _remove($array_sql, $options =
'')
692 if (!$err && !preg_match(
'/(newboxdefonly|noboxes)/', $options)) {
717 $num = count((array) $array_sql);
718 for ($i = 0; $i < $num; $i++) {
720 dol_syslog(get_class($this).
"::_remove", LOG_DEBUG);
721 $result = $this->db->query($array_sql[$i]);
723 $this->error = $this->db->error();
734 $moduleNameInConf = strtolower(preg_replace(
'/^MAIN_MODULE_/',
'', $this->const_name));
736 if ($moduleNameInConf ===
'propale') {
737 $moduleNameInConf =
'propal';
738 } elseif ($moduleNameInConf ===
'supplierproposal') {
739 $moduleNameInConf =
'supplier_proposal';
742 unset(
$conf->modules[$moduleNameInConf]);
746 $this->db->rollback();
761 $langs->load(
"admin");
763 if ($langs->transnoentitiesnoconv(
"Module".$this->numero.
"Name") !=
"Module".$this->numero.
"Name") {
765 return $langs->transnoentitiesnoconv(
"Module".$this->numero.
"Name");
768 if (is_array($this->langfiles)) {
769 foreach ($this->langfiles as $val) {
776 if ($langs->trans(
"Module".$this->name.
"Name") !=
"Module".$this->name.
"Name") {
778 return $langs->transnoentitiesnoconv(
"Module".$this->
name.
"Name");
782 return $langs->transnoentitiesnoconv($this->
name);
793 public function getDesc($foruseinpopupdesc = 0)
796 $langs->load(
"admin");
798 if ($langs->transnoentitiesnoconv(
"Module".$this->numero.
"Desc") !=
"Module".$this->numero.
"Desc") {
800 return $langs->transnoentitiesnoconv(
"Module".$this->numero.
"Desc");
803 if (is_array($this->langfiles)) {
804 foreach ($this->langfiles as $val) {
811 if ($langs->transnoentitiesnoconv(
"Module".$this->name.
"Desc") !=
"Module".$this->name.
"Desc") {
813 return $langs->trans(
"Module".$this->
name.
"Desc");
830 $langs->load(
"admin");
832 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
833 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
839 $content = file_get_contents($pathoffile,
false,
null, 0, 1024 * 1024);
841 if ((
float) DOL_VERSION >= 6.0) {
842 @include_once DOL_DOCUMENT_ROOT.
'/core/lib/parsemd.lib.php';
854 $content = preg_replace(
'/<a href="/',
'<a target="_blank" rel="noopener noreferrer" href="', $content);
856 $content = nl2br($content);
860 if (!empty($this->descriptionlong)) {
861 if (is_array($this->langfiles)) {
862 foreach ($this->langfiles as $val) {
869 $content = $langs->transnoentitiesnoconv($this->descriptionlong);
873 return '<div class="moduledesclong">'.$content.
'</div>';
889 $pathoffile =
dol_buildpath(strtolower($this->
name).
'/README-'.$langs->defaultlang.
'.md', 0);
894 $tmp = explode(
'_', $langs->defaultlang);
895 $pathoffile =
dol_buildpath(strtolower($this->
name).
'/README-'.$tmp[0].
'.md', 0);
907 return ($filefound ? $pathoffile :
'');
919 $langs->load(
"admin");
921 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
922 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
928 $pathoffile =
dol_buildpath(strtolower($this->
name).
'/ChangeLog-'.$langs->defaultlang.
'.md', 0);
940 $content = file_get_contents($pathoffile);
942 if ((
float) DOL_VERSION >= 6.0) {
943 @include_once DOL_DOCUMENT_ROOT.
'/core/lib/parsemd.lib.php';
947 $content = nl2br($content);
963 return $this->editor_name;
973 return $this->editor_url;
987 $langs->load(
"admin");
991 $newversion = preg_replace(
'/_deprecated/',
'', $this->version);
992 if ($newversion ==
'experimental') {
993 $ret = ($translated ? $langs->transnoentitiesnoconv(
"VersionExperimental") : $newversion);
994 } elseif ($newversion ==
'development') {
995 $ret = ($translated ? $langs->transnoentitiesnoconv(
"VersionDevelopment") : $newversion);
996 } elseif ($newversion ==
'dolibarr') {
998 } elseif ($newversion) {
1001 $ret = ($translated ? $langs->transnoentitiesnoconv(
"VersionUnknown") :
'unknown');
1004 if (preg_match(
'/_deprecated/', $this->version)) {
1005 $ret .= ($translated ?
' ('.$langs->transnoentitiesnoconv(
"Deprecated").
')' : $this->version);
1017 if (in_array($this->version, array(
'dolibarr',
'dolibarr_deprecated',
'experimental',
'development'))) {
1018 return $this->module_position;
1020 if ($this->module_position >= 100000) {
1021 return $this->module_position;
1023 $position = intval($this->module_position) + 100000;
1024 return strval($position);
1037 if ($this->version ==
'dolibarr' || $this->version ==
'dolibarr_deprecated') {
1040 if (!empty($this->version) && !in_array($this->version, array(
'experimental',
'development')) && empty($this->version_if_core)) {
1043 if (!empty($this->editor_name) || !empty($this->editor_url) && empty($this->version_if_core)) {
1046 if ($this->numero >= 100000) {
1060 return $this->langfiles;
1074 $langstring =
"ExportDataset_".$this->export_code[$r];
1075 if ($langs->trans($langstring) == $langstring) {
1077 return $langs->trans($this->export_label[$r]);
1080 return $langs->trans($langstring);
1096 $langstring =
"ImportDataset_".$this->import_code[$r];
1098 if ($langs->trans($langstring) == $langstring) {
1100 return $langs->transnoentitiesnoconv($this->import_label[$r]);
1103 return $langs->transnoentitiesnoconv($langstring);
1119 $sql =
"SELECT tms FROM ".MAIN_DB_PREFIX.
"const";
1120 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1121 $sql .=
" AND entity IN (0, ".((int)
$conf->entity).
")";
1123 dol_syslog(get_class($this).
"::getLastActiveDate", LOG_DEBUG);
1124 $resql = $this->db->query($sql);
1128 $obj = $this->db->fetch_object($resql);
1130 return $this->db->jdate($obj->tms);
1149 $sql =
"SELECT tms, note FROM ".MAIN_DB_PREFIX.
"const";
1150 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1151 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
1153 dol_syslog(get_class($this).
"::getLastActiveDate", LOG_DEBUG);
1154 $resql = $this->db->query($sql);
1158 $obj = $this->db->fetch_object($resql);
1162 $tmp = json_decode($obj->note,
true);
1165 'authorid' => empty($tmp[
'authorid']) ?
'' : (int) $tmp[
'authorid'],
1166 'ip' => empty($tmp[
'ip']) ?
'' : (
string) $tmp[
'ip'],
1167 'lastactivationdate' => $this->db->jdate($obj->tms),
1168 'lastactivationversion' => (!empty($tmp[
'lastactivationversion']) ? (
string) $tmp[
'lastactivationversion'] :
'unknown'),
1186 global
$conf, $user;
1191 $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 :
$conf->entity);
1193 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1194 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1195 $sql .=
" AND entity IN (0, ".$entity.
")";
1197 dol_syslog(get_class($this).
"::_active delete activation constant", LOG_DEBUG);
1198 $resql = $this->db->query($sql);
1203 $note = json_encode(
1205 'authorid' => (is_object($user) ? $user->id : 0),
1206 'ip' => (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']),
1207 'lastactivationversion' => $this->version,
1211 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (name, value, visible, entity, note) VALUES";
1212 $sql .=
" (".$this->db->encrypt($this->const_name);
1213 $sql .=
", ".$this->db->encrypt(
'1');
1214 $sql .=
", 0, ".((int) $entity);
1215 $sql .=
", '".$this->db->escape($note).
"')";
1217 dol_syslog(get_class($this).
"::_active insert activation constant", LOG_DEBUG);
1218 $resql = $this->db->query($sql);
1241 $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 :
$conf->entity);
1243 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1244 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1245 $sql .=
" AND entity IN (0, ".$entity.
")";
1247 dol_syslog(get_class($this).
"::_unactive", LOG_DEBUG);
1248 $this->db->query($sql);
1282 if (empty($reldir)) {
1286 include_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
1288 foreach (
$conf->file->dol_document_root as $dirroot) {
1290 $dirsql = $dirroot.$reldir;
1294 $listofsubdir = array(
'',
'tables/',
'data/');
1295 if ($this->db->type ==
'pgsql') {
1296 $listofsubdir[] =
'../pgsql/functions/';
1299 foreach ($listofsubdir as $subdir) {
1300 $dir = $dirsql.$subdir;
1302 $handle = @opendir($dir);
1303 if (is_resource($handle)) {
1308 while (($file = readdir($handle)) !==
false) {
1312 foreach ($files as $file) {
1313 if ($onlywithsuffix) {
1314 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1321 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 4) ==
'llx_') {
1333 while (($file = readdir($handle)) !==
false) {
1337 foreach ($files as $file) {
1338 if ($onlywithsuffix) {
1339 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1346 if (preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 4) ==
'llx_') {
1358 while (($file = readdir($handle)) !==
false) {
1362 foreach ($files as $file) {
1363 if ($onlywithsuffix) {
1364 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1371 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 9) ==
'functions') {
1383 while (($file = readdir($handle)) !==
false) {
1387 foreach ($files as $file) {
1388 if ($onlywithsuffix) {
1389 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1396 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 4) ==
'data') {
1408 while (($file = readdir($handle)) !==
false) {
1412 foreach ($files as $file) {
1413 if ($onlywithsuffix) {
1414 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1421 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 6) ==
'update') {
1440 dol_syslog(
"A module wants to load sql files from ".$reldir.
" but this directory was not found.", LOG_WARNING);
1457 include_once DOL_DOCUMENT_ROOT.
'/core/class/infobox.class.php';
1463 if (is_array($this->boxes)) {
1464 dol_syslog(get_class($this).
"::insert_boxes", LOG_DEBUG);
1468 foreach ($this->boxes as $key => $value) {
1469 $file = isset($this->boxes[$key][
'file']) ? $this->boxes[$key][
'file'] :
'';
1470 $note = isset($this->boxes[$key][
'note']) ? $this->boxes[$key][
'note'] :
'';
1471 $enabledbydefaulton = isset($this->boxes[$key][
'enabledbydefaulton']) ? $this->boxes[$key][
'enabledbydefaulton'] :
'Home';
1474 $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] :
'';
1477 $note = isset($this->boxes[$key][2]) ? $this->boxes[$key][2] :
'';
1481 $sql =
"SELECT count(*) as nb FROM ".MAIN_DB_PREFIX.
"boxes_def";
1482 $sql .=
" WHERE file = '".$this->db->escape($file).
"'";
1483 $sql .=
" AND entity = ".$conf->entity;
1485 $sql .=
" AND note ='".$this->db->escape($note).
"'";
1488 $result = $this->db->query($sql);
1490 $obj = $this->db->fetch_object($result);
1491 if ($obj->nb == 0) {
1495 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"boxes_def (file, entity, note)";
1496 $sql .=
" VALUES ('".$this->db->escape($file).
"', ";
1497 $sql .=
$conf->entity.
", ";
1498 $sql .= $note ?
"'".$this->db->escape($note).
"'" :
"null";
1501 dol_syslog(get_class($this).
"::insert_boxes", LOG_DEBUG);
1502 $resql = $this->db->query($sql);
1507 if (!$err && !preg_match(
'/newboxdefonly/', $option)) {
1508 $lastid = $this->db->last_insert_id(MAIN_DB_PREFIX.
"boxes_def",
"rowid");
1510 foreach ($pos_name as $key2 => $val2) {
1512 if ($enabledbydefaulton && $val2 != $enabledbydefaulton) {
1516 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"boxes (box_id, position, box_order, fk_user, entity)";
1517 $sql .=
" VALUES (".((int) $lastid).
", ".((int) $key2).
", '0', 0, ".((int)
$conf->entity).
")";
1519 dol_syslog(get_class($this).
"::insert_boxes onto page ".$key2.
"=".$val2, LOG_DEBUG);
1520 $resql = $this->db->query($sql);
1528 $this->db->commit();
1530 $this->error = $this->db->lasterror();
1531 $this->db->rollback();
1536 $this->error = $this->db->lasterror();
1559 if (is_array($this->boxes)) {
1560 foreach ($this->boxes as $key => $value) {
1562 if (empty($this->boxes[$key][
'file'])) {
1563 $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] :
'';
1565 $file = $this->boxes[$key][
'file'];
1573 if ($file ==
'box_graph_product_distribution.php') {
1575 dol_syslog(
"We discard deleting module ".$file.
" because another module still active requires it.");
1580 if ($this->db->type ==
'sqlite3') {
1583 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes ";
1584 $sql .=
"WHERE ".MAIN_DB_PREFIX.
"boxes.box_id IN (";
1585 $sql .=
"SELECT ".MAIN_DB_PREFIX.
"boxes_def.rowid ";
1586 $sql .=
"FROM ".MAIN_DB_PREFIX.
"boxes_def ";
1587 $sql .=
"WHERE ".MAIN_DB_PREFIX.
"boxes_def.file = '".$this->db->escape($file).
"') ";
1588 $sql .=
"AND ".MAIN_DB_PREFIX.
"boxes.entity = ".
$conf->entity;
1590 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes";
1591 $sql .=
" USING ".MAIN_DB_PREFIX.
"boxes, ".MAIN_DB_PREFIX.
"boxes_def";
1592 $sql .=
" WHERE ".MAIN_DB_PREFIX.
"boxes.box_id = ".MAIN_DB_PREFIX.
"boxes_def.rowid";
1593 $sql .=
" AND ".MAIN_DB_PREFIX.
"boxes_def.file = '".$this->db->escape($file).
"'";
1594 $sql .=
" AND ".MAIN_DB_PREFIX.
"boxes.entity = ".
$conf->entity;
1597 dol_syslog(get_class($this).
"::delete_boxes", LOG_DEBUG);
1598 $resql = $this->db->query($sql);
1600 $this->error = $this->db->lasterror();
1604 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes_def";
1605 $sql .=
" WHERE file = '".$this->db->escape($file).
"'";
1606 $sql .=
" AND entity = ".$conf->entity;
1608 dol_syslog(get_class($this).
"::delete_boxes", LOG_DEBUG);
1609 $resql = $this->db->query($sql);
1611 $this->error = $this->db->lasterror();
1629 include_once DOL_DOCUMENT_ROOT .
'/core/class/infobox.class.php';
1630 include_once DOL_DOCUMENT_ROOT .
'/cron/class/cronjob.class.php';
1631 include_once DOL_DOCUMENT_ROOT .
'/user/class/user.class.php';
1633 global
$conf, $user;
1636 $user =
new User($this->db);
1641 if (is_array($this->cronjobs)) {
1642 dol_syslog(get_class($this) .
"::insert_cronjobs", LOG_DEBUG);
1644 foreach ($this->cronjobs as $key => $value) {
1647 $entity = isset($value[
'entity']) ? $value[
'entity'] :
$conf->entity;
1648 $label = isset($value[
'label']) ? $value[
'label'] :
'';
1649 $jobtype = isset($value[
'jobtype']) ? $value[
'jobtype'] :
'';
1650 $classesname = isset($value[
'class']) ? $value[
'class'] :
'';
1651 $objectname = isset($value[
'objectname']) ? $value[
'objectname'] :
'';
1652 $methodename = isset($value[
'method']) ? $value[
'method'] :
'';
1653 $command = isset($value[
'command']) ? $value[
'command'] :
'';
1654 $params = isset($value[
'parameters']) ? $value[
'parameters'] :
'';
1655 $md5params = isset($value[
'md5params']) ? $value[
'md5params'] :
'';
1656 $comment = isset($value[
'comment']) ? $value[
'comment'] :
'';
1657 $frequency = isset($value[
'frequency']) ? $value[
'frequency'] :
'';
1658 $unitfrequency = isset($value[
'unitfrequency']) ? $value[
'unitfrequency'] :
'';
1659 $priority = isset($value[
'priority']) ? $value[
'priority'] :
'';
1660 $datestart = isset($value[
'datestart']) ? $value[
'datestart'] :
'';
1661 $dateend = isset($value[
'dateend']) ? $value[
'dateend'] :
'';
1662 $datenextrun = isset($value[
'datenextrun']) ? $value[
'datenextrun'] : $now;
1663 $status = isset($value[
'status']) ? $value[
'status'] :
'';
1664 $maxrun = isset($value[
'maxrun']) ? $value[
'maxrun'] : 0;
1665 $libname = isset($value[
'libname']) ? $value[
'libname'] :
'';
1666 $test = isset($value[
'test']) ? $value[
'test'] :
'';
1669 $sql =
"SELECT count(*) as nb FROM " . MAIN_DB_PREFIX .
"cronjob";
1671 $sql .=
" WHERE label = '".$this->db->escape($label).
"'";
1689 $sql .=
" AND entity = " . ((int) $entity);
1691 $result = $this->db->query($sql);
1693 $this->error = $this->db->lasterror();
1699 $obj = $this->db->fetch_object($result);
1704 $cronjob =
new Cronjob($this->db);
1706 $cronjob->entity = $entity;
1707 $cronjob->label = $label;
1708 $cronjob->jobtype = $jobtype;
1709 $cronjob->classesname = $classesname;
1710 $cronjob->objectname = $objectname;
1711 $cronjob->methodename = $methodename;
1712 $cronjob->command = $command;
1713 $cronjob->params = $params;
1714 $cronjob->md5params = $md5params;
1715 $cronjob->note_private = $comment;
1716 $cronjob->frequency = $frequency;
1717 $cronjob->unitfrequency = $unitfrequency;
1718 $cronjob->priority = $priority;
1719 $cronjob->datestart = $datestart;
1720 $cronjob->dateend = $dateend;
1721 $cronjob->datenextrun = $datenextrun;
1722 $cronjob->maxrun = $maxrun;
1723 $cronjob->status = $status;
1724 $cronjob->test = $test;
1725 $cronjob->libname = $libname;
1726 $cronjob->module_name = empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class;
1728 $retCreate = $cronjob->create($user);
1730 if ($retCreate < 0) {
1731 $this->error = implode(
"\n", array_merge([$cronjob->error], $cronjob->errors));
1753 if (is_array($this->cronjobs)) {
1754 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"cronjob";
1755 $sql .=
" WHERE module_name = '".$this->db->escape(empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class).
"'";
1756 $sql .=
" AND entity = ".$conf->entity;
1757 $sql .=
" AND test = '1'";
1760 dol_syslog(get_class($this).
"::delete_cronjobs", LOG_DEBUG);
1761 $resql = $this->db->query($sql);
1763 $this->error = $this->db->lasterror();
1784 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1785 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" LIKE '".$this->db->escape($this->const_name).
"_TABS_%'";
1786 $sql .=
" AND entity = ".((int)
$conf->entity);
1788 dol_syslog(get_class($this).
"::delete_tabs", LOG_DEBUG);
1789 if (!$this->db->query($sql)) {
1790 $this->error = $this->db->lasterror();
1810 if (!empty($this->tabs)) {
1811 dol_syslog(get_class($this).
"::insert_tabs", LOG_DEBUG);
1814 foreach ($this->tabs as $key => $value) {
1815 if (is_array($value) && count($value) == 0) {
1819 $entity =
$conf->entity;
1822 if (is_array($value)) {
1823 $newvalue = $value[
'data'];
1824 if (isset($value[
'entity'])) {
1825 $entity = $value[
'entity'];
1830 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (";
1835 $sql .=
", visible";
1838 $sql .=
" VALUES (";
1839 $sql .= $this->db->encrypt($this->const_name.
"_TABS_".$i);
1840 $sql .=
", 'chaine'";
1841 $sql .=
", ".$this->db->encrypt($newvalue);
1844 $sql .=
", ".((int) $entity);
1847 $resql = $this->db->query($sql);
1850 if ($this->db->lasterrno() !=
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1851 $this->error = $this->db->lasterror();
1852 $this->errors[] = $this->db->lasterror();
1877 if (empty($this->
const)) {
1883 foreach ($this->
const as $key => $value) {
1885 $name = $this->
const[$key][0];
1886 $entity = (!empty($this->
const[$key][5]) && $this->
const[$key][5] !=
'current') ? 0 :
$conf->entity;
1889 $type = $this->
const[$key][1];
1890 $val = $this->
const[$key][2];
1891 $note = isset($this->
const[$key][3]) ? $this->
const[$key][3] :
'';
1892 $visible = isset($this->
const[$key][4]) ? $this->
const[$key][4] : 0;
1895 if (empty($visible)) {
1898 if (empty($val) && $val !=
'0') {
1902 if (!empty($name)) {
1903 $sql =
"SELECT count(*) as nb";
1904 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1905 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
1906 $sql .=
" AND entity = ".((int) $entity);
1908 $result = $this->db->query($sql);
1910 $row = $this->db->fetch_row($result);
1913 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (name, type, value, note, visible, entity)";
1914 $sql .=
" VALUES (";
1915 $sql .= $this->db->encrypt($name);
1916 $sql .=
", '".$this->db->escape($type).
"'";
1917 $sql .=
", ".(($val !=
'') ? $this->db->encrypt($val) :
"''");
1918 $sql .=
", ".($note ?
"'".$this->db->escape($note).
"'" :
"null");
1919 $sql .=
", '".$this->db->escape($visible).
"'";
1920 $sql .=
", ".((int) $entity);
1923 if (!$this->db->query($sql)) {
1927 $conf->global->$name = $val;
1930 dol_syslog(__METHOD__.
" constant '".$name.
"' already exists", LOG_DEBUG);
1954 if (empty($this->
const)) {
1958 foreach ($this->
const as $key => $value) {
1959 $name = $this->
const[$key][0];
1960 $deleteonunactive = (!empty($this->
const[$key][6])) ? 1 : 0;
1962 if ($deleteonunactive) {
1963 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1964 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
1965 $sql .=
" AND entity in (0, ".$conf->entity.
")";
1966 dol_syslog(get_class($this).
"::delete_const", LOG_DEBUG);
1967 if (!$this->db->query($sql)) {
1968 $this->error = $this->db->lasterror();
1989 global
$conf, $user;
1992 $entity = (!empty($force_entity) ? $force_entity :
$conf->entity);
1994 dol_syslog(get_class($this).
"::insert_permissions", LOG_DEBUG);
1997 $sql_del =
"SELECT ".$this->db->decrypt(
'value').
" as value";
1998 $sql_del .=
" FROM ".MAIN_DB_PREFIX.
"const";
1999 $sql_del .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
2000 $sql_del .=
" AND entity IN (0,".((int) $entity).
")";
2002 $resql = $this->db->query($sql_del);
2005 $obj = $this->db->fetch_object($resql);
2007 if ($obj !==
null && !empty($obj->value) && !empty($this->rights)) {
2008 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
2011 foreach ($this->rights as $key => $value) {
2012 $r_id = $this->rights[$key][self::KEY_ID];
2013 $r_label = $this->rights[$key][self::KEY_LABEL];
2014 $r_type = $this->rights[$key][self::KEY_TYPE] ??
'w';
2015 $r_default = $this->rights[$key][self::KEY_DEFAULT] ?? 0;
2016 $r_perms = $this->rights[$key][self::KEY_FIRST_LEVEL] ??
'';
2017 $r_subperms = $this->rights[$key][self::KEY_SECOND_LEVEL] ??
'';
2020 $r_family = $this->family;
2021 $r_family_position = 0;
2024 if (empty($r_perms)) {
2029 $r_module = (empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class);
2032 $r_module_origin =
'';
2034 if (isset($this->rights[$key][self::KEY_MODULE])) {
2036 $r_module = $this->rights[$key][self::KEY_MODULE];
2038 $r_module_origin = (empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class);
2042 $r_enabled = $this->rights[$key][self::KEY_ENABLED] ??
'1';
2045 $sql =
"SELECT count(*) as nb FROM ".MAIN_DB_PREFIX.
"rights_def";
2046 $sql .=
" WHERE entity = ".((int) $entity);
2047 $sql .=
" AND id = ".((int) $r_id);
2049 $resqlselect = $this->db->query($sql);
2051 $objcount = $this->db->fetch_object($resqlselect);
2052 if ($objcount && $objcount->nb == 0) {
2053 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"rights_def (";
2056 $sql .=
", libelle";
2058 $sql .=
", module_origin";
2059 $sql .=
", module_position";
2061 $sql .=
", family_position";
2063 $sql .=
", bydefault";
2065 $sql .=
", subperms";
2066 $sql .=
", enabled";
2067 $sql .=
") VALUES (";
2068 $sql .= ((int) $r_id);
2069 $sql .=
", ".((int) $entity);
2070 $sql .=
", '".$this->db->escape($r_label).
"'";
2071 $sql .=
", '".$this->db->escape($r_module).
"'";
2072 $sql .=
", '".$this->db->escape($r_module_origin).
"'";
2073 $sql .=
", '".$this->db->escape((
string) $r_module_position).
"'";
2074 $sql .=
", '".$this->db->escape($r_family).
"'";
2075 $sql .=
", '".$this->db->escape((
string) $r_family_position).
"'";
2076 $sql .=
", '".$this->db->escape($r_type).
"'";
2077 $sql .=
", ".((int) $r_default);
2078 $sql .=
", '".$this->db->escape($r_perms).
"'";
2079 $sql .=
", '".$this->db->escape($r_subperms).
"'";
2080 $sql .=
", '".$this->db->escape($r_enabled).
"'";
2083 $resqlinsert = $this->db->query($sql, 1);
2085 if (!$resqlinsert) {
2086 if ($this->db->errno() !=
"DB_ERROR_RECORD_ALREADY_EXISTS") {
2087 $this->error = $this->db->lasterror();
2091 dol_syslog(get_class($this).
"::insert_permissions record already exists", LOG_INFO);
2095 $this->db->free($resqlinsert);
2098 $this->db->free($resqlselect);
2102 if (!empty($reinitadminperms)) {
2103 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"user WHERE admin = 1";
2104 dol_syslog(get_class($this).
"::insert_permissions Search all admin users", LOG_DEBUG);
2106 $resqlseladmin = $this->db->query($sql, 1);
2108 if ($resqlseladmin) {
2109 $num = $this->db->num_rows($resqlseladmin);
2112 $obj2 = $this->db->fetch_object($resqlseladmin);
2113 dol_syslog(get_class($this).
"::insert_permissions Add permission id ".$r_id.
" to user id=".$obj2->rowid);
2115 $tmpuser =
new User($this->db);
2116 $result = $tmpuser->fetch($obj2->rowid);
2118 $tmpuser->addrights($r_id,
'',
'', 0, 1);
2120 dol_syslog(get_class($this).
"::insert_permissions Failed to add the permission to user because fetch return an error", LOG_ERR);
2130 if (!empty($reinitadminperms) && !empty($user->admin)) {
2132 $user->clearrights();
2133 $user->loadRights();
2136 $this->db->free($resql);
2138 $this->error = $this->db->lasterror();
2159 $module = empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class;
2161 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"rights_def";
2162 $sql .=
" WHERE (module = '".$this->db->escape($module).
"' OR module_origin = '".$this->db->escape($module).
"')";
2165 if (empty($this->core_enabled)) {
2166 $sql .=
" AND entity = ".((int)
$conf->entity);
2169 dol_syslog(get_class($this).
"::delete_permissions", LOG_DEBUG);
2170 if (!$this->db->query($sql)) {
2171 $this->error = $this->db->lasterror();
2188 global
$conf, $user;
2190 if (!is_array($this->menu) || empty($this->menu)) {
2194 include_once DOL_DOCUMENT_ROOT.
'/core/class/menubase.class.php';
2196 dol_syslog(get_class($this).
"::insert_menus", LOG_DEBUG);
2201 $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 :
$conf->entity);
2205 foreach ($this->menu as $key => $value) {
2207 $menu->menu_handler =
'all';
2210 $menu->module = (empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class);
2212 if (!$this->menu[$key][
'fk_menu']) {
2216 $fk_parent = $this->menu[$key][
'fk_menu'];
2218 if (preg_match(
'/^r=/', $fk_parent)) {
2219 $fk_parent = str_replace(
'r=',
'', $fk_parent);
2220 if (isset($this->menu[$fk_parent][
'rowid'])) {
2221 $menu->fk_menu = $this->menu[$fk_parent][
'rowid'];
2224 } elseif (preg_match(
'/^fk_mainmenu=([a-zA-Z0-9_]+),fk_leftmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) {
2225 $menu->fk_menu = -1;
2226 $menu->fk_mainmenu = $reg[1];
2227 $menu->fk_leftmenu = $reg[2];
2229 } elseif (preg_match(
'/^fk_mainmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) {
2230 $menu->fk_menu = -1;
2231 $menu->fk_mainmenu = $reg[1];
2232 $menu->fk_leftmenu =
'';
2235 if (!$foundparent) {
2236 $this->error =
"ErrorBadDefinitionOfMenuArrayInModuleDescriptor";
2237 dol_syslog(get_class($this).
"::insert_menus ".$this->error.
" ".$this->menu[$key][
'fk_menu'], LOG_ERR);
2241 $menu->type = $this->menu[$key][
'type'];
2242 $menu->mainmenu = isset($this->menu[$key][
'mainmenu']) ? $this->menu[$key][
'mainmenu'] : (isset($menu->fk_mainmenu) ? $menu->fk_mainmenu :
'');
2243 $menu->leftmenu = isset($this->menu[$key][
'leftmenu']) ? $this->menu[$key][
'leftmenu'] :
'';
2244 $menu->title = $this->menu[$key][
'titre'];
2245 $menu->prefix = isset($this->menu[$key][
'prefix']) ? $this->menu[$key][
'prefix'] :
'';
2246 $menu->url = $this->menu[$key][
'url'];
2247 $menu->langs = isset($this->menu[$key][
'langs']) ? $this->menu[$key][
'langs'] :
'';
2248 $menu->position = $this->menu[$key][
'position'];
2249 $menu->perms = $this->menu[$key][
'perms'];
2250 $menu->target = isset($this->menu[$key][
'target']) ? $this->menu[$key][
'target'] :
'';
2251 $menu->user = $this->menu[$key][
'user'];
2252 $menu->enabled = isset($this->menu[$key][
'enabled']) ? $this->menu[$key][
'enabled'] : 0;
2253 $menu->position = $this->menu[$key][
'position'];
2254 $menu->entity = $entity;
2257 $result = $menu->create($user);
2259 $this->menu[$key][
'rowid'] = $result;
2261 $this->error = $menu->error;
2262 dol_syslog(get_class($this).
'::insert_menus result='.$result.
" ".$this->error, LOG_ERR);
2270 $this->db->commit();
2272 dol_syslog(get_class($this).
"::insert_menus ".$this->error, LOG_ERR);
2273 $this->db->rollback();
2294 $module = empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class;
2296 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"menu";
2297 $sql .=
" WHERE module = '".$this->db->escape($module).
"'";
2298 $sql .=
" AND menu_handler = 'all'";
2299 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
2301 dol_syslog(get_class($this).
"::delete_menus", LOG_DEBUG);
2302 $resql = $this->db->query($sql);
2304 $this->error = $this->db->lasterror();
2320 global $langs,
$conf;
2325 if (isset($this->dirs) && is_array($this->dirs)) {
2326 foreach ($this->dirs as $key => $value) {
2329 if (!is_array($value)) {
2332 $constname = $this->const_name.
"_DIR_";
2333 $dir = $this->dirs[$key][1];
2334 $addtodatabase = empty($this->dirs[$key][2]) ?
'' : $this->dirs[$key][2];
2335 $subname = empty($this->dirs[$key][3]) ?
'' : strtoupper($this->dirs[$key][3]);
2336 $forcename = empty($this->dirs[$key][4]) ?
'' : strtoupper($this->dirs[$key][4]);
2338 if (!empty($forcename)) {
2339 $constname =
'MAIN_MODULE_'.$forcename.
"_DIR_";
2341 if (!empty($subname)) {
2342 $constname = $constname.$subname.
"_";
2345 $name = $constname.strtoupper($this->dirs[$key][0]);
2350 $fulldir = DOL_DATA_ROOT.$dir;
2352 $fulldir = DOL_DATA_ROOT.
"/".
$conf->entity.$dir;
2355 if (!empty($fulldir) && !file_exists($fulldir)) {
2356 if (
dol_mkdir($fulldir, DOL_DATA_ROOT) < 0) {
2357 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $fulldir);
2358 dol_syslog(get_class($this).
"::_init ".$this->error, LOG_ERR);
2364 if (!empty($addtodatabase) && !empty($name)) {
2393 $sql =
"SELECT count(*)";
2394 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
2395 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
2396 $sql .=
" AND entity = ".$conf->entity;
2398 dol_syslog(get_class($this).
"::insert_dirs", LOG_DEBUG);
2399 $result = $this->db->query($sql);
2401 $row = $this->db->fetch_row($result);
2404 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (name, type, value, note, visible, entity)";
2405 $sql .=
" VALUES (".$this->db->encrypt($name).
", 'chaine', ".$this->db->encrypt($dir).
", '".$this->db->escape(
"Directory for module ".$this->
name).
"', '0', ".((int)
$conf->entity).
")";
2407 dol_syslog(get_class($this).
"::insert_dirs", LOG_DEBUG);
2408 $this->db->query($sql);
2411 $this->error = $this->db->lasterror();
2432 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
2433 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" LIKE '".$this->db->escape($this->const_name).
"_DIR_%'";
2434 $sql .=
" AND entity = ".$conf->entity;
2436 dol_syslog(get_class($this).
"::delete_dirs", LOG_DEBUG);
2437 if (!$this->db->query($sql)) {
2438 $this->error = $this->db->lasterror();
2455 global
$conf, $langs;
2459 if (is_array($this->module_parts)) {
2460 if (empty($this->module_parts[
'icon']) && !empty($this->picto) && preg_match(
'/^fa\-/', $this->picto)) {
2461 $this->module_parts[
'icon'] = $this->picto;
2464 foreach ($this->module_parts as $key => $value) {
2465 if (is_array($value) && count($value) == 0) {
2470 if ($key ==
'websitetemplates' && $value == 1) {
2474 $docs =
dol_dir_list($srcroot,
'directories', 0,
'website_.*$');
2475 foreach ($docs as $cursorfile) {
2476 $src = $srcroot.
'/'.$cursorfile[
'name'];
2477 $dest = DOL_DATA_ROOT.
'/doctemplates/websites/'.$cursorfile[
'name'];
2484 $result = dol_compress_dir($src, $dest.
'.zip',
'zip');
2487 $this->error = ($errormsg ? $errormsg : $langs->trans(
'ErrorFailToCreateZip', $dest));
2488 $this->errors[] = ($errormsg ? $errormsg : $langs->trans(
'ErrorFailToCreateZip', $dest));
2493 $docs =
dol_dir_list($srcroot,
'files', 0,
'website_.*\.jpg$');
2494 foreach ($docs as $cursorfile) {
2495 $src = $srcroot.
'/'.$cursorfile[
'name'];
2496 $dest = DOL_DATA_ROOT.
'/doctemplates/websites/'.$cursorfile[
'name'];
2502 $entity =
$conf->entity;
2506 if (is_array($value)) {
2509 if (isset($value[
'data']) && is_array($value[
'data'])) {
2510 $newvalue = json_encode($value[
'data']);
2511 if (isset($value[
'entity'])) {
2512 $entity = $value[
'entity'];
2514 } elseif (isset($value[
'data']) && !is_array($value[
'data'])) {
2515 $newvalue = $value[
'data'];
2516 if (isset($value[
'entity'])) {
2517 $entity = $value[
'entity'];
2520 $newvalue = json_encode($value);
2524 if (!empty($newvalue)) {
2525 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (";
2530 $sql .=
", visible";
2533 $sql .=
" VALUES (";
2534 $sql .=
" ".$this->db->encrypt($this->const_name.
"_".strtoupper($key), 1);
2535 $sql .=
", 'chaine'";
2536 $sql .=
", ".$this->db->encrypt($newvalue, 1);
2539 $sql .=
", ".((int) $entity);
2542 dol_syslog(get_class($this).
"::insert_module_parts for key=".$this->const_name.
"_".strtoupper($key), LOG_DEBUG);
2544 $resql = $this->db->query($sql, 1);
2546 if ($this->db->lasterrno() !=
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2548 $this->error = $this->db->lasterror();
2550 dol_syslog(get_class($this).
"::insert_module_parts for ".$this->const_name.
"_".strtoupper($key).
" Record already exists.", LOG_WARNING);
2572 if (is_array($this->module_parts)) {
2573 dol_syslog(get_class($this).
"::delete_module_parts", LOG_DEBUG);
2575 if (empty($this->module_parts[
'icon']) && !empty($this->picto) && preg_match(
'/^fa\-/', $this->picto)) {
2576 $this->module_parts[
'icon'] = $this->picto;
2579 foreach ($this->module_parts as $key => $value) {
2581 if (is_array($value) && isset($value[
'entity'])) {
2582 $entity = $value[
'entity'];
2584 $entity =
$conf->entity;
2587 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
2588 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" LIKE '".$this->db->escape($this->const_name).
"_".strtoupper($key).
"'";
2589 $sql .=
" AND entity = ".((int) $entity);
2591 if (!$this->db->query($sql)) {
2592 $this->error = $this->db->lasterror();
2609 public function init($options =
'')
2611 return $this->
_init(array(), $options);
2622 public function remove($options =
'')
2624 return $this->
_remove(array(), $options);
2642 $imginfo =
"info_black";
2645 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($this)));
2649 if (preg_match(
'/development/i', $version)) {
2650 $versiontrans .=
'warning';
2652 if (preg_match(
'/experimental/i', $version)) {
2653 $versiontrans .=
'warning';
2655 if (preg_match(
'/deprecated/i', $version)) {
2656 $versiontrans .=
'warning';
2660 <div class="box-flex-item info-box-module'
2661 .(getDolGlobalString($const_name) ?
'' :
' --disabled')
2663 .($this->needUpdate ?
' --need-update' :
'')
2665 <div class="info-box info-box-sm info-box-module">
2666 <div class="info-box-icon'.(!
getDolGlobalString($const_name) ?
'' :
' info-box-icon-module-enabled'.($versiontrans ?
' info-box-icon-module-warning' :
'')).
'">';
2671 if (!empty($this->picto)) {
2672 if (preg_match(
'/^\//i', $this->picto)) {
2673 $return .=
img_picto($alttext, $this->picto,
'class="inline-block valignmiddle"', 1);
2675 $return .=
img_object($alttext, $this->picto,
'class="inline-block valignmiddle"');
2678 $return .=
img_object($alttext,
'generic',
'class="inline-block valignmiddle"');
2681 if ($this->
isCoreOrExternalModule() ==
'external' || preg_match(
'/development|experimental|deprecated/i', $version)) {
2682 $versionTitle = $langs->trans(
"Version").
' '.$this->
getVersion(1);
2683 if ($this->needUpdate) {
2684 $versionTitle .=
'<br>'.$langs->trans(
'ModuleUpdateAvailable').
' : '.$this->lastVersion;
2687 $return .=
'<span class="info-box-icon-version'.($versiontrans ?
' '.$versiontrans :
'').
' classfortooltip" title="'.
dol_escape_js($versionTitle).
'" >';
2689 $return .=
'</span>';
2693 <div class="info-box-content info-box-text-module'.(!
getDolGlobalString($const_name) ?
'' :
' info-box-module-enabled'.($versiontrans ?
' info-box-content-warning' :
'')).
'">
2694 <span class="info-box-title noopacity">'.$this->
getName().
'</span>
2697 $return .=
'<div class="valignmiddle inline-block info-box-more">';
2699 $return .=
'<a class="valignmiddle inline-block" href="javascript:document_preview(\''.DOL_URL_ROOT.
'/admin/modulehelp.php?id='.((int) $this->numero).
'\',\
'text/html\',\''.dol_escape_js($langs->trans(
"Module")).
'\')
">'.img_picto(($this->isCoreOrExternalModule() == 'external' ? $langs->trans("ExternalModule
").' - ' : '').$langs->trans("ClickToShowDescription
"), $imginfo).'</a>';
2700 $return .= '</div><br>';
2702 $return .= '<div class="valignmiddle
inline-block info-box-actions
">';
2703 $return .= '<div class="valignmiddle
inline-block info-box-setup
">';
2704 $return .= $codetoconfig;
2705 $return .= '</div>';
2706 $return .= '<div class="valignmiddle
inline-block marginleftonly marginrightonly
">';
2707 $return .= $codeenabledisable;
2708 $return .= '</div>';
2709 $return .= '</div>';
2712 </div><!-- /.info-box-content -->
2713 </div><!-- /.info-box -->
2727 public function checkForUpdate()
2729 require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
2730 if (!empty($this->url_last_version)) {
2731 $lastVersion = getURLContent($this->url_last_version, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only
2732 if (isset($lastVersion['content']) && strlen($lastVersion['content']) < 30) {
2733 // Security warning : be careful with remote data content, the module editor could be hacked (or evil) so limit to a-z A-Z 0-9 _ . -
2734 $this->lastVersion = preg_replace("/[^a-zA-Z0-9_\.\-]+/
", "", $lastVersion['content']);
2735 if (version_compare($this->lastVersion, $this->version) > 0) {
2736 $this->needUpdate = true;
2739 $this->needUpdate = false;
2756 public function checkForCompliance($nametocheck = '')
2758 global $conf, $langs;
2760 if (empty($nametocheck)) {
2761 $nametocheck = $this->name;
2764 // Get list of illegal modules name or ID
2765 if (empty($conf->cache['noncompliantmodules'])) {
2766 require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
2768 $result = getURLContent(self::URL_FOR_BLACKLISTED_MODULES, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only
2769 if (isset($result['content']) && $result['http_code'] == 200) {
2770 $langs->load("errors
");
2772 // Security warning : be careful with remote data content, the module editor could be hacked (or evil) so limit to a-z A-Z 0-9 _ . -
2773 $arrayoflines = preg_split("/[\n,]/
", $result['content']);
2774 foreach ($arrayoflines as $line) {
2775 $tmpfieldsofline = explode(';', $line);
2776 $modulekey = strtolower(trim($tmpfieldsofline[0]));
2777 if (empty($modulekey)) {
2780 $conf->cache['noncompliantmodules'][$modulekey]['name'] = trim($tmpfieldsofline[0]);
2781 $conf->cache['noncompliantmodules'][$modulekey]['id'] = (isset($tmpfieldsofline[1]) ? trim($tmpfieldsofline[1]) : '');
2782 $conf->cache['noncompliantmodules'][$modulekey]['signature'] = (isset($tmpfieldsofline[2]) ? trim($tmpfieldsofline[2]) : '');
2783 $conf->cache['noncompliantmodules'][$modulekey]['message'] = $langs->trans(empty(isset($tmpfieldsofline[3]) ? trim($tmpfieldsofline[3]) : '') ? 'WarningModuleAffiliatedToAReportedCompany' : trim($tmpfieldsofline[3]));
2784 if (!empty($tmpfieldsofline[4])) {
2785 $message2 = $langs->trans("WarningModuleAffiliatedToAPiratPlatform
", '{s}');
2786 $listofillegalurl = '';
2787 foreach (explode(" ", $tmpfieldsofline[4]) as $illegalurl) {
2788 $listofillegalurl .= ($listofillegalurl ? ' '.$langs->trans("or
").' ' : '').'<b>'.preg_replace('/[^a-z0-9\.\-]/', '', $illegalurl).'</b>';
2790 $message2 = str_replace('{s}', $listofillegalurl, $message2);
2791 $conf->cache['noncompliantmodules'][$modulekey]['message2'] = $message2;
2797 if (!empty($conf->cache['noncompliantmodules'])) {
2798 $modulekey = strtolower($nametocheck);
2799 if (in_array($modulekey, array_keys($conf->cache['noncompliantmodules']))) {
2800 $answer = trim($conf->cache['noncompliantmodules'][$modulekey]['message']);
2801 if (!empty($conf->cache['noncompliantmodules'][$modulekey]['message2'])) {
2802 $answer .= '<br>'.$conf->cache['noncompliantmodules'][$modulekey]['message2'];
2829 protected function declareNewDictionary($dictionaryArray, $langs = '')
2831 $fields = array('name', 'lib', 'sql', 'sqlsort', 'field', 'fieldvalue', 'fieldinsert', 'rowid', 'cond', 'help', 'fieldcheck');
2833 foreach ($fields as $field) {
2834 if (isset($dictionaryArray[$field])) {
2835 // @phan-suppress-next-line PhanTypeMismatchProperty
2836 $this->dictionaries['tab'.$field][] = $dictionaryArray[$field];
2839 if ($langs && !in_array($langs, $this->dictionaries[$langs])) {
2840 $this->dictionaries['langs'][] = $langs;
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.
delete_permissions()
Removes access rights.
getImportDatasetLabel($r)
Gives translated label of an import dataset.
_init($array_sql, $options='')
Enables a module.
getLastActivationDate()
Gives the last date of activation.
delete_cronjobs()
Removes boxes.
getKanbanView($codeenabledisable='', $codetoconfig='')
Return Kanban view of a module.
getModulePosition()
Gives the module position.
insert_const()
Adds constants.
__construct($db)
Constructor.
delete_boxes()
Removes boxes.
isCoreOrExternalModule()
Tells if module is core or external.
getDescLongReadmeFound()
Return path of file if a README file was found.
insert_permissions($reinitadminperms=0, $force_entity=null, $notrigger=0)
Adds access rights.
delete_menus()
Removes menu entries.
delete_const()
Removes constants tagged 'deleteonunactive'.
_active()
Insert constants for module activation.
_remove($array_sql, $options='')
Disable function.
getDescLong()
Gives the long description of a module.
insert_boxes($option='')
Adds boxes.
getDesc($foruseinpopupdesc=0)
Gives the translated module description if translation exists in admin.lang or the default module des...
getPublisher()
Gives the publisher name.
getChangeLog()
Gives the changelog.
insert_cronjobs()
Adds cronjobs.
create_dirs()
Creates directories.
delete_module_parts()
Removes generic parts.
getVersion($translated=1)
Gives module version (translated if param $translated is on) For 'experimental' modules,...
_unactive()
Module deactivation.
delete_tabs()
Removes tabs.
getExportDatasetLabel($r)
Gives translated label of an export dataset.
getName()
Gives the translated module name if translation exists in admin.lang or into language files of module...
_load_tables($reldir, $onlywithsuffix='')
Create tables and keys required by module:
insert_dirs($name, $dir)
Adds directories definitions.
getLangFilesArray()
Gives module related language files list.
insert_menus()
Adds menu entries.
insert_module_parts()
Save configuration for generic features.
getPublisherUrl()
Gives the publisher url.
getLastActivationInfo()
Gives the last author of activation.
delete_dirs()
Removes directories.
init($options='')
Function called when module is enabled.
static getListOfPagesForBoxes()
Name of positions (See below)
Class to manage Dolibarr users.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_copy($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=0)
Copy a file to another file.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_is_file($pathoffile)
Return if path is a file.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_now($mode='gmt')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
dolMd2Html($content, $parser='parsedown', $replaceimagepath=null)
Function to parse MD content into HTML.
$conf db name
Only used if Module[ID]Name translation string is not found.