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://ping.dolibarr.org/modules-blacklist.txt';
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();
213 public $lastVersion =
'';
219 public $needUpdate =
false;
234 public $descriptionlong;
239 public $dictionaries = array();
256 public $export_label;
266 public $export_enabled;
270 public $export_permission;
274 public $export_fields_array;
278 public $export_TypeFields_array;
282 public $export_entities_array;
286 public $export_aggregate_array;
290 public $export_examplevalues_array;
294 public $export_help_array;
301 public $export_special_array;
308 public $export_dependencies_array;
312 public $export_sql_start;
316 public $export_sql_end;
320 public $export_sql_order;
333 public $import_label;
342 public $import_entities_array;
346 public $import_tables_array;
350 public $import_tables_creator_array;
354 public $import_fields_array;
358 public $import_fieldshidden_array;
362 public $import_convertvalue_array;
366 public $import_regex_array;
370 public $import_examplevalues_array;
374 public $import_updatekeys_array;
378 public $import_run_sql_after_array;
382 public $import_TypeFields_array;
386 public $import_help_array;
396 public $always_enabled;
406 public $automatic_activation = array();
411 public $core_enabled;
427 public $config_page_url;
450 public $conflictwith;
462 public $warnings_activation;
469 public $warnings_activation_ext;
476 public $warnings_unactivation;
493 public $need_dolibarr_version;
499 public $max_dolibarr_version;
504 public $need_javascript_ajax;
509 public $enabled_bydefault;
514 public $hidden =
false;
519 public $url_last_version;
548 protected function _init($array_sql, $options =
'')
572 if (!$err && !preg_match(
'/newboxdefonly/', $options)) {
577 if (!$err && !preg_match(
'/noboxes/', $options)) {
602 $num = count($array_sql);
603 for ($i = 0; $i < $num; $i++) {
605 $val = $array_sql[$i];
608 if (is_array($val)) {
610 $ignoreerror = $val[
'ignoreerror'] ?? 0;
613 $sql = str_replace(
'__ENTITY__', (
string) $conf->entity, $sql);
615 dol_syslog(get_class($this).
"::_init ignoreerror=".$ignoreerror, LOG_DEBUG);
616 $result = $this->db->query($sql, $ignoreerror);
619 $this->error = $this->db->lasterror();
622 dol_syslog(get_class($this).
"::_init Warning ".$this->db->lasterror(), LOG_WARNING);
632 $moduleNameInConf = strtolower(preg_replace(
'/^MAIN_MODULE_/',
'', $this->const_name));
634 if ($moduleNameInConf ===
'propale') {
635 $moduleNameInConf =
'propal';
636 } elseif ($moduleNameInConf ===
'supplierproposal') {
637 $moduleNameInConf =
'supplier_proposal';
640 $conf->modules[$moduleNameInConf] = $moduleNameInConf;
644 $this->db->rollback();
658 protected function _remove($array_sql, $options =
'')
687 if (!$err && !preg_match(
'/(newboxdefonly|noboxes)/', $options)) {
712 $num = count((array) $array_sql);
713 for ($i = 0; $i < $num; $i++) {
715 dol_syslog(get_class($this).
"::_remove", LOG_DEBUG);
716 $result = $this->db->query($array_sql[$i]);
718 $this->error = $this->db->error();
729 $moduleNameInConf = strtolower(preg_replace(
'/^MAIN_MODULE_/',
'', $this->const_name));
731 if ($moduleNameInConf ===
'propale') {
732 $moduleNameInConf =
'propal';
733 } elseif ($moduleNameInConf ===
'supplierproposal') {
734 $moduleNameInConf =
'supplier_proposal';
737 unset($conf->modules[$moduleNameInConf]);
741 $this->db->rollback();
756 $langs->load(
"admin");
758 if ($langs->transnoentitiesnoconv(
"Module".$this->numero.
"Name") !=
"Module".$this->numero.
"Name") {
760 return $langs->transnoentitiesnoconv(
"Module".$this->numero.
"Name");
763 if (is_array($this->langfiles)) {
764 foreach ($this->langfiles as $val) {
771 if ($langs->trans(
"Module".$this->name.
"Name") !=
"Module".$this->name.
"Name") {
773 return $langs->transnoentitiesnoconv(
"Module".$this->
name.
"Name");
777 return $langs->transnoentitiesnoconv($this->
name);
788 public function getDesc($foruseinpopupdesc = 0)
791 $langs->load(
"admin");
793 if ($langs->transnoentitiesnoconv(
"Module".$this->numero.
"Desc") !=
"Module".$this->numero.
"Desc") {
795 return $langs->transnoentitiesnoconv(
"Module".$this->numero.
"Desc");
798 if (is_array($this->langfiles)) {
799 foreach ($this->langfiles as $val) {
806 if ($langs->transnoentitiesnoconv(
"Module".$this->name.
"Desc") !=
"Module".$this->name.
"Desc") {
808 return $langs->trans(
"Module".$this->
name.
"Desc");
825 $langs->load(
"admin");
827 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
828 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
834 $content = file_get_contents($pathoffile,
false,
null, 0, 1024 * 1024);
836 if ((
float) DOL_VERSION >= 6.0) {
837 @include_once DOL_DOCUMENT_ROOT.
'/core/lib/parsemd.lib.php';
849 $content = preg_replace(
'/<a href="/',
'<a target="_blank" rel="noopener noreferrer" href="', $content);
851 $content = nl2br($content);
855 if (!empty($this->descriptionlong)) {
856 if (is_array($this->langfiles)) {
857 foreach ($this->langfiles as $val) {
864 $content = $langs->transnoentitiesnoconv($this->descriptionlong);
868 return '<div class="moduledesclong">'.$content.
'</div>';
884 $pathoffile =
dol_buildpath(strtolower($this->
name).
'/README-'.$langs->defaultlang.
'.md', 0);
889 $tmp = explode(
'_', $langs->defaultlang);
890 $pathoffile =
dol_buildpath(strtolower($this->
name).
'/README-'.$tmp[0].
'.md', 0);
902 return ($filefound ? $pathoffile :
'');
914 $langs->load(
"admin");
916 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
917 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
923 $pathoffile =
dol_buildpath(strtolower($this->
name).
'/ChangeLog-'.$langs->defaultlang.
'.md', 0);
935 $content = file_get_contents($pathoffile);
937 if ((
float) DOL_VERSION >= 6.0) {
938 @include_once DOL_DOCUMENT_ROOT.
'/core/lib/parsemd.lib.php';
942 $content = nl2br($content);
958 return $this->editor_name;
968 return $this->editor_url;
982 $langs->load(
"admin");
986 $newversion = preg_replace(
'/_deprecated/',
'', $this->version);
987 if ($newversion ==
'experimental') {
988 $ret = ($translated ? $langs->transnoentitiesnoconv(
"VersionExperimental") : $newversion);
989 } elseif ($newversion ==
'development') {
990 $ret = ($translated ? $langs->transnoentitiesnoconv(
"VersionDevelopment") : $newversion);
991 } elseif ($newversion ==
'dolibarr') {
993 } elseif ($newversion) {
996 $ret = ($translated ? $langs->transnoentitiesnoconv(
"VersionUnknown") :
'unknown');
999 if (preg_match(
'/_deprecated/', $this->version)) {
1000 $ret .= ($translated ?
' ('.$langs->transnoentitiesnoconv(
"Deprecated").
')' : $this->version);
1012 if (in_array($this->version, array(
'dolibarr',
'dolibarr_deprecated',
'experimental',
'development'))) {
1013 return $this->module_position;
1015 if ($this->module_position >= 100000) {
1016 return $this->module_position;
1018 $position = intval($this->module_position) + 100000;
1019 return strval($position);
1032 if ($this->version ==
'dolibarr' || $this->version ==
'dolibarr_deprecated') {
1035 if (!empty($this->version) && !in_array($this->version, array(
'experimental',
'development'))) {
1038 if (!empty($this->editor_name) || !empty($this->editor_url)) {
1041 if ($this->numero >= 100000) {
1055 return $this->langfiles;
1069 $langstring =
"ExportDataset_".$this->export_code[$r];
1070 if ($langs->trans($langstring) == $langstring) {
1072 return $langs->trans($this->export_label[$r]);
1075 return $langs->trans($langstring);
1091 $langstring =
"ImportDataset_".$this->import_code[$r];
1093 if ($langs->trans($langstring) == $langstring) {
1095 return $langs->transnoentitiesnoconv($this->import_label[$r]);
1098 return $langs->transnoentitiesnoconv($langstring);
1114 $sql =
"SELECT tms FROM ".MAIN_DB_PREFIX.
"const";
1115 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1116 $sql .=
" AND entity IN (0, ".((int) $conf->entity).
")";
1118 dol_syslog(get_class($this).
"::getLastActiveDate", LOG_DEBUG);
1119 $resql = $this->db->query($sql);
1123 $obj = $this->db->fetch_object($resql);
1125 return $this->db->jdate($obj->tms);
1144 $sql =
"SELECT tms, note FROM ".MAIN_DB_PREFIX.
"const";
1145 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1146 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
1148 dol_syslog(get_class($this).
"::getLastActiveDate", LOG_DEBUG);
1149 $resql = $this->db->query($sql);
1153 $obj = $this->db->fetch_object($resql);
1157 $tmp = json_decode($obj->note,
true);
1160 'authorid' => empty($tmp[
'authorid']) ?
'' : (int) $tmp[
'authorid'],
1161 'ip' => empty($tmp[
'ip']) ?
'' : (string) $tmp[
'ip'],
1162 'lastactivationdate' => $this->db->jdate($obj->tms),
1163 'lastactivationversion' => (!empty($tmp[
'lastactivationversion']) ? (string) $tmp[
'lastactivationversion'] :
'unknown'),
1181 global $conf, $user;
1186 $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity);
1188 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1189 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1190 $sql .=
" AND entity IN (0, ".$entity.
")";
1192 dol_syslog(get_class($this).
"::_active delete activation constant", LOG_DEBUG);
1193 $resql = $this->db->query($sql);
1198 $note = json_encode(
1200 'authorid' => (is_object($user) ? $user->id : 0),
1201 'ip' => (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']),
1202 'lastactivationversion' => $this->version,
1206 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (name, value, visible, entity, note) VALUES";
1207 $sql .=
" (".$this->db->encrypt($this->const_name);
1208 $sql .=
", ".$this->db->encrypt(
'1');
1209 $sql .=
", 0, ".((int) $entity);
1210 $sql .=
", '".$this->db->escape($note).
"')";
1212 dol_syslog(get_class($this).
"::_active insert activation constant", LOG_DEBUG);
1213 $resql = $this->db->query($sql);
1236 $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity);
1238 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1239 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1240 $sql .=
" AND entity IN (0, ".$entity.
")";
1242 dol_syslog(get_class($this).
"::_unactive", LOG_DEBUG);
1243 $this->db->query($sql);
1274 if (empty($reldir)) {
1278 include_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
1280 foreach ($conf->file->dol_document_root as $dirroot) {
1282 $dirsql = $dirroot.$reldir;
1286 $listofsubdir = array(
'',
'tables/',
'data/');
1287 if ($this->db->type ==
'pgsql') {
1288 $listofsubdir[] =
'../pgsql/functions/';
1291 foreach ($listofsubdir as $subdir) {
1292 $dir = $dirsql.$subdir;
1294 $handle = @opendir($dir);
1295 if (is_resource($handle)) {
1300 while (($file = readdir($handle)) !==
false) {
1304 foreach ($files as $file) {
1305 if ($onlywithsuffix) {
1306 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1313 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 4) ==
'llx_') {
1325 while (($file = readdir($handle)) !==
false) {
1329 foreach ($files as $file) {
1330 if ($onlywithsuffix) {
1331 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1338 if (preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 4) ==
'llx_') {
1350 while (($file = readdir($handle)) !==
false) {
1354 foreach ($files as $file) {
1355 if ($onlywithsuffix) {
1356 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1363 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 9) ==
'functions') {
1375 while (($file = readdir($handle)) !==
false) {
1379 foreach ($files as $file) {
1380 if ($onlywithsuffix) {
1381 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1388 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 4) ==
'data') {
1400 while (($file = readdir($handle)) !==
false) {
1404 foreach ($files as $file) {
1405 if ($onlywithsuffix) {
1406 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1413 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 6) ==
'update') {
1432 dol_syslog(
"A module wants to load sql files from ".$reldir.
" but this directory was not found.", LOG_WARNING);
1449 include_once DOL_DOCUMENT_ROOT.
'/core/class/infobox.class.php';
1455 if (is_array($this->boxes)) {
1456 dol_syslog(get_class($this).
"::insert_boxes", LOG_DEBUG);
1460 foreach ($this->boxes as $key => $value) {
1461 $file = isset($this->boxes[$key][
'file']) ? $this->boxes[$key][
'file'] :
'';
1462 $note = isset($this->boxes[$key][
'note']) ? $this->boxes[$key][
'note'] :
'';
1463 $enabledbydefaulton = isset($this->boxes[$key][
'enabledbydefaulton']) ? $this->boxes[$key][
'enabledbydefaulton'] :
'Home';
1466 $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] :
'';
1469 $note = isset($this->boxes[$key][2]) ? $this->boxes[$key][2] :
'';
1473 $sql =
"SELECT count(*) as nb FROM ".MAIN_DB_PREFIX.
"boxes_def";
1474 $sql .=
" WHERE file = '".$this->db->escape($file).
"'";
1475 $sql .=
" AND entity = ".$conf->entity;
1477 $sql .=
" AND note ='".$this->db->escape($note).
"'";
1480 $result = $this->db->query($sql);
1482 $obj = $this->db->fetch_object($result);
1483 if ($obj->nb == 0) {
1487 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"boxes_def (file, entity, note)";
1488 $sql .=
" VALUES ('".$this->db->escape($file).
"', ";
1489 $sql .= $conf->entity.
", ";
1490 $sql .= $note ?
"'".$this->db->escape($note).
"'" :
"null";
1493 dol_syslog(get_class($this).
"::insert_boxes", LOG_DEBUG);
1494 $resql = $this->db->query($sql);
1499 if (!$err && !preg_match(
'/newboxdefonly/', $option)) {
1500 $lastid = $this->db->last_insert_id(MAIN_DB_PREFIX.
"boxes_def",
"rowid");
1502 foreach ($pos_name as $key2 => $val2) {
1504 if ($enabledbydefaulton && $val2 != $enabledbydefaulton) {
1508 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"boxes (box_id, position, box_order, fk_user, entity)";
1509 $sql .=
" VALUES (".((int) $lastid).
", ".((int) $key2).
", '0', 0, ".((int) $conf->entity).
")";
1511 dol_syslog(get_class($this).
"::insert_boxes onto page ".$key2.
"=".$val2, LOG_DEBUG);
1512 $resql = $this->db->query($sql);
1520 $this->db->commit();
1522 $this->error = $this->db->lasterror();
1523 $this->db->rollback();
1528 $this->error = $this->db->lasterror();
1551 if (is_array($this->boxes)) {
1552 foreach ($this->boxes as $key => $value) {
1554 if (empty($this->boxes[$key][
'file'])) {
1555 $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] :
'';
1557 $file = $this->boxes[$key][
'file'];
1565 if ($file ==
'box_graph_product_distribution.php') {
1567 dol_syslog(
"We discard deleting module ".$file.
" because another module still active requires it.");
1572 if ($this->db->type ==
'sqlite3') {
1575 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes ";
1576 $sql .=
"WHERE ".MAIN_DB_PREFIX.
"boxes.box_id IN (";
1577 $sql .=
"SELECT ".MAIN_DB_PREFIX.
"boxes_def.rowid ";
1578 $sql .=
"FROM ".MAIN_DB_PREFIX.
"boxes_def ";
1579 $sql .=
"WHERE ".MAIN_DB_PREFIX.
"boxes_def.file = '".$this->db->escape($file).
"') ";
1580 $sql .=
"AND ".MAIN_DB_PREFIX.
"boxes.entity = ".$conf->entity;
1582 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes";
1583 $sql .=
" USING ".MAIN_DB_PREFIX.
"boxes, ".MAIN_DB_PREFIX.
"boxes_def";
1584 $sql .=
" WHERE ".MAIN_DB_PREFIX.
"boxes.box_id = ".MAIN_DB_PREFIX.
"boxes_def.rowid";
1585 $sql .=
" AND ".MAIN_DB_PREFIX.
"boxes_def.file = '".$this->db->escape($file).
"'";
1586 $sql .=
" AND ".MAIN_DB_PREFIX.
"boxes.entity = ".$conf->entity;
1589 dol_syslog(get_class($this).
"::delete_boxes", LOG_DEBUG);
1590 $resql = $this->db->query($sql);
1592 $this->error = $this->db->lasterror();
1596 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes_def";
1597 $sql .=
" WHERE file = '".$this->db->escape($file).
"'";
1598 $sql .=
" AND entity = ".$conf->entity;
1600 dol_syslog(get_class($this).
"::delete_boxes", LOG_DEBUG);
1601 $resql = $this->db->query($sql);
1603 $this->error = $this->db->lasterror();
1621 include_once DOL_DOCUMENT_ROOT .
'/core/class/infobox.class.php';
1622 include_once DOL_DOCUMENT_ROOT .
'/cron/class/cronjob.class.php';
1623 include_once DOL_DOCUMENT_ROOT .
'/user/class/user.class.php';
1625 global $conf, $user;
1628 $user =
new User($this->db);
1633 if (is_array($this->cronjobs)) {
1634 dol_syslog(get_class($this) .
"::insert_cronjobs", LOG_DEBUG);
1636 foreach ($this->cronjobs as $key => $value) {
1639 $entity = isset($value[
'entity']) ? $value[
'entity'] : $conf->entity;
1640 $label = isset($value[
'label']) ? $value[
'label'] :
'';
1641 $jobtype = isset($value[
'jobtype']) ? $value[
'jobtype'] :
'';
1642 $classesname = isset($value[
'class']) ? $value[
'class'] :
'';
1643 $objectname = isset($value[
'objectname']) ? $value[
'objectname'] :
'';
1644 $methodename = isset($value[
'method']) ? $value[
'method'] :
'';
1645 $command = isset($value[
'command']) ? $value[
'command'] :
'';
1646 $params = isset($value[
'parameters']) ? $value[
'parameters'] :
'';
1647 $md5params = isset($value[
'md5params']) ? $value[
'md5params'] :
'';
1648 $comment = isset($value[
'comment']) ? $value[
'comment'] :
'';
1649 $frequency = isset($value[
'frequency']) ? $value[
'frequency'] :
'';
1650 $unitfrequency = isset($value[
'unitfrequency']) ? $value[
'unitfrequency'] :
'';
1651 $priority = isset($value[
'priority']) ? $value[
'priority'] :
'';
1652 $datestart = isset($value[
'datestart']) ? $value[
'datestart'] :
'';
1653 $dateend = isset($value[
'dateend']) ? $value[
'dateend'] :
'';
1654 $datenextrun = isset($value[
'datenextrun']) ? $value[
'datenextrun'] : $now;
1655 $status = isset($value[
'status']) ? $value[
'status'] :
'';
1656 $maxrun = isset($value[
'maxrun']) ? $value[
'maxrun'] : 0;
1657 $libname = isset($value[
'libname']) ? $value[
'libname'] :
'';
1658 $test = isset($value[
'test']) ? $value[
'test'] :
'';
1661 $sql =
"SELECT count(*) as nb FROM " . MAIN_DB_PREFIX .
"cronjob";
1663 $sql .=
" WHERE label = '".$this->db->escape($label).
"'";
1681 $sql .=
" AND entity = " . ((int) $entity);
1683 $result = $this->db->query($sql);
1685 $this->error = $this->db->lasterror();
1691 $obj = $this->db->fetch_object($result);
1696 $cronjob =
new Cronjob($this->db);
1698 $cronjob->entity = $entity;
1699 $cronjob->label = $label;
1700 $cronjob->jobtype = $jobtype;
1701 $cronjob->classesname = $classesname;
1702 $cronjob->objectname = $objectname;
1703 $cronjob->methodename = $methodename;
1704 $cronjob->command = $command;
1705 $cronjob->params = $params;
1706 $cronjob->md5params = $md5params;
1707 $cronjob->note_private = $comment;
1708 $cronjob->frequency = $frequency;
1709 $cronjob->unitfrequency = $unitfrequency;
1710 $cronjob->priority = $priority;
1711 $cronjob->datestart = $datestart;
1712 $cronjob->dateend = $dateend;
1713 $cronjob->datenextrun = $datenextrun;
1714 $cronjob->maxrun = $maxrun;
1715 $cronjob->status = $status;
1716 $cronjob->test = $test;
1717 $cronjob->libname = $libname;
1718 $cronjob->module_name = empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class;
1720 $retCreate = $cronjob->create($user);
1722 if ($retCreate < 0) {
1723 $this->error = implode(
"\n", array_merge([$cronjob->error], $cronjob->errors));
1745 if (is_array($this->cronjobs)) {
1746 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"cronjob";
1747 $sql .=
" WHERE module_name = '".$this->db->escape(empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class).
"'";
1748 $sql .=
" AND entity = ".$conf->entity;
1749 $sql .=
" AND test = '1'";
1752 dol_syslog(get_class($this).
"::delete_cronjobs", LOG_DEBUG);
1753 $resql = $this->db->query($sql);
1755 $this->error = $this->db->lasterror();
1776 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1777 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" LIKE '".$this->db->escape($this->const_name).
"_TABS_%'";
1778 $sql .=
" AND entity = ".((int) $conf->entity);
1780 dol_syslog(get_class($this).
"::delete_tabs", LOG_DEBUG);
1781 if (!$this->db->query($sql)) {
1782 $this->error = $this->db->lasterror();
1802 if (!empty($this->tabs)) {
1803 dol_syslog(get_class($this).
"::insert_tabs", LOG_DEBUG);
1806 foreach ($this->tabs as $key => $value) {
1807 if (is_array($value) && count($value) == 0) {
1811 $entity = $conf->entity;
1814 if (is_array($value)) {
1815 $newvalue = $value[
'data'];
1816 if (isset($value[
'entity'])) {
1817 $entity = $value[
'entity'];
1822 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (";
1827 $sql .=
", visible";
1830 $sql .=
" VALUES (";
1831 $sql .= $this->db->encrypt($this->const_name.
"_TABS_".$i);
1832 $sql .=
", 'chaine'";
1833 $sql .=
", ".$this->db->encrypt($newvalue);
1836 $sql .=
", ".((int) $entity);
1839 $resql = $this->db->query($sql);
1842 if ($this->db->lasterrno() !=
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1843 $this->error = $this->db->lasterror();
1844 $this->errors[] = $this->db->lasterror();
1869 if (empty($this->
const)) {
1875 foreach ($this->
const as $key => $value) {
1877 $name = $this->
const[$key][0];
1878 $entity = (!empty($this->
const[$key][5]) && $this->
const[$key][5] !=
'current') ? 0 : $conf->entity;
1881 $type = $this->
const[$key][1];
1882 $val = $this->
const[$key][2];
1883 $note = isset($this->
const[$key][3]) ? $this->
const[$key][3] :
'';
1884 $visible = isset($this->
const[$key][4]) ? $this->
const[$key][4] : 0;
1887 if (empty($visible)) {
1890 if (empty($val) && $val !=
'0') {
1894 if (!empty($name)) {
1895 $sql =
"SELECT count(*) as nb";
1896 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1897 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
1898 $sql .=
" AND entity = ".((int) $entity);
1900 $result = $this->db->query($sql);
1902 $row = $this->db->fetch_row($result);
1905 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (name, type, value, note, visible, entity)";
1906 $sql .=
" VALUES (";
1907 $sql .= $this->db->encrypt($name);
1908 $sql .=
", '".$this->db->escape($type).
"'";
1909 $sql .=
", ".(($val !=
'') ? $this->db->encrypt($val) :
"''");
1910 $sql .=
", ".($note ?
"'".$this->db->escape($note).
"'" :
"null");
1911 $sql .=
", '".$this->db->escape($visible).
"'";
1912 $sql .=
", ".((int) $entity);
1915 if (!$this->db->query($sql)) {
1919 $conf->global->$name = $val;
1922 dol_syslog(__METHOD__.
" constant '".$name.
"' already exists", LOG_DEBUG);
1946 if (empty($this->
const)) {
1950 foreach ($this->
const as $key => $value) {
1951 $name = $this->
const[$key][0];
1952 $deleteonunactive = (!empty($this->
const[$key][6])) ? 1 : 0;
1954 if ($deleteonunactive) {
1955 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1956 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
1957 $sql .=
" AND entity in (0, ".$conf->entity.
")";
1958 dol_syslog(get_class($this).
"::delete_const", LOG_DEBUG);
1959 if (!$this->db->query($sql)) {
1960 $this->error = $this->db->lasterror();
1981 global $conf, $user;
1984 $entity = (!empty($force_entity) ? $force_entity : $conf->entity);
1986 dol_syslog(get_class($this).
"::insert_permissions", LOG_DEBUG);
1989 $sql_del =
"SELECT ".$this->db->decrypt(
'value').
" as value";
1990 $sql_del .=
" FROM ".MAIN_DB_PREFIX.
"const";
1991 $sql_del .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1992 $sql_del .=
" AND entity IN (0,".((int) $entity).
")";
1994 $resql = $this->db->query($sql_del);
1997 $obj = $this->db->fetch_object($resql);
1999 if ($obj !==
null && !empty($obj->value) && !empty($this->rights)) {
2000 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
2003 foreach ($this->rights as $key => $value) {
2004 $r_id = $this->rights[$key][self::KEY_ID];
2005 $r_label = $this->rights[$key][self::KEY_LABEL];
2006 $r_type = $this->rights[$key][self::KEY_TYPE] ??
'w';
2007 $r_default = $this->rights[$key][self::KEY_DEFAULT] ?? 0;
2008 $r_perms = $this->rights[$key][self::KEY_FIRST_LEVEL] ??
'';
2009 $r_subperms = $this->rights[$key][self::KEY_SECOND_LEVEL] ??
'';
2012 $r_family = $this->family;
2013 $r_family_position = 0;
2016 if (empty($r_perms)) {
2021 $r_module = (empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class);
2024 $r_module_origin =
'';
2026 if (isset($this->rights[$key][self::KEY_MODULE])) {
2028 $r_module = $this->rights[$key][self::KEY_MODULE];
2030 $r_module_origin = (empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class);
2034 $r_enabled = $this->rights[$key][self::KEY_ENABLED] ??
'1';
2037 $sql =
"SELECT count(*) as nb FROM ".MAIN_DB_PREFIX.
"rights_def";
2038 $sql .=
" WHERE entity = ".((int) $entity);
2039 $sql .=
" AND id = ".((int) $r_id);
2041 $resqlselect = $this->db->query($sql);
2043 $objcount = $this->db->fetch_object($resqlselect);
2044 if ($objcount && $objcount->nb == 0) {
2045 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"rights_def (";
2048 $sql .=
", libelle";
2050 $sql .=
", module_origin";
2051 $sql .=
", module_position";
2053 $sql .=
", family_position";
2055 $sql .=
", bydefault";
2057 $sql .=
", subperms";
2058 $sql .=
", enabled";
2059 $sql .=
") VALUES (";
2060 $sql .= ((int) $r_id);
2061 $sql .=
", ".((int) $entity);
2062 $sql .=
", '".$this->db->escape($r_label).
"'";
2063 $sql .=
", '".$this->db->escape($r_module).
"'";
2064 $sql .=
", '".$this->db->escape($r_module_origin).
"'";
2065 $sql .=
", '".$this->db->escape((
string) $r_module_position).
"'";
2066 $sql .=
", '".$this->db->escape($r_family).
"'";
2067 $sql .=
", '".$this->db->escape((
string) $r_family_position).
"'";
2068 $sql .=
", '".$this->db->escape($r_type).
"'";
2069 $sql .=
", ".((int) $r_default);
2070 $sql .=
", '".$this->db->escape($r_perms).
"'";
2071 $sql .=
", '".$this->db->escape($r_subperms).
"'";
2072 $sql .=
", '".$this->db->escape($r_enabled).
"'";
2075 $resqlinsert = $this->db->query($sql, 1);
2077 if (!$resqlinsert) {
2078 if ($this->db->errno() !=
"DB_ERROR_RECORD_ALREADY_EXISTS") {
2079 $this->error = $this->db->lasterror();
2083 dol_syslog(get_class($this).
"::insert_permissions record already exists", LOG_INFO);
2087 $this->db->free($resqlinsert);
2090 $this->db->free($resqlselect);
2094 if (!empty($reinitadminperms)) {
2095 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"user WHERE admin = 1";
2096 dol_syslog(get_class($this).
"::insert_permissions Search all admin users", LOG_DEBUG);
2098 $resqlseladmin = $this->db->query($sql, 1);
2100 if ($resqlseladmin) {
2101 $num = $this->db->num_rows($resqlseladmin);
2104 $obj2 = $this->db->fetch_object($resqlseladmin);
2105 dol_syslog(get_class($this).
"::insert_permissions Add permission id ".$r_id.
" to user id=".$obj2->rowid);
2107 $tmpuser =
new User($this->db);
2108 $result = $tmpuser->fetch($obj2->rowid);
2110 $tmpuser->addrights($r_id,
'',
'', 0, 1);
2112 dol_syslog(get_class($this).
"::insert_permissions Failed to add the permission to user because fetch return an error", LOG_ERR);
2122 if (!empty($reinitadminperms) && !empty($user->admin)) {
2124 $user->clearrights();
2125 $user->loadRights();
2128 $this->db->free($resql);
2130 $this->error = $this->db->lasterror();
2151 $module = empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class;
2153 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"rights_def";
2154 $sql .=
" WHERE (module = '".$this->db->escape($module).
"' OR module_origin = '".$this->db->escape($module).
"')";
2157 if (empty($this->core_enabled)) {
2158 $sql .=
" AND entity = ".((int) $conf->entity);
2161 dol_syslog(get_class($this).
"::delete_permissions", LOG_DEBUG);
2162 if (!$this->db->query($sql)) {
2163 $this->error = $this->db->lasterror();
2180 global $conf, $user;
2182 if (!is_array($this->menu) || empty($this->menu)) {
2186 include_once DOL_DOCUMENT_ROOT.
'/core/class/menubase.class.php';
2188 dol_syslog(get_class($this).
"::insert_menus", LOG_DEBUG);
2193 $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity);
2197 foreach ($this->menu as $key => $value) {
2199 $menu->menu_handler =
'all';
2202 $menu->module = (empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class);
2204 if (!$this->menu[$key][
'fk_menu']) {
2208 $fk_parent = $this->menu[$key][
'fk_menu'];
2210 if (preg_match(
'/^r=/', $fk_parent)) {
2211 $fk_parent = str_replace(
'r=',
'', $fk_parent);
2212 if (isset($this->menu[$fk_parent][
'rowid'])) {
2213 $menu->fk_menu = $this->menu[$fk_parent][
'rowid'];
2216 } elseif (preg_match(
'/^fk_mainmenu=([a-zA-Z0-9_]+),fk_leftmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) {
2217 $menu->fk_menu = -1;
2218 $menu->fk_mainmenu = $reg[1];
2219 $menu->fk_leftmenu = $reg[2];
2221 } elseif (preg_match(
'/^fk_mainmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) {
2222 $menu->fk_menu = -1;
2223 $menu->fk_mainmenu = $reg[1];
2224 $menu->fk_leftmenu =
'';
2227 if (!$foundparent) {
2228 $this->error =
"ErrorBadDefinitionOfMenuArrayInModuleDescriptor";
2229 dol_syslog(get_class($this).
"::insert_menus ".$this->error.
" ".$this->menu[$key][
'fk_menu'], LOG_ERR);
2233 $menu->type = $this->menu[$key][
'type'];
2234 $menu->mainmenu = isset($this->menu[$key][
'mainmenu']) ? $this->menu[$key][
'mainmenu'] : (isset($menu->fk_mainmenu) ? $menu->fk_mainmenu :
'');
2235 $menu->leftmenu = isset($this->menu[$key][
'leftmenu']) ? $this->menu[$key][
'leftmenu'] :
'';
2236 $menu->title = $this->menu[$key][
'titre'];
2237 $menu->prefix = isset($this->menu[$key][
'prefix']) ? $this->menu[$key][
'prefix'] :
'';
2238 $menu->url = $this->menu[$key][
'url'];
2239 $menu->langs = isset($this->menu[$key][
'langs']) ? $this->menu[$key][
'langs'] :
'';
2240 $menu->position = $this->menu[$key][
'position'];
2241 $menu->perms = $this->menu[$key][
'perms'];
2242 $menu->target = isset($this->menu[$key][
'target']) ? $this->menu[$key][
'target'] :
'';
2243 $menu->user = $this->menu[$key][
'user'];
2244 $menu->enabled = isset($this->menu[$key][
'enabled']) ? $this->menu[$key][
'enabled'] : 0;
2245 $menu->position = $this->menu[$key][
'position'];
2246 $menu->entity = $entity;
2249 $result = $menu->create($user);
2251 $this->menu[$key][
'rowid'] = $result;
2253 $this->error = $menu->error;
2254 dol_syslog(get_class($this).
'::insert_menus result='.$result.
" ".$this->error, LOG_ERR);
2262 $this->db->commit();
2264 dol_syslog(get_class($this).
"::insert_menus ".$this->error, LOG_ERR);
2265 $this->db->rollback();
2286 $module = empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class;
2288 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"menu";
2289 $sql .=
" WHERE module = '".$this->db->escape($module).
"'";
2290 $sql .=
" AND menu_handler = 'all'";
2291 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
2293 dol_syslog(get_class($this).
"::delete_menus", LOG_DEBUG);
2294 $resql = $this->db->query($sql);
2296 $this->error = $this->db->lasterror();
2312 global $langs, $conf;
2317 if (isset($this->dirs) && is_array($this->dirs)) {
2318 foreach ($this->dirs as $key => $value) {
2321 if (!is_array($value)) {
2324 $constname = $this->const_name.
"_DIR_";
2325 $dir = $this->dirs[$key][1];
2326 $addtodatabase = empty($this->dirs[$key][2]) ?
'' : $this->dirs[$key][2];
2327 $subname = empty($this->dirs[$key][3]) ?
'' : strtoupper($this->dirs[$key][3]);
2328 $forcename = empty($this->dirs[$key][4]) ?
'' : strtoupper($this->dirs[$key][4]);
2330 if (!empty($forcename)) {
2331 $constname =
'MAIN_MODULE_'.$forcename.
"_DIR_";
2333 if (!empty($subname)) {
2334 $constname = $constname.$subname.
"_";
2337 $name = $constname.strtoupper($this->dirs[$key][0]);
2342 $fulldir = DOL_DATA_ROOT.$dir;
2344 $fulldir = DOL_DATA_ROOT.
"/".$conf->entity.$dir;
2347 if (!empty($fulldir) && !file_exists($fulldir)) {
2348 if (
dol_mkdir($fulldir, DOL_DATA_ROOT) < 0) {
2349 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $fulldir);
2350 dol_syslog(get_class($this).
"::_init ".$this->error, LOG_ERR);
2356 if (!empty($addtodatabase) && !empty($name)) {
2385 $sql =
"SELECT count(*)";
2386 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
2387 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
2388 $sql .=
" AND entity = ".$conf->entity;
2390 dol_syslog(get_class($this).
"::insert_dirs", LOG_DEBUG);
2391 $result = $this->db->query($sql);
2393 $row = $this->db->fetch_row($result);
2396 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (name, type, value, note, visible, entity)";
2397 $sql .=
" VALUES (".$this->db->encrypt($name).
", 'chaine', ".$this->db->encrypt($dir).
", '".$this->db->escape(
"Directory for module ".$this->
name).
"', '0', ".((int) $conf->entity).
")";
2399 dol_syslog(get_class($this).
"::insert_dirs", LOG_DEBUG);
2400 $this->db->query($sql);
2403 $this->error = $this->db->lasterror();
2424 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
2425 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" LIKE '".$this->db->escape($this->const_name).
"_DIR_%'";
2426 $sql .=
" AND entity = ".$conf->entity;
2428 dol_syslog(get_class($this).
"::delete_dirs", LOG_DEBUG);
2429 if (!$this->db->query($sql)) {
2430 $this->error = $this->db->lasterror();
2447 global $conf, $langs;
2451 if (is_array($this->module_parts)) {
2452 if (empty($this->module_parts[
'icon']) && !empty($this->picto) && preg_match(
'/^fa\-/', $this->picto)) {
2453 $this->module_parts[
'icon'] = $this->picto;
2456 foreach ($this->module_parts as $key => $value) {
2457 if (is_array($value) && count($value) == 0) {
2462 if ($key ==
'websitetemplates' && $value == 1) {
2466 $docs =
dol_dir_list($srcroot,
'directories', 0,
'website_.*$');
2467 foreach ($docs as $cursorfile) {
2468 $src = $srcroot.
'/'.$cursorfile[
'name'];
2469 $dest = DOL_DATA_ROOT.
'/doctemplates/websites/'.$cursorfile[
'name'];
2476 $result = dol_compress_dir($src, $dest.
'.zip',
'zip');
2479 $this->error = ($errormsg ? $errormsg : $langs->trans(
'ErrorFailToCreateZip', $dest));
2480 $this->errors[] = ($errormsg ? $errormsg : $langs->trans(
'ErrorFailToCreateZip', $dest));
2485 $docs =
dol_dir_list($srcroot,
'files', 0,
'website_.*\.jpg$');
2486 foreach ($docs as $cursorfile) {
2487 $src = $srcroot.
'/'.$cursorfile[
'name'];
2488 $dest = DOL_DATA_ROOT.
'/doctemplates/websites/'.$cursorfile[
'name'];
2494 $entity = $conf->entity;
2498 if (is_array($value)) {
2501 if (isset($value[
'data']) && is_array($value[
'data'])) {
2502 $newvalue = json_encode($value[
'data']);
2503 if (isset($value[
'entity'])) {
2504 $entity = $value[
'entity'];
2506 } elseif (isset($value[
'data']) && !is_array($value[
'data'])) {
2507 $newvalue = $value[
'data'];
2508 if (isset($value[
'entity'])) {
2509 $entity = $value[
'entity'];
2512 $newvalue = json_encode($value);
2516 if (!empty($newvalue)) {
2517 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (";
2522 $sql .=
", visible";
2525 $sql .=
" VALUES (";
2526 $sql .=
" ".$this->db->encrypt($this->const_name.
"_".strtoupper($key), 1);
2527 $sql .=
", 'chaine'";
2528 $sql .=
", ".$this->db->encrypt($newvalue, 1);
2531 $sql .=
", ".((int) $entity);
2534 dol_syslog(get_class($this).
"::insert_module_parts for key=".$this->const_name.
"_".strtoupper($key), LOG_DEBUG);
2536 $resql = $this->db->query($sql, 1);
2538 if ($this->db->lasterrno() !=
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2540 $this->error = $this->db->lasterror();
2542 dol_syslog(get_class($this).
"::insert_module_parts for ".$this->const_name.
"_".strtoupper($key).
" Record already exists.", LOG_WARNING);
2564 if (is_array($this->module_parts)) {
2565 dol_syslog(get_class($this).
"::delete_module_parts", LOG_DEBUG);
2567 if (empty($this->module_parts[
'icon']) && !empty($this->picto) && preg_match(
'/^fa\-/', $this->picto)) {
2568 $this->module_parts[
'icon'] = $this->picto;
2571 foreach ($this->module_parts as $key => $value) {
2573 if (is_array($value) && isset($value[
'entity'])) {
2574 $entity = $value[
'entity'];
2576 $entity = $conf->entity;
2579 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
2580 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" LIKE '".$this->db->escape($this->const_name).
"_".strtoupper($key).
"'";
2581 $sql .=
" AND entity = ".((int) $entity);
2583 if (!$this->db->query($sql)) {
2584 $this->error = $this->db->lasterror();
2601 public function init($options =
'')
2603 return $this->
_init(array(), $options);
2614 public function remove($options =
'')
2616 return $this->
_remove(array(), $options);
2634 $imginfo =
"info_black";
2637 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($this)));
2641 if (preg_match(
'/development/i', $version)) {
2642 $versiontrans .=
'warning';
2644 if (preg_match(
'/experimental/i', $version)) {
2645 $versiontrans .=
'warning';
2647 if (preg_match(
'/deprecated/i', $version)) {
2648 $versiontrans .=
'warning';
2652 <div class="box-flex-item info-box-module'
2653 .(getDolGlobalString($const_name) ?
'' :
' --disabled')
2655 .($this->needUpdate ?
' --need-update' :
'')
2657 <div class="info-box info-box-sm info-box-module">
2658 <div class="info-box-icon'.(!
getDolGlobalString($const_name) ?
'' :
' info-box-icon-module-enabled'.($versiontrans ?
' info-box-icon-module-warning' :
'')).
'">';
2663 if (!empty($this->picto)) {
2664 if (preg_match(
'/^\//i', $this->picto)) {
2665 $return .=
img_picto($alttext, $this->picto,
'class="inline-block valignmiddle"', 1);
2667 $return .=
img_object($alttext, $this->picto,
'class="inline-block valignmiddle"');
2670 $return .=
img_object($alttext,
'generic',
'class="inline-block valignmiddle"');
2673 if ($this->
isCoreOrExternalModule() ==
'external' || preg_match(
'/development|experimental|deprecated/i', $version)) {
2674 $versionTitle = $langs->trans(
"Version").
' '.$this->
getVersion(1);
2675 if ($this->needUpdate) {
2676 $versionTitle .=
'<br>'.$langs->trans(
'ModuleUpdateAvailable').
' : '.$this->lastVersion;
2679 $return .=
'<span class="info-box-icon-version'.($versiontrans ?
' '.$versiontrans :
'').
' classfortooltip" title="'.
dol_escape_js($versionTitle).
'" >';
2681 $return .=
'</span>';
2685 <div class="info-box-content info-box-text-module'.(!
getDolGlobalString($const_name) ?
'' :
' info-box-module-enabled'.($versiontrans ?
' info-box-content-warning' :
'')).
'">
2686 <span class="info-box-title noopacity">'.$this->
getName().
'</span>
2689 $return .=
'<div class="valignmiddle inline-block info-box-more">';
2691 $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>';
2692 $return .= '</div><br>';
2694 $return .= '<div class="valignmiddle
inline-block info-box-actions
">';
2695 $return .= '<div class="valignmiddle
inline-block info-box-setup
">';
2696 $return .= $codetoconfig;
2697 $return .= '</div>';
2698 $return .= '<div class="valignmiddle
inline-block marginleftonly marginrightonly
">';
2699 $return .= $codeenabledisable;
2700 $return .= '</div>';
2701 $return .= '</div>';
2704 </div><!-- /.info-box-content -->
2705 </div><!-- /.info-box -->
2719 public function checkForUpdate()
2721 require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
2722 if (!empty($this->url_last_version)) {
2723 $lastVersion = getURLContent($this->url_last_version, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only
2724 if (isset($lastVersion['content']) && strlen($lastVersion['content']) < 30) {
2725 // 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 _ . -
2726 $this->lastVersion = preg_replace("/[^a-zA-Z0-9_\.\-]+/
", "", $lastVersion['content']);
2727 if (version_compare($this->lastVersion, $this->version) > 0) {
2728 $this->needUpdate = true;
2731 $this->needUpdate = false;
2748 public function checkForCompliance($nametocheck = '')
2750 global $conf, $langs;
2752 if (empty($nametocheck)) {
2753 $nametocheck = $this->name;
2756 // Get list of illegal modules name or ID
2757 if (empty($conf->cache['noncompliantmodules'])) {
2758 require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
2760 $result = getURLContent(self::URL_FOR_BLACKLISTED_MODULES, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only
2761 if (isset($result['content']) && $result['http_code'] == 200) {
2762 $langs->load("errors
");
2764 // 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 _ . -
2765 $arrayoflines = preg_split("/[\n,]/
", $result['content']);
2766 foreach ($arrayoflines as $line) {
2767 $tmpfieldsofline = explode(';', $line);
2768 $modulekey = strtolower(trim($tmpfieldsofline[0]));
2769 if (empty($modulekey)) {
2772 $conf->cache['noncompliantmodules'][$modulekey]['name'] = trim($tmpfieldsofline[0]);
2773 $conf->cache['noncompliantmodules'][$modulekey]['id'] = (isset($tmpfieldsofline[1]) ? trim($tmpfieldsofline[1]) : '');
2774 $conf->cache['noncompliantmodules'][$modulekey]['signature'] = (isset($tmpfieldsofline[2]) ? trim($tmpfieldsofline[2]) : '');
2775 $conf->cache['noncompliantmodules'][$modulekey]['message'] = $langs->trans(empty(isset($tmpfieldsofline[3]) ? trim($tmpfieldsofline[3]) : '') ? 'WarningModuleAffiliatedToAReportedCompany' : trim($tmpfieldsofline[3]));
2776 if (!empty($tmpfieldsofline[4])) {
2777 $message2 = $langs->trans("WarningModuleAffiliatedToAPiratPlatform
", '{s}');
2778 $listofillegalurl = '';
2779 foreach (explode(" ", $tmpfieldsofline[4]) as $illegalurl) {
2780 $listofillegalurl .= ($listofillegalurl ? ' '.$langs->trans("or
").' ' : '').'<b>'.preg_replace('/[^a-z0-9\.\-]/', '', $illegalurl).'</b>';
2782 $message2 = str_replace('{s}', $listofillegalurl, $message2);
2783 $conf->cache['noncompliantmodules'][$modulekey]['message2'] = $message2;
2789 if (!empty($conf->cache['noncompliantmodules'])) {
2790 $modulekey = strtolower($nametocheck);
2791 if (in_array($modulekey, array_keys($conf->cache['noncompliantmodules']))) {
2792 $answer = trim($conf->cache['noncompliantmodules'][$modulekey]['message']);
2793 if (!empty($conf->cache['noncompliantmodules'][$modulekey]['message2'])) {
2794 $answer .= '<br>'.$conf->cache['noncompliantmodules'][$modulekey]['message2'];
2821 protected function declareNewDictionary($dictionaryArray, $langs = '')
2823 $fields = array('name', 'lib', 'sql', 'sqlsort', 'field', 'fieldvalue', 'fieldinsert', 'rowid', 'cond', 'help', 'fieldcheck');
2825 foreach ($fields as $field) {
2826 if (isset($dictionaryArray[$field])) {
2827 // @phan-suppress-next-line PhanTypeMismatchProperty
2828 $this->dictionaries['tab'.$field][] = $dictionaryArray[$field];
2831 if ($langs && !in_array($langs, $this->dictionaries[$langs])) {
2832 $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...
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.