64 public $editor_squarred_logo;
92 public $module_position =
'50';
109 public $dirs = array();
114 public $boxes = array();
119 public $const = array();
124 public $cronjobs = array();
134 public $rights_admin_allowed;
139 public $rights_class;
144 const KEY_DEFAULT = 3;
145 const KEY_FIRST_LEVEL = 4;
146 const KEY_SECOND_LEVEL = 5;
147 const KEY_MODULE = 6;
148 const KEY_ENABLED = 7;
153 public $menu = array();
182 public $module_parts = array();
231 public $descriptionlong;
236 public $dictionaries = array();
253 public $export_label;
263 public $export_enabled;
267 public $export_permission;
271 public $export_fields_array;
275 public $export_TypeFields_array;
279 public $export_entities_array;
283 public $export_aggregate_array;
287 public $export_examplevalues_array;
291 public $export_help_array;
298 public $export_special_array;
305 public $export_dependencies_array;
309 public $export_sql_start;
313 public $export_sql_end;
317 public $export_sql_order;
330 public $import_label;
339 public $import_entities_array;
343 public $import_tables_array;
347 public $import_tables_creator_array;
351 public $import_fields_array;
355 public $import_fieldshidden_array;
359 public $import_convertvalue_array;
363 public $import_regex_array;
367 public $import_examplevalues_array;
371 public $import_updatekeys_array;
375 public $import_run_sql_after_array;
379 public $import_TypeFields_array;
383 public $import_help_array;
393 public $always_enabled;
403 public $core_enabled;
419 public $config_page_url;
442 public $conflictwith;
454 public $warnings_activation;
461 public $warnings_activation_ext;
468 public $warnings_unactivation;
485 public $need_dolibarr_version;
487 public $need_javascript_ajax;
489 public $enabled_bydefault;
494 public $hidden =
false;
499 public $url_last_version;
528 protected function _init($array_sql, $options =
'')
552 if (!$err && !preg_match(
'/newboxdefonly/', $options)) {
557 if (!$err && !preg_match(
'/noboxes/', $options)) {
582 $num = count($array_sql);
583 for ($i = 0; $i < $num; $i++) {
585 $val = $array_sql[$i];
588 if (is_array($val)) {
590 $ignoreerror = $val[
'ignoreerror'];
593 $sql = str_replace(
'__ENTITY__', (
string) $conf->entity, $sql);
595 dol_syslog(get_class($this).
"::_init ignoreerror=".$ignoreerror, LOG_DEBUG);
596 $result = $this->db->query($sql, $ignoreerror);
599 $this->error = $this->db->lasterror();
602 dol_syslog(get_class($this).
"::_init Warning ".$this->db->lasterror(), LOG_WARNING);
612 $moduleNameInConf = strtolower(preg_replace(
'/^MAIN_MODULE_/',
'', $this->const_name));
614 if ($moduleNameInConf ===
'propale') {
615 $moduleNameInConf =
'propal';
616 } elseif ($moduleNameInConf ===
'supplierproposal') {
617 $moduleNameInConf =
'supplier_proposal';
620 $conf->modules[$moduleNameInConf] = $moduleNameInConf;
624 $this->db->rollback();
638 protected function _remove($array_sql, $options =
'')
667 if (!$err && !preg_match(
'/(newboxdefonly|noboxes)/', $options)) {
692 $num = count((array) $array_sql);
693 for ($i = 0; $i < $num; $i++) {
695 dol_syslog(get_class($this).
"::_remove", LOG_DEBUG);
696 $result = $this->db->query($array_sql[$i]);
698 $this->error = $this->db->error();
709 $moduleNameInConf = strtolower(preg_replace(
'/^MAIN_MODULE_/',
'', $this->const_name));
711 if ($moduleNameInConf ===
'propale') {
712 $moduleNameInConf =
'propal';
713 } elseif ($moduleNameInConf ===
'supplierproposal') {
714 $moduleNameInConf =
'supplier_proposal';
717 unset($conf->modules[$moduleNameInConf]);
721 $this->db->rollback();
736 $langs->load(
"admin");
738 if ($langs->transnoentitiesnoconv(
"Module".$this->numero.
"Name") !=
"Module".$this->numero.
"Name") {
740 return $langs->transnoentitiesnoconv(
"Module".$this->numero.
"Name");
743 if (is_array($this->langfiles)) {
744 foreach ($this->langfiles as $val) {
751 if ($langs->trans(
"Module".$this->name.
"Name") !=
"Module".$this->name.
"Name") {
753 return $langs->transnoentitiesnoconv(
"Module".$this->
name.
"Name");
757 return $langs->transnoentitiesnoconv($this->
name);
770 $langs->load(
"admin");
772 if ($langs->transnoentitiesnoconv(
"Module".$this->numero.
"Desc") !=
"Module".$this->numero.
"Desc") {
774 return $langs->transnoentitiesnoconv(
"Module".$this->numero.
"Desc");
777 if (is_array($this->langfiles)) {
778 foreach ($this->langfiles as $val) {
785 if ($langs->transnoentitiesnoconv(
"Module".$this->name.
"Desc") !=
"Module".$this->name.
"Desc") {
787 return $langs->trans(
"Module".$this->
name.
"Desc");
804 $langs->load(
"admin");
806 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
807 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
813 $content = file_get_contents($pathoffile,
false,
null, 0, 1024 * 1024);
815 if ((
float) DOL_VERSION >= 6.0) {
816 @include_once DOL_DOCUMENT_ROOT.
'/core/lib/parsemd.lib.php';
828 $content = preg_replace(
'/<a href="/',
'<a target="_blank" rel="noopener noreferrer" href="', $content);
830 $content = nl2br($content);
834 if (!empty($this->descriptionlong)) {
835 if (is_array($this->langfiles)) {
836 foreach ($this->langfiles as $val) {
843 $content = $langs->transnoentitiesnoconv($this->descriptionlong);
863 $pathoffile =
dol_buildpath(strtolower($this->
name).
'/README-'.$langs->defaultlang.
'.md', 0);
868 $tmp = explode(
'_', $langs->defaultlang);
869 $pathoffile =
dol_buildpath(strtolower($this->
name).
'/README-'.$tmp[0].
'.md', 0);
881 return ($filefound ? $pathoffile :
'');
893 $langs->load(
"admin");
895 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
896 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
902 $pathoffile =
dol_buildpath(strtolower($this->
name).
'/ChangeLog-'.$langs->defaultlang.
'.md', 0);
914 $content = file_get_contents($pathoffile);
916 if ((
float) DOL_VERSION >= 6.0) {
917 @include_once DOL_DOCUMENT_ROOT.
'/core/lib/parsemd.lib.php';
921 $content = nl2br($content);
937 return $this->editor_name;
947 return $this->editor_url;
961 $langs->load(
"admin");
965 $newversion = preg_replace(
'/_deprecated/',
'', $this->version);
966 if ($newversion ==
'experimental') {
967 $ret = ($translated ? $langs->transnoentitiesnoconv(
"VersionExperimental") : $newversion);
968 } elseif ($newversion ==
'development') {
969 $ret = ($translated ? $langs->transnoentitiesnoconv(
"VersionDevelopment") : $newversion);
970 } elseif ($newversion ==
'dolibarr') {
972 } elseif ($newversion) {
975 $ret = ($translated ? $langs->transnoentitiesnoconv(
"VersionUnknown") :
'unknown');
978 if (preg_match(
'/_deprecated/', $this->version)) {
979 $ret .= ($translated ?
' ('.$langs->transnoentitiesnoconv(
"Deprecated").
')' : $this->version);
991 if (in_array($this->version, array(
'dolibarr',
'dolibarr_deprecated',
'experimental',
'development'))) {
992 return $this->module_position;
994 if ($this->module_position >= 100000) {
995 return $this->module_position;
997 $position = intval($this->module_position) + 100000;
998 return strval($position);
1011 if ($this->version ==
'dolibarr' || $this->version ==
'dolibarr_deprecated') {
1014 if (!empty($this->version) && !in_array($this->version, array(
'experimental',
'development'))) {
1017 if (!empty($this->editor_name) || !empty($this->editor_url)) {
1020 if ($this->numero >= 100000) {
1034 return $this->langfiles;
1048 $langstring =
"ExportDataset_".$this->export_code[$r];
1049 if ($langs->trans($langstring) == $langstring) {
1051 return $langs->trans($this->export_label[$r]);
1054 return $langs->trans($langstring);
1070 $langstring =
"ImportDataset_".$this->import_code[$r];
1072 if ($langs->trans($langstring) == $langstring) {
1074 return $langs->transnoentitiesnoconv($this->import_label[$r]);
1077 return $langs->transnoentitiesnoconv($langstring);
1093 $sql =
"SELECT tms FROM ".MAIN_DB_PREFIX.
"const";
1094 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1095 $sql .=
" AND entity IN (0, ".((int) $conf->entity).
")";
1097 dol_syslog(get_class($this).
"::getLastActiveDate", LOG_DEBUG);
1098 $resql = $this->db->query($sql);
1102 $obj = $this->db->fetch_object($resql);
1104 return $this->db->jdate($obj->tms);
1123 $sql =
"SELECT tms, note FROM ".MAIN_DB_PREFIX.
"const";
1124 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1125 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
1127 dol_syslog(get_class($this).
"::getLastActiveDate", LOG_DEBUG);
1128 $resql = $this->db->query($sql);
1132 $obj = $this->db->fetch_object($resql);
1136 $tmp = json_decode($obj->note,
true);
1139 'authorid' => empty($tmp[
'authorid']) ?
'' : $tmp[
'authorid'],
1140 'ip' => empty($tmp[
'ip']) ?
'' : $tmp[
'ip'],
1141 'lastactivationdate' => $this->db->jdate($obj->tms),
1142 'lastactivationversion' => (!empty($tmp[
'lastactivationversion']) ? $tmp[
'lastactivationversion'] :
'unknown'),
1160 global $conf, $user;
1165 $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity);
1167 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1168 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1169 $sql .=
" AND entity IN (0, ".$entity.
")";
1171 dol_syslog(get_class($this).
"::_active delete activation constant", LOG_DEBUG);
1172 $resql = $this->db->query($sql);
1177 $note = json_encode(
1179 'authorid' => (is_object($user) ? $user->id : 0),
1180 'ip' => (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']),
1181 'lastactivationversion' => $this->version,
1185 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (name, value, visible, entity, note) VALUES";
1186 $sql .=
" (".$this->db->encrypt($this->const_name);
1187 $sql .=
", ".$this->db->encrypt(
'1');
1188 $sql .=
", 0, ".((int) $entity);
1189 $sql .=
", '".$this->db->escape($note).
"')";
1191 dol_syslog(get_class($this).
"::_active insert activation constant", LOG_DEBUG);
1192 $resql = $this->db->query($sql);
1215 $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity);
1217 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1218 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1219 $sql .=
" AND entity IN (0, ".$entity.
")";
1221 dol_syslog(get_class($this).
"::_unactive", LOG_DEBUG);
1222 $this->db->query($sql);
1253 if (empty($reldir)) {
1257 include_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
1259 foreach ($conf->file->dol_document_root as $dirroot) {
1261 $dirsql = $dirroot.$reldir;
1265 $listofsubdir = array(
'',
'tables/',
'data/');
1266 if ($this->db->type ==
'pgsql') {
1267 $listofsubdir[] =
'../pgsql/functions/';
1270 foreach ($listofsubdir as $subdir) {
1271 $dir = $dirsql.$subdir;
1273 $handle = @opendir($dir);
1274 if (is_resource($handle)) {
1279 while (($file = readdir($handle)) !==
false) {
1283 foreach ($files as $file) {
1284 if ($onlywithsuffix) {
1285 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1292 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 4) ==
'llx_') {
1304 while (($file = readdir($handle)) !==
false) {
1308 foreach ($files as $file) {
1309 if ($onlywithsuffix) {
1310 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1317 if (preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 4) ==
'llx_') {
1329 while (($file = readdir($handle)) !==
false) {
1333 foreach ($files as $file) {
1334 if ($onlywithsuffix) {
1335 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1342 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 9) ==
'functions') {
1354 while (($file = readdir($handle)) !==
false) {
1358 foreach ($files as $file) {
1359 if ($onlywithsuffix) {
1360 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1367 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 4) ==
'data') {
1379 while (($file = readdir($handle)) !==
false) {
1383 foreach ($files as $file) {
1384 if ($onlywithsuffix) {
1385 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1392 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 6) ==
'update') {
1411 dol_syslog(
"A module wants to load sql files from ".$reldir.
" but this directory was not found.", LOG_WARNING);
1428 include_once DOL_DOCUMENT_ROOT.
'/core/class/infobox.class.php';
1434 if (is_array($this->boxes)) {
1435 dol_syslog(get_class($this).
"::insert_boxes", LOG_DEBUG);
1439 foreach ($this->boxes as $key => $value) {
1440 $file = isset($this->boxes[$key][
'file']) ? $this->boxes[$key][
'file'] :
'';
1441 $note = isset($this->boxes[$key][
'note']) ? $this->boxes[$key][
'note'] :
'';
1442 $enabledbydefaulton = isset($this->boxes[$key][
'enabledbydefaulton']) ? $this->boxes[$key][
'enabledbydefaulton'] :
'Home';
1445 $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] :
'';
1448 $note = isset($this->boxes[$key][2]) ? $this->boxes[$key][2] :
'';
1452 $sql =
"SELECT count(*) as nb FROM ".MAIN_DB_PREFIX.
"boxes_def";
1453 $sql .=
" WHERE file = '".$this->db->escape($file).
"'";
1454 $sql .=
" AND entity = ".$conf->entity;
1456 $sql .=
" AND note ='".$this->db->escape($note).
"'";
1459 $result = $this->db->query($sql);
1461 $obj = $this->db->fetch_object($result);
1462 if ($obj->nb == 0) {
1466 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"boxes_def (file, entity, note)";
1467 $sql .=
" VALUES ('".$this->db->escape($file).
"', ";
1468 $sql .= $conf->entity.
", ";
1469 $sql .= $note ?
"'".$this->db->escape($note).
"'" :
"null";
1472 dol_syslog(get_class($this).
"::insert_boxes", LOG_DEBUG);
1473 $resql = $this->db->query($sql);
1478 if (!$err && !preg_match(
'/newboxdefonly/', $option)) {
1479 $lastid = $this->db->last_insert_id(MAIN_DB_PREFIX.
"boxes_def",
"rowid");
1481 foreach ($pos_name as $key2 => $val2) {
1483 if ($enabledbydefaulton && $val2 != $enabledbydefaulton) {
1487 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"boxes (box_id, position, box_order, fk_user, entity)";
1488 $sql .=
" VALUES (".((int) $lastid).
", ".((int) $key2).
", '0', 0, ".((int) $conf->entity).
")";
1490 dol_syslog(get_class($this).
"::insert_boxes onto page ".$key2.
"=".$val2, LOG_DEBUG);
1491 $resql = $this->db->query($sql);
1499 $this->db->commit();
1501 $this->error = $this->db->lasterror();
1502 $this->db->rollback();
1507 $this->error = $this->db->lasterror();
1530 if (is_array($this->boxes)) {
1531 foreach ($this->boxes as $key => $value) {
1533 if (empty($this->boxes[$key][
'file'])) {
1534 $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] :
'';
1536 $file = $this->boxes[$key][
'file'];
1544 if ($file ==
'box_graph_product_distribution.php') {
1545 if (isModEnabled(
"product") || isModEnabled(
"service")) {
1546 dol_syslog(
"We discard deleting module ".$file.
" because another module still active requires it.");
1551 if ($this->db->type ==
'sqlite3') {
1554 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes ";
1555 $sql .=
"WHERE ".MAIN_DB_PREFIX.
"boxes.box_id IN (";
1556 $sql .=
"SELECT ".MAIN_DB_PREFIX.
"boxes_def.rowid ";
1557 $sql .=
"FROM ".MAIN_DB_PREFIX.
"boxes_def ";
1558 $sql .=
"WHERE ".MAIN_DB_PREFIX.
"boxes_def.file = '".$this->db->escape($file).
"') ";
1559 $sql .=
"AND ".MAIN_DB_PREFIX.
"boxes.entity = ".$conf->entity;
1561 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes";
1562 $sql .=
" USING ".MAIN_DB_PREFIX.
"boxes, ".MAIN_DB_PREFIX.
"boxes_def";
1563 $sql .=
" WHERE ".MAIN_DB_PREFIX.
"boxes.box_id = ".MAIN_DB_PREFIX.
"boxes_def.rowid";
1564 $sql .=
" AND ".MAIN_DB_PREFIX.
"boxes_def.file = '".$this->db->escape($file).
"'";
1565 $sql .=
" AND ".MAIN_DB_PREFIX.
"boxes.entity = ".$conf->entity;
1568 dol_syslog(get_class($this).
"::delete_boxes", LOG_DEBUG);
1569 $resql = $this->db->query($sql);
1571 $this->error = $this->db->lasterror();
1575 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes_def";
1576 $sql .=
" WHERE file = '".$this->db->escape($file).
"'";
1577 $sql .=
" AND entity = ".$conf->entity;
1579 dol_syslog(get_class($this).
"::delete_boxes", LOG_DEBUG);
1580 $resql = $this->db->query($sql);
1582 $this->error = $this->db->lasterror();
1600 include_once DOL_DOCUMENT_ROOT .
'/core/class/infobox.class.php';
1601 include_once DOL_DOCUMENT_ROOT .
'/cron/class/cronjob.class.php';
1603 global $conf, $user;
1607 if (is_array($this->cronjobs)) {
1608 dol_syslog(get_class($this) .
"::insert_cronjobs", LOG_DEBUG);
1610 foreach ($this->cronjobs as $key => $value) {
1613 $entity = isset($value[
'entity']) ? $value[
'entity'] : $conf->entity;
1614 $label = isset($value[
'label']) ? $value[
'label'] :
'';
1615 $jobtype = isset($value[
'jobtype']) ? $value[
'jobtype'] :
'';
1616 $classesname = isset($value[
'class']) ? $value[
'class'] :
'';
1617 $objectname = isset($value[
'objectname']) ? $value[
'objectname'] :
'';
1618 $methodename = isset($value[
'method']) ? $value[
'method'] :
'';
1619 $command = isset($value[
'command']) ? $value[
'command'] :
'';
1620 $params = isset($value[
'parameters']) ? $value[
'parameters'] :
'';
1621 $md5params = isset($value[
'md5params']) ? $value[
'md5params'] :
'';
1622 $comment = isset($value[
'comment']) ? $value[
'comment'] :
'';
1623 $frequency = isset($value[
'frequency']) ? $value[
'frequency'] :
'';
1624 $unitfrequency = isset($value[
'unitfrequency']) ? $value[
'unitfrequency'] :
'';
1625 $priority = isset($value[
'priority']) ? $value[
'priority'] :
'';
1626 $datestart = isset($value[
'datestart']) ? $value[
'datestart'] :
'';
1627 $dateend = isset($value[
'dateend']) ? $value[
'dateend'] :
'';
1628 $datenextrun = isset($value[
'datenextrun']) ? $value[
'datenextrun'] : $now;
1629 $status = isset($value[
'status']) ? $value[
'status'] :
'';
1630 $maxrun = isset($value[
'maxrun']) ? $value[
'maxrun'] : 0;
1631 $libname = isset($value[
'libname']) ? $value[
'libname'] :
'';
1632 $test = isset($value[
'test']) ? $value[
'test'] :
'';
1635 $sql =
"SELECT count(*) as nb FROM " . MAIN_DB_PREFIX .
"cronjob";
1637 $sql .=
" WHERE label = '".$this->db->escape($label).
"'";
1639 $sql .=
" AND classesname = '" . $this->db->escape($classesname) .
"'";
1642 $sql .=
" AND objectname = '" . $this->db->escape($objectname) .
"'";
1645 $sql .=
" AND methodename = '" . $this->db->escape($methodename) .
"'";
1648 $sql .=
" AND command = '" . $this->db->escape($command) .
"'";
1651 $sql .=
" AND params = '" . $this->db->escape($params) .
"'";
1653 $sql .=
" AND entity = " . ((int) $entity);
1655 $result = $this->db->query($sql);
1657 $this->error = $this->db->lasterror();
1663 $obj = $this->db->fetch_object($result);
1668 $cronjob =
new Cronjob($this->db);
1670 $cronjob->entity = $entity;
1671 $cronjob->label = $label;
1672 $cronjob->jobtype = $jobtype;
1673 $cronjob->classesname = $classesname;
1674 $cronjob->objectname = $objectname;
1675 $cronjob->methodename = $methodename;
1676 $cronjob->command = $command;
1677 $cronjob->params = $params;
1678 $cronjob->md5params = $md5params;
1679 $cronjob->comment = $comment;
1680 $cronjob->frequency = $frequency;
1681 $cronjob->unitfrequency = $unitfrequency;
1682 $cronjob->priority = $priority;
1683 $cronjob->datestart = $datestart;
1684 $cronjob->dateend = $dateend;
1685 $cronjob->datenextrun = $datenextrun;
1686 $cronjob->maxrun = $maxrun;
1687 $cronjob->status = $status;
1688 $cronjob->test = $test;
1689 $cronjob->libname = $libname;
1690 $cronjob->module_name = empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class;
1692 $retCreate = $cronjob->create($user);
1694 if ($retCreate < 0) {
1695 $this->error = implode(
"\n", array_merge([$cronjob->error], $cronjob->errors));
1717 if (is_array($this->cronjobs)) {
1718 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"cronjob";
1719 $sql .=
" WHERE module_name = '".$this->db->escape(empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class).
"'";
1720 $sql .=
" AND entity = ".$conf->entity;
1721 $sql .=
" AND test = '1'";
1724 dol_syslog(get_class($this).
"::delete_cronjobs", LOG_DEBUG);
1725 $resql = $this->db->query($sql);
1727 $this->error = $this->db->lasterror();
1748 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1749 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" like '".$this->db->escape($this->const_name).
"_TABS_%'";
1750 $sql .=
" AND entity = ".$conf->entity;
1752 dol_syslog(get_class($this).
"::delete_tabs", LOG_DEBUG);
1753 if (!$this->db->query($sql)) {
1754 $this->error = $this->db->lasterror();
1774 if (!empty($this->tabs)) {
1775 dol_syslog(get_class($this).
"::insert_tabs", LOG_DEBUG);
1778 foreach ($this->tabs as $key => $value) {
1779 if (is_array($value) && count($value) == 0) {
1783 $entity = $conf->entity;
1786 if (is_array($value)) {
1787 $newvalue = $value[
'data'];
1788 if (isset($value[
'entity'])) {
1789 $entity = $value[
'entity'];
1794 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (";
1799 $sql .=
", visible";
1802 $sql .=
" VALUES (";
1803 $sql .= $this->db->encrypt($this->const_name.
"_TABS_".$i);
1804 $sql .=
", 'chaine'";
1805 $sql .=
", ".$this->db->encrypt($newvalue);
1808 $sql .=
", ".((int) $entity);
1811 $resql = $this->db->query($sql);
1814 if ($this->db->lasterrno() !=
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1815 $this->error = $this->db->lasterror();
1816 $this->errors[] = $this->db->lasterror();
1841 if (empty($this->
const)) {
1847 foreach ($this->
const as $key => $value) {
1848 $name = $this->
const[$key][0];
1849 $type = $this->
const[$key][1];
1850 $val = $this->
const[$key][2];
1851 $note = isset($this->
const[$key][3]) ? $this->
const[$key][3] :
'';
1852 $visible = isset($this->
const[$key][4]) ? $this->
const[$key][4] : 0;
1853 $entity = (!empty($this->
const[$key][5]) && $this->
const[$key][5] !=
'current') ? 0 : $conf->entity;
1856 if (empty($visible)) {
1859 if (empty($val) && $val !=
'0') {
1863 $sql =
"SELECT count(*) as nb";
1864 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1865 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
1866 $sql .=
" AND entity = ".((int) $entity);
1868 $result = $this->db->query($sql);
1870 $row = $this->db->fetch_row($result);
1873 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (name,type,value,note,visible,entity)";
1874 $sql .=
" VALUES (";
1875 $sql .= $this->db->encrypt($name);
1876 $sql .=
",'".$this->db->escape($type).
"'";
1877 $sql .=
",".(($val !=
'') ? $this->db->encrypt($val) :
"''");
1878 $sql .=
",".($note ?
"'".$this->db->escape($note).
"'" :
"null");
1879 $sql .=
",'".$this->db->escape($visible).
"'";
1880 $sql .=
",".$entity;
1883 if (!$this->db->query($sql)) {
1887 dol_syslog(__METHOD__.
" constant '".$name.
"' already exists", LOG_DEBUG);
1910 if (empty($this->
const)) {
1914 foreach ($this->
const as $key => $value) {
1915 $name = $this->
const[$key][0];
1916 $deleteonunactive = (!empty($this->
const[$key][6])) ? 1 : 0;
1918 if ($deleteonunactive) {
1919 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1920 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
1921 $sql .=
" AND entity in (0, ".$conf->entity.
")";
1922 dol_syslog(get_class($this).
"::delete_const", LOG_DEBUG);
1923 if (!$this->db->query($sql)) {
1924 $this->error = $this->db->lasterror();
1945 global $conf, $user;
1948 $entity = (!empty($force_entity) ? $force_entity : $conf->entity);
1950 dol_syslog(get_class($this).
"::insert_permissions", LOG_DEBUG);
1953 $sql_del =
"SELECT ".$this->db->decrypt(
'value').
" as value";
1954 $sql_del .=
" FROM ".MAIN_DB_PREFIX.
"const";
1955 $sql_del .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1956 $sql_del .=
" AND entity IN (0,".((int) $entity).
")";
1958 $resql = $this->db->query($sql_del);
1961 $obj = $this->db->fetch_object($resql);
1963 if ($obj !==
null && !empty($obj->value) && !empty($this->rights)) {
1964 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1978 foreach ($this->rights as $key => $value) {
1979 $r_id = $this->rights[$key][self::KEY_ID];
1980 $r_label = $this->rights[$key][self::KEY_LABEL];
1981 $r_type = $this->rights[$key][self::KEY_TYPE] ??
'w';
1982 $r_default = $this->rights[$key][self::KEY_DEFAULT] ?? 0;
1983 $r_perms = $this->rights[$key][self::KEY_FIRST_LEVEL] ??
'';
1984 $r_subperms = $this->rights[$key][self::KEY_SECOND_LEVEL] ??
'';
1987 if (empty($r_perms)) {
1992 $r_module = (empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class);
1995 $r_module_origin =
'';
1997 if (isset($this->rights[$key][self::KEY_MODULE])) {
1999 $r_module = $this->rights[$key][self::KEY_MODULE];
2001 $r_module_origin = (empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class);
2005 $r_enabled = $this->rights[$key][self::KEY_ENABLED] ??
'1';
2008 $sql =
"SELECT count(*) as nb FROM ".MAIN_DB_PREFIX.
"rights_def";
2009 $sql .=
" WHERE entity = ".((int) $entity);
2010 $sql .=
" AND id = ".((int) $r_id);
2012 $resqlselect = $this->db->query($sql);
2014 $objcount = $this->db->fetch_object($resqlselect);
2015 if ($objcount && $objcount->nb == 0) {
2016 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"rights_def (";
2019 $sql .=
", libelle";
2021 $sql .=
", module_origin";
2023 $sql .=
", bydefault";
2025 $sql .=
", subperms";
2026 $sql .=
", enabled";
2027 $sql .=
") VALUES (";
2028 $sql .= ((int) $r_id);
2029 $sql .=
", ".((int) $entity);
2030 $sql .=
", '".$this->db->escape($r_label).
"'";
2031 $sql .=
", '".$this->db->escape($r_module).
"'";
2032 $sql .=
", '".$this->db->escape($r_module_origin).
"'";
2033 $sql .=
", '".$this->db->escape($r_type).
"'";
2034 $sql .=
", ".((int) $r_default);
2035 $sql .=
", '".$this->db->escape($r_perms).
"'";
2036 $sql .=
", '".$this->db->escape($r_subperms).
"'";
2037 $sql .=
", '".$this->db->escape($r_enabled).
"'";
2040 $resqlinsert = $this->db->query($sql, 1);
2042 if (!$resqlinsert) {
2043 if ($this->db->errno() !=
"DB_ERROR_RECORD_ALREADY_EXISTS") {
2044 $this->error = $this->db->lasterror();
2048 dol_syslog(get_class($this).
"::insert_permissions record already exists", LOG_INFO);
2052 $this->db->free($resqlinsert);
2055 $this->db->free($resqlselect);
2059 if (!empty($reinitadminperms)) {
2060 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"user WHERE admin = 1";
2061 dol_syslog(get_class($this).
"::insert_permissions Search all admin users", LOG_DEBUG);
2063 $resqlseladmin = $this->db->query($sql, 1);
2065 if ($resqlseladmin) {
2066 $num = $this->db->num_rows($resqlseladmin);
2069 $obj2 = $this->db->fetch_object($resqlseladmin);
2070 dol_syslog(get_class($this).
"::insert_permissions Add permission id ".$r_id.
" to user id=".$obj2->rowid);
2072 $tmpuser =
new User($this->db);
2073 $result = $tmpuser->fetch($obj2->rowid);
2075 $tmpuser->addrights($r_id,
'',
'', 0, 1);
2077 dol_syslog(get_class($this).
"::insert_permissions Failed to add the permission to user because fetch return an error", LOG_ERR);
2087 if (!empty($reinitadminperms) && !empty($user->admin)) {
2089 $user->clearrights();
2090 $user->loadRights();
2093 $this->db->free($resql);
2095 $this->error = $this->db->lasterror();
2116 $module = empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class;
2118 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"rights_def";
2119 $sql .=
" WHERE (module = '".$this->db->escape($module).
"' OR module_origin = '".$this->db->escape($module).
"')";
2122 if (empty($this->core_enabled)) {
2123 $sql .=
" AND entity = ".((int) $conf->entity);
2126 dol_syslog(get_class($this).
"::delete_permissions", LOG_DEBUG);
2127 if (!$this->db->query($sql)) {
2128 $this->error = $this->db->lasterror();
2145 global $conf, $user;
2147 if (!is_array($this->menu) || empty($this->menu)) {
2151 include_once DOL_DOCUMENT_ROOT.
'/core/class/menubase.class.php';
2153 dol_syslog(get_class($this).
"::insert_menus", LOG_DEBUG);
2158 $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity);
2162 foreach ($this->menu as $key => $value) {
2164 $menu->menu_handler =
'all';
2167 $menu->module = (empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class);
2169 if (!$this->menu[$key][
'fk_menu']) {
2173 $fk_parent = $this->menu[$key][
'fk_menu'];
2175 if (preg_match(
'/^r=/', $fk_parent)) {
2176 $fk_parent = str_replace(
'r=',
'', $fk_parent);
2177 if (isset($this->menu[$fk_parent][
'rowid'])) {
2178 $menu->fk_menu = $this->menu[$fk_parent][
'rowid'];
2181 } elseif (preg_match(
'/^fk_mainmenu=([a-zA-Z0-9_]+),fk_leftmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) {
2182 $menu->fk_menu = -1;
2183 $menu->fk_mainmenu = $reg[1];
2184 $menu->fk_leftmenu = $reg[2];
2186 } elseif (preg_match(
'/^fk_mainmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) {
2187 $menu->fk_menu = -1;
2188 $menu->fk_mainmenu = $reg[1];
2189 $menu->fk_leftmenu =
'';
2192 if (!$foundparent) {
2193 $this->error =
"ErrorBadDefinitionOfMenuArrayInModuleDescriptor";
2194 dol_syslog(get_class($this).
"::insert_menus ".$this->error.
" ".$this->menu[$key][
'fk_menu'], LOG_ERR);
2198 $menu->type = $this->menu[$key][
'type'];
2199 $menu->mainmenu = isset($this->menu[$key][
'mainmenu']) ? $this->menu[$key][
'mainmenu'] : (isset($menu->fk_mainmenu) ? $menu->fk_mainmenu :
'');
2200 $menu->leftmenu = isset($this->menu[$key][
'leftmenu']) ? $this->menu[$key][
'leftmenu'] :
'';
2201 $menu->title = $this->menu[$key][
'titre'];
2202 $menu->prefix = isset($this->menu[$key][
'prefix']) ? $this->menu[$key][
'prefix'] :
'';
2203 $menu->url = $this->menu[$key][
'url'];
2204 $menu->langs = isset($this->menu[$key][
'langs']) ? $this->menu[$key][
'langs'] :
'';
2205 $menu->position = $this->menu[$key][
'position'];
2206 $menu->perms = $this->menu[$key][
'perms'];
2207 $menu->target = isset($this->menu[$key][
'target']) ? $this->menu[$key][
'target'] :
'';
2208 $menu->user = $this->menu[$key][
'user'];
2209 $menu->enabled = isset($this->menu[$key][
'enabled']) ? $this->menu[$key][
'enabled'] : 0;
2210 $menu->position = $this->menu[$key][
'position'];
2211 $menu->entity = $entity;
2214 $result = $menu->create($user);
2216 $this->menu[$key][
'rowid'] = $result;
2218 $this->error = $menu->error;
2219 dol_syslog(get_class($this).
'::insert_menus result='.$result.
" ".$this->error, LOG_ERR);
2227 $this->db->commit();
2229 dol_syslog(get_class($this).
"::insert_menus ".$this->error, LOG_ERR);
2230 $this->db->rollback();
2251 $module = empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class;
2253 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"menu";
2254 $sql .=
" WHERE module = '".$this->db->escape($module).
"'";
2255 $sql .=
" AND menu_handler = 'all'";
2256 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
2258 dol_syslog(get_class($this).
"::delete_menus", LOG_DEBUG);
2259 $resql = $this->db->query($sql);
2261 $this->error = $this->db->lasterror();
2277 global $langs, $conf;
2282 if (isset($this->dirs) && is_array($this->dirs)) {
2283 foreach ($this->dirs as $key => $value) {
2286 if (!is_array($value)) {
2289 $constname = $this->const_name.
"_DIR_";
2290 $dir = $this->dirs[$key][1];
2291 $addtodatabase = empty($this->dirs[$key][2]) ?
'' : $this->dirs[$key][2];
2292 $subname = empty($this->dirs[$key][3]) ?
'' : strtoupper($this->dirs[$key][3]);
2293 $forcename = empty($this->dirs[$key][4]) ?
'' : strtoupper($this->dirs[$key][4]);
2295 if (!empty($forcename)) {
2296 $constname =
'MAIN_MODULE_'.$forcename.
"_DIR_";
2298 if (!empty($subname)) {
2299 $constname = $constname.$subname.
"_";
2302 $name = $constname.strtoupper($this->dirs[$key][0]);
2307 $fulldir = DOL_DATA_ROOT.$dir;
2309 $fulldir = DOL_DATA_ROOT.
"/".$conf->entity.$dir;
2312 if (!empty($fulldir) && !file_exists($fulldir)) {
2313 if (
dol_mkdir($fulldir, DOL_DATA_ROOT) < 0) {
2314 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $fulldir);
2315 dol_syslog(get_class($this).
"::_init ".$this->error, LOG_ERR);
2321 if (!empty($addtodatabase) && !empty($name)) {
2350 $sql =
"SELECT count(*)";
2351 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
2352 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
2353 $sql .=
" AND entity = ".$conf->entity;
2355 dol_syslog(get_class($this).
"::insert_dirs", LOG_DEBUG);
2356 $result = $this->db->query($sql);
2358 $row = $this->db->fetch_row($result);
2361 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (name, type, value, note, visible, entity)";
2362 $sql .=
" VALUES (".$this->db->encrypt($name).
", 'chaine', ".$this->db->encrypt($dir).
", '".$this->db->escape(
"Directory for module ".$this->
name).
"', '0', ".((int) $conf->entity).
")";
2364 dol_syslog(get_class($this).
"::insert_dirs", LOG_DEBUG);
2365 $this->db->query($sql);
2368 $this->error = $this->db->lasterror();
2389 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
2390 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" LIKE '".$this->db->escape($this->const_name).
"_DIR_%'";
2391 $sql .=
" AND entity = ".$conf->entity;
2393 dol_syslog(get_class($this).
"::delete_dirs", LOG_DEBUG);
2394 if (!$this->db->query($sql)) {
2395 $this->error = $this->db->lasterror();
2412 global $conf, $langs;
2416 if (is_array($this->module_parts)) {
2417 if (empty($this->module_parts[
'icon']) && !empty($this->picto) && preg_match(
'/^fa\-/', $this->picto)) {
2418 $this->module_parts[
'icon'] = $this->picto;
2421 foreach ($this->module_parts as $key => $value) {
2422 if (is_array($value) && count($value) == 0) {
2427 if ($key ==
'websitetemplates' && $value == 1) {
2431 $docs =
dol_dir_list($srcroot,
'directories', 0,
'website_.*$');
2432 foreach ($docs as $cursorfile) {
2433 $src = $srcroot.
'/'.$cursorfile[
'name'];
2434 $dest = DOL_DATA_ROOT.
'/doctemplates/websites/'.$cursorfile[
'name'];
2441 $result = dol_compress_dir($src, $dest.
'.zip',
'zip');
2444 $this->error = ($errormsg ? $errormsg : $langs->trans(
'ErrorFailToCreateZip', $dest));
2445 $this->errors[] = ($errormsg ? $errormsg : $langs->trans(
'ErrorFailToCreateZip', $dest));
2450 $docs =
dol_dir_list($srcroot,
'files', 0,
'website_.*\.jpg$');
2451 foreach ($docs as $cursorfile) {
2452 $src = $srcroot.
'/'.$cursorfile[
'name'];
2453 $dest = DOL_DATA_ROOT.
'/doctemplates/websites/'.$cursorfile[
'name'];
2459 $entity = $conf->entity;
2463 if (is_array($value)) {
2466 if (isset($value[
'data']) && is_array($value[
'data'])) {
2467 $newvalue = json_encode($value[
'data']);
2468 if (isset($value[
'entity'])) {
2469 $entity = $value[
'entity'];
2471 } elseif (isset($value[
'data']) && !is_array($value[
'data'])) {
2472 $newvalue = $value[
'data'];
2473 if (isset($value[
'entity'])) {
2474 $entity = $value[
'entity'];
2477 $newvalue = json_encode($value);
2481 if (!empty($newvalue)) {
2482 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (";
2487 $sql .=
", visible";
2490 $sql .=
" VALUES (";
2491 $sql .=
" ".$this->db->encrypt($this->const_name.
"_".strtoupper($key), 1);
2492 $sql .=
", 'chaine'";
2493 $sql .=
", ".$this->db->encrypt($newvalue, 1);
2496 $sql .=
", ".((int) $entity);
2499 dol_syslog(get_class($this).
"::insert_module_parts for key=".$this->const_name.
"_".strtoupper($key), LOG_DEBUG);
2501 $resql = $this->db->query($sql, 1);
2503 if ($this->db->lasterrno() !=
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2505 $this->error = $this->db->lasterror();
2507 dol_syslog(get_class($this).
"::insert_module_parts for ".$this->const_name.
"_".strtoupper($key).
" Record already exists.", LOG_WARNING);
2529 if (is_array($this->module_parts)) {
2530 dol_syslog(get_class($this).
"::delete_module_parts", LOG_DEBUG);
2532 if (empty($this->module_parts[
'icon']) && !empty($this->picto) && preg_match(
'/^fa\-/', $this->picto)) {
2533 $this->module_parts[
'icon'] = $this->picto;
2536 foreach ($this->module_parts as $key => $value) {
2538 if (is_array($value) && isset($value[
'entity'])) {
2539 $entity = $value[
'entity'];
2541 $entity = $conf->entity;
2544 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
2545 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" LIKE '".$this->db->escape($this->const_name).
"_".strtoupper($key).
"'";
2546 $sql .=
" AND entity = ".((int) $entity);
2548 if (!$this->db->query($sql)) {
2549 $this->error = $this->db->lasterror();
2566 public function init($options =
'')
2568 return $this->
_init(array(), $options);
2579 public function remove($options =
'')
2581 return $this->
_remove(array(), $options);
2599 $imginfo =
"info_black";
2602 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($this)));
2606 if (preg_match(
'/development/i', $version)) {
2607 $versiontrans .=
'warning';
2609 if (preg_match(
'/experimental/i', $version)) {
2610 $versiontrans .=
'warning';
2612 if (preg_match(
'/deprecated/i', $version)) {
2613 $versiontrans .=
'warning';
2617 <div class="box-flex-item info-box-module'
2618 .(getDolGlobalString($const_name) ?
'' :
' --disabled')
2620 .($this->needUpdate ?
' --need-update' :
'')
2622 <div class="info-box info-box-sm info-box-module">
2623 <div class="info-box-icon'.(!
getDolGlobalString($const_name) ?
'' :
' info-box-icon-module-enabled'.($versiontrans ?
' info-box-icon-module-warning' :
'')).
'">';
2628 if (!empty($this->picto)) {
2629 if (preg_match(
'/^\//i', $this->picto)) {
2630 $return .=
img_picto($alttext, $this->picto,
'class="inline-block valignmiddle"', 1);
2632 $return .=
img_object($alttext, $this->picto,
'class="inline-block valignmiddle"');
2635 $return .=
img_object($alttext,
'generic',
'class="inline-block valignmiddle"');
2638 if ($this->
isCoreOrExternalModule() ==
'external' || preg_match(
'/development|experimental|deprecated/i', $version)) {
2639 $versionTitle = $langs->trans(
"Version").
' '.$this->
getVersion(1);
2640 if ($this->needUpdate) {
2641 $versionTitle .=
'<br>'.$langs->trans(
'ModuleUpdateAvailable').
' : '.
$this->lastVersion;
2644 $return .=
'<span class="info-box-icon-version'.($versiontrans ?
' '.$versiontrans :
'').
' classfortooltip" title="'.
dol_escape_js($versionTitle).
'" >';
2646 $return .=
'</span>';
2650 <div class="info-box-content info-box-text-module'.(!
getDolGlobalString($const_name) ?
'' :
' info-box-module-enabled'.($versiontrans ?
' info-box-content-warning' :
'')).
'">
2651 <span class="info-box-title">'.$this->
getName().
'</span>
2654 $return .=
'<div class="valignmiddle inline-block info-box-more">';
2656 $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>';
2657 $return .= '</div><br>';
2659 $return .= '<div class="valignmiddle
inline-block info-box-actions
">';
2660 $return .= '<div class="valignmiddle
inline-block info-box-setup
">';
2661 $return .= $codetoconfig;
2662 $return .= '</div>';
2663 $return .= '<div class="valignmiddle
inline-block marginleftonly marginrightonly
">';
2664 $return .= $codeenabledisable;
2665 $return .= '</div>';
2666 $return .= '</div>';
2669 </div><!-- /.info-box-content -->
2670 </div><!-- /.info-box -->
2684 public function checkForUpdate()
2686 require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
2687 if (!empty($this->url_last_version)) {
2688 $lastVersion = getURLContent($this->url_last_version, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only
2689 if (isset($lastVersion['content']) && strlen($lastVersion['content']) < 30) {
2690 // 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 _ . -
2691 $this->lastVersion = preg_replace("/[^a-zA-Z0-9_\.\-]+/
", "", $lastVersion['content']);
2692 if (version_compare($this->lastVersion, $this->version) > 0) {
2693 $this->needUpdate = true;
2696 $this->needUpdate = false;
2724 protected function declareNewDictionary($dictionaryArray, $langs = '')
2726 $fields = array('name', 'lib', 'sql', 'sqlsort', 'field', 'fieldvalue', 'fieldinsert', 'rowid', 'cond', 'help', 'fieldcheck');
2728 foreach ($fields as $field) {
2729 if (isset($dictionaryArray[$field])) {
2730 $this->dictionaries['tab'.$field][] = $dictionaryArray[$field];
2733 if ($langs && !in_array($langs, $this->dictionaries[$langs])) {
2734 $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.
$needUpdate
true indicate this module need update
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.
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,...
$lastVersion
Module last version.
_unactive()
Module deactivation.
getDesc()
Gives the translated module description if translation exists in admin.lang or the default module des...
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_now($mode='auto')
Return date for now.
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.
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.