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;
260 public $export_enabled;
261 public $export_permission;
262 public $export_fields_array;
263 public $export_TypeFields_array;
264 public $export_entities_array;
265 public $export_aggregate_array;
266 public $export_examplevalues_array;
267 public $export_help_array;
268 public $export_special_array;
269 public $export_dependencies_array;
270 public $export_sql_start;
271 public $export_sql_end;
272 public $export_sql_order;
285 public $import_label;
288 public $import_entities_array;
289 public $import_tables_array;
290 public $import_tables_creator_array;
291 public $import_fields_array;
292 public $import_fieldshidden_array;
293 public $import_convertvalue_array;
294 public $import_regex_array;
295 public $import_examplevalues_array;
296 public $import_updatekeys_array;
297 public $import_run_sql_after_array;
298 public $import_TypeFields_array;
299 public $import_help_array;
309 public $always_enabled;
319 public $core_enabled;
335 public $config_page_url;
355 public $conflictwith;
367 public $warnings_activation;
374 public $warnings_activation_ext;
381 public $warnings_unactivation;
395 public $need_dolibarr_version;
397 public $need_javascript_ajax;
399 public $enabled_bydefault;
404 public $hidden =
false;
409 public $url_last_version;
438 protected function _init($array_sql, $options =
'')
462 if (!$err && !preg_match(
'/newboxdefonly/', $options)) {
467 if (!$err && !preg_match(
'/noboxes/', $options)) {
492 $num = count($array_sql);
493 for ($i = 0; $i < $num; $i++) {
495 $val = $array_sql[$i];
498 if (is_array($val)) {
500 $ignoreerror = $val[
'ignoreerror'];
503 $sql = str_replace(
'__ENTITY__', (
string) $conf->entity, $sql);
505 dol_syslog(get_class($this).
"::_init ignoreerror=".$ignoreerror, LOG_DEBUG);
506 $result = $this->db->query($sql, $ignoreerror);
509 $this->error = $this->db->lasterror();
512 dol_syslog(get_class($this).
"::_init Warning ".$this->db->lasterror(), LOG_WARNING);
522 $moduleNameInConf = strtolower(preg_replace(
'/^MAIN_MODULE_/',
'', $this->const_name));
524 if ($moduleNameInConf ===
'propale') {
525 $moduleNameInConf =
'propal';
526 } elseif ($moduleNameInConf ===
'supplierproposal') {
527 $moduleNameInConf =
'supplier_proposal';
530 $conf->modules[$moduleNameInConf] = $moduleNameInConf;
534 $this->db->rollback();
548 protected function _remove($array_sql, $options =
'')
577 if (!$err && !preg_match(
'/(newboxdefonly|noboxes)/', $options)) {
602 $num = count((array) $array_sql);
603 for ($i = 0; $i < $num; $i++) {
605 dol_syslog(get_class($this).
"::_remove", LOG_DEBUG);
606 $result = $this->db->query($array_sql[$i]);
608 $this->error = $this->db->error();
619 $moduleNameInConf = strtolower(preg_replace(
'/^MAIN_MODULE_/',
'', $this->const_name));
621 if ($moduleNameInConf ===
'propale') {
622 $moduleNameInConf =
'propal';
623 } elseif ($moduleNameInConf ===
'supplierproposal') {
624 $moduleNameInConf =
'supplier_proposal';
627 unset($conf->modules[$moduleNameInConf]);
631 $this->db->rollback();
646 $langs->load(
"admin");
648 if ($langs->transnoentitiesnoconv(
"Module".$this->numero.
"Name") !=
"Module".$this->numero.
"Name") {
650 return $langs->transnoentitiesnoconv(
"Module".$this->numero.
"Name");
653 if (is_array($this->langfiles)) {
654 foreach ($this->langfiles as $val) {
661 if ($langs->trans(
"Module".$this->name.
"Name") !=
"Module".$this->name.
"Name") {
663 return $langs->transnoentitiesnoconv(
"Module".$this->
name.
"Name");
667 return $langs->transnoentitiesnoconv($this->
name);
680 $langs->load(
"admin");
682 if ($langs->transnoentitiesnoconv(
"Module".$this->numero.
"Desc") !=
"Module".$this->numero.
"Desc") {
684 return $langs->transnoentitiesnoconv(
"Module".$this->numero.
"Desc");
687 if (is_array($this->langfiles)) {
688 foreach ($this->langfiles as $val) {
695 if ($langs->transnoentitiesnoconv(
"Module".$this->name.
"Desc") !=
"Module".$this->name.
"Desc") {
697 return $langs->trans(
"Module".$this->
name.
"Desc");
714 $langs->load(
"admin");
716 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
717 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
723 $content = file_get_contents($pathoffile,
false,
null, 0, 1024 * 1024);
725 if ((
float) DOL_VERSION >= 6.0) {
726 @include_once DOL_DOCUMENT_ROOT.
'/core/lib/parsemd.lib.php';
738 $content = preg_replace(
'/<a href="/',
'<a target="_blank" rel="noopener noreferrer" href="', $content);
740 $content = nl2br($content);
744 if (!empty($this->descriptionlong)) {
745 if (is_array($this->langfiles)) {
746 foreach ($this->langfiles as $val) {
753 $content = $langs->transnoentitiesnoconv($this->descriptionlong);
757 return '<div class="moduledesclong">'.$content.
'</div>';
773 $pathoffile =
dol_buildpath(strtolower($this->
name).
'/README-'.$langs->defaultlang.
'.md', 0);
778 $tmp = explode(
'_', $langs->defaultlang);
779 $pathoffile =
dol_buildpath(strtolower($this->
name).
'/README-'.$tmp[0].
'.md', 0);
791 return ($filefound ? $pathoffile :
'');
803 $langs->load(
"admin");
805 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
806 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
812 $pathoffile =
dol_buildpath(strtolower($this->
name).
'/ChangeLog-'.$langs->defaultlang.
'.md', 0);
824 $content = file_get_contents($pathoffile);
826 if ((
float) DOL_VERSION >= 6.0) {
827 @include_once DOL_DOCUMENT_ROOT.
'/core/lib/parsemd.lib.php';
831 $content = nl2br($content);
847 return $this->editor_name;
857 return $this->editor_url;
871 $langs->load(
"admin");
875 $newversion = preg_replace(
'/_deprecated/',
'', $this->version);
876 if ($newversion ==
'experimental') {
877 $ret = ($translated ? $langs->transnoentitiesnoconv(
"VersionExperimental") : $newversion);
878 } elseif ($newversion ==
'development') {
879 $ret = ($translated ? $langs->transnoentitiesnoconv(
"VersionDevelopment") : $newversion);
880 } elseif ($newversion ==
'dolibarr') {
882 } elseif ($newversion) {
885 $ret = ($translated ? $langs->transnoentitiesnoconv(
"VersionUnknown") :
'unknown');
888 if (preg_match(
'/_deprecated/', $this->version)) {
889 $ret .= ($translated ?
' ('.$langs->transnoentitiesnoconv(
"Deprecated").
')' : $this->version);
901 if (in_array($this->version, array(
'dolibarr',
'experimental',
'development'))) {
902 return $this->module_position;
904 if ($this->module_position >= 100000) {
905 return $this->module_position;
907 $position = intval($this->module_position) + 100000;
908 return strval($position);
922 if ($this->version ==
'dolibarr' || $this->version ==
'dolibarr_deprecated') {
925 if (!empty($this->version) && !in_array($this->version, array(
'experimental',
'development'))) {
928 if (!empty($this->editor_name) || !empty($this->editor_url)) {
931 if ($this->numero >= 100000) {
945 return $this->langfiles;
959 $langstring =
"ExportDataset_".$this->export_code[$r];
960 if ($langs->trans($langstring) == $langstring) {
962 return $langs->trans($this->export_label[$r]);
965 return $langs->trans($langstring);
981 $langstring =
"ImportDataset_".$this->import_code[$r];
983 if ($langs->trans($langstring) == $langstring) {
985 return $langs->transnoentitiesnoconv($this->import_label[$r]);
988 return $langs->transnoentitiesnoconv($langstring);
1004 $sql =
"SELECT tms FROM ".MAIN_DB_PREFIX.
"const";
1005 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1006 $sql .=
" AND entity IN (0, ".((int) $conf->entity).
")";
1008 dol_syslog(get_class($this).
"::getLastActiveDate", LOG_DEBUG);
1009 $resql = $this->db->query($sql);
1013 $obj = $this->db->fetch_object($resql);
1015 return $this->db->jdate($obj->tms);
1034 $sql =
"SELECT tms, note FROM ".MAIN_DB_PREFIX.
"const";
1035 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1036 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
1038 dol_syslog(get_class($this).
"::getLastActiveDate", LOG_DEBUG);
1039 $resql = $this->db->query($sql);
1043 $obj = $this->db->fetch_object($resql);
1047 $tmp = json_decode($obj->note,
true);
1050 'authorid' => empty($tmp[
'authorid']) ?
'' : $tmp[
'authorid'],
1051 'ip' => empty($tmp[
'ip']) ?
'' : $tmp[
'ip'],
1052 'lastactivationdate' => $this->db->jdate($obj->tms),
1053 'lastactivationversion' => (!empty($tmp[
'lastactivationversion']) ? $tmp[
'lastactivationversion'] :
'unknown'),
1071 global $conf, $user;
1076 $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity);
1078 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1079 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1080 $sql .=
" AND entity IN (0, ".$entity.
")";
1082 dol_syslog(get_class($this).
"::_active delete activation constant", LOG_DEBUG);
1083 $resql = $this->db->query($sql);
1088 $note = json_encode(
1090 'authorid' => (is_object($user) ? $user->id : 0),
1091 'ip' => (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']),
1092 'lastactivationversion' => $this->version,
1096 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (name, value, visible, entity, note) VALUES";
1097 $sql .=
" (".$this->db->encrypt($this->const_name);
1098 $sql .=
", ".$this->db->encrypt(
'1');
1099 $sql .=
", 0, ".((int) $entity);
1100 $sql .=
", '".$this->db->escape($note).
"')";
1102 dol_syslog(get_class($this).
"::_active insert activation constant", LOG_DEBUG);
1103 $resql = $this->db->query($sql);
1126 $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity);
1128 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1129 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1130 $sql .=
" AND entity IN (0, ".$entity.
")";
1132 dol_syslog(get_class($this).
"::_unactive", LOG_DEBUG);
1133 $this->db->query($sql);
1164 if (empty($reldir)) {
1168 include_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
1170 foreach ($conf->file->dol_document_root as $dirroot) {
1172 $dirsql = $dirroot.$reldir;
1176 $listofsubdir = array(
'',
'tables/',
'data/');
1177 if ($this->db->type ==
'pgsql') {
1178 $listofsubdir[] =
'../pgsql/functions/';
1181 foreach ($listofsubdir as $subdir) {
1182 $dir = $dirsql.$subdir;
1184 $handle = @opendir($dir);
1185 if (is_resource($handle)) {
1190 while (($file = readdir($handle)) !==
false) {
1194 foreach ($files as $file) {
1195 if ($onlywithsuffix) {
1196 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1203 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 4) ==
'llx_') {
1215 while (($file = readdir($handle)) !==
false) {
1219 foreach ($files as $file) {
1220 if ($onlywithsuffix) {
1221 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1228 if (preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 4) ==
'llx_') {
1240 while (($file = readdir($handle)) !==
false) {
1244 foreach ($files as $file) {
1245 if ($onlywithsuffix) {
1246 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1253 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 9) ==
'functions') {
1265 while (($file = readdir($handle)) !==
false) {
1269 foreach ($files as $file) {
1270 if ($onlywithsuffix) {
1271 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1278 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 4) ==
'data') {
1290 while (($file = readdir($handle)) !==
false) {
1294 foreach ($files as $file) {
1295 if ($onlywithsuffix) {
1296 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1303 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 6) ==
'update') {
1322 dol_syslog(
"A module wants to load sql files from ".$reldir.
" but this directory was not found.", LOG_WARNING);
1339 include_once DOL_DOCUMENT_ROOT.
'/core/class/infobox.class.php';
1345 if (is_array($this->boxes)) {
1346 dol_syslog(get_class($this).
"::insert_boxes", LOG_DEBUG);
1350 foreach ($this->boxes as $key => $value) {
1351 $file = isset($this->boxes[$key][
'file']) ? $this->boxes[$key][
'file'] :
'';
1352 $note = isset($this->boxes[$key][
'note']) ? $this->boxes[$key][
'note'] :
'';
1353 $enabledbydefaulton = isset($this->boxes[$key][
'enabledbydefaulton']) ? $this->boxes[$key][
'enabledbydefaulton'] :
'Home';
1356 $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] :
'';
1359 $note = isset($this->boxes[$key][2]) ? $this->boxes[$key][2] :
'';
1363 $sql =
"SELECT count(*) as nb FROM ".MAIN_DB_PREFIX.
"boxes_def";
1364 $sql .=
" WHERE file = '".$this->db->escape($file).
"'";
1365 $sql .=
" AND entity = ".$conf->entity;
1367 $sql .=
" AND note ='".$this->db->escape($note).
"'";
1370 $result = $this->db->query($sql);
1372 $obj = $this->db->fetch_object($result);
1373 if ($obj->nb == 0) {
1377 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"boxes_def (file, entity, note)";
1378 $sql .=
" VALUES ('".$this->db->escape($file).
"', ";
1379 $sql .= $conf->entity.
", ";
1380 $sql .= $note ?
"'".$this->db->escape($note).
"'" :
"null";
1383 dol_syslog(get_class($this).
"::insert_boxes", LOG_DEBUG);
1384 $resql = $this->db->query($sql);
1389 if (!$err && !preg_match(
'/newboxdefonly/', $option)) {
1390 $lastid = $this->db->last_insert_id(MAIN_DB_PREFIX.
"boxes_def",
"rowid");
1392 foreach ($pos_name as $key2 => $val2) {
1394 if ($enabledbydefaulton && $val2 != $enabledbydefaulton) {
1398 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"boxes (box_id, position, box_order, fk_user, entity)";
1399 $sql .=
" VALUES (".((int) $lastid).
", ".((int) $key2).
", '0', 0, ".((int) $conf->entity).
")";
1401 dol_syslog(get_class($this).
"::insert_boxes onto page ".$key2.
"=".$val2, LOG_DEBUG);
1402 $resql = $this->db->query($sql);
1410 $this->db->commit();
1412 $this->error = $this->db->lasterror();
1413 $this->db->rollback();
1418 $this->error = $this->db->lasterror();
1441 if (is_array($this->boxes)) {
1442 foreach ($this->boxes as $key => $value) {
1444 if (empty($this->boxes[$key][
'file'])) {
1445 $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] :
'';
1447 $file = $this->boxes[$key][
'file'];
1455 if ($file ==
'box_graph_product_distribution.php') {
1456 if (isModEnabled(
"product") || isModEnabled(
"service")) {
1457 dol_syslog(
"We discard deleting module ".$file.
" because another module still active requires it.");
1462 if ($this->db->type ==
'sqlite3') {
1465 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes ";
1466 $sql .=
"WHERE ".MAIN_DB_PREFIX.
"boxes.box_id IN (";
1467 $sql .=
"SELECT ".MAIN_DB_PREFIX.
"boxes_def.rowid ";
1468 $sql .=
"FROM ".MAIN_DB_PREFIX.
"boxes_def ";
1469 $sql .=
"WHERE ".MAIN_DB_PREFIX.
"boxes_def.file = '".$this->db->escape($file).
"') ";
1470 $sql .=
"AND ".MAIN_DB_PREFIX.
"boxes.entity = ".$conf->entity;
1472 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes";
1473 $sql .=
" USING ".MAIN_DB_PREFIX.
"boxes, ".MAIN_DB_PREFIX.
"boxes_def";
1474 $sql .=
" WHERE ".MAIN_DB_PREFIX.
"boxes.box_id = ".MAIN_DB_PREFIX.
"boxes_def.rowid";
1475 $sql .=
" AND ".MAIN_DB_PREFIX.
"boxes_def.file = '".$this->db->escape($file).
"'";
1476 $sql .=
" AND ".MAIN_DB_PREFIX.
"boxes.entity = ".$conf->entity;
1479 dol_syslog(get_class($this).
"::delete_boxes", LOG_DEBUG);
1480 $resql = $this->db->query($sql);
1482 $this->error = $this->db->lasterror();
1486 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes_def";
1487 $sql .=
" WHERE file = '".$this->db->escape($file).
"'";
1488 $sql .=
" AND entity = ".$conf->entity;
1490 dol_syslog(get_class($this).
"::delete_boxes", LOG_DEBUG);
1491 $resql = $this->db->query($sql);
1493 $this->error = $this->db->lasterror();
1511 include_once DOL_DOCUMENT_ROOT.
'/core/class/infobox.class.php';
1517 if (is_array($this->cronjobs)) {
1518 dol_syslog(get_class($this).
"::insert_cronjobs", LOG_DEBUG);
1520 foreach ($this->cronjobs as $key => $value) {
1521 $entity = isset($this->cronjobs[$key][
'entity']) ? $this->cronjobs[$key][
'entity'] : $conf->entity;
1522 $label = isset($this->cronjobs[$key][
'label']) ? $this->cronjobs[$key][
'label'] :
'';
1523 $jobtype = isset($this->cronjobs[$key][
'jobtype']) ? $this->cronjobs[$key][
'jobtype'] :
'';
1524 $class = isset($this->cronjobs[$key][
'class']) ? $this->cronjobs[$key][
'class'] :
'';
1525 $objectname = isset($this->cronjobs[$key][
'objectname']) ? $this->cronjobs[$key][
'objectname'] :
'';
1526 $method = isset($this->cronjobs[$key][
'method']) ? $this->cronjobs[$key][
'method'] :
'';
1527 $command = isset($this->cronjobs[$key][
'command']) ? $this->cronjobs[$key][
'command'] :
'';
1528 $parameters = isset($this->cronjobs[$key][
'parameters']) ? $this->cronjobs[$key][
'parameters'] :
'';
1529 $comment = isset($this->cronjobs[$key][
'comment']) ? $this->cronjobs[$key][
'comment'] :
'';
1530 $frequency = isset($this->cronjobs[$key][
'frequency']) ? $this->cronjobs[$key][
'frequency'] :
'';
1531 $unitfrequency = isset($this->cronjobs[$key][
'unitfrequency']) ? $this->cronjobs[$key][
'unitfrequency'] :
'';
1532 $priority = isset($this->cronjobs[$key][
'priority']) ? $this->cronjobs[$key][
'priority'] :
'';
1533 $datestart = isset($this->cronjobs[$key][
'datestart']) ? $this->cronjobs[$key][
'datestart'] :
'';
1534 $dateend = isset($this->cronjobs[$key][
'dateend']) ? $this->cronjobs[$key][
'dateend'] :
'';
1535 $status = isset($this->cronjobs[$key][
'status']) ? $this->cronjobs[$key][
'status'] :
'';
1536 $test = isset($this->cronjobs[$key][
'test']) ? $this->cronjobs[$key][
'test'] :
'';
1537 $datenextrun = isset($this->cronjobs[$key][
'datenextrun']) ? $this->cronjobs[$key][
'datenextrun'] :
'';
1540 $sql =
"SELECT count(*) as nb FROM ".MAIN_DB_PREFIX.
"cronjob";
1542 $sql .=
" WHERE label = '".$this->db->escape($label).
"'";
1558 $sql .=
" AND entity = ".((int) $entity);
1562 $result = $this->db->query($sql);
1564 $obj = $this->db->fetch_object($result);
1565 if ($obj->nb == 0) {
1569 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"cronjob (module_name, datec, datestart, dateend, label, jobtype, classesname, objectname, methodename, command, params, note,";
1570 if (is_int($frequency)) {
1571 $sql .=
' frequency,';
1573 if (is_int($unitfrequency)) {
1574 $sql .=
' unitfrequency,';
1576 if (is_int($priority)) {
1577 $sql .=
' priority,';
1579 if (!empty($datenextrun)) {
1580 $sql .=
' datenextrun,';
1582 if (is_int($status)) {
1585 $sql .=
" entity, test)";
1586 $sql .=
" VALUES (";
1587 $sql .=
"'".$this->db->escape(empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class).
"', ";
1588 $sql .=
"'".$this->db->idate($now).
"', ";
1589 $sql .= ($datestart ?
"'".$this->db->idate($datestart).
"'" :
"'".$this->db->idate($now).
"'").
", ";
1590 $sql .= ($dateend ?
"'".$this->db->idate($dateend).
"'" :
"NULL").
", ";
1591 $sql .=
"'".$this->db->escape($label).
"', ";
1592 $sql .=
"'".$this->db->escape($jobtype).
"', ";
1593 $sql .= ($class ?
"'".$this->db->escape($class).
"'" :
"null").
",";
1594 $sql .= ($objectname ?
"'".$this->db->escape($objectname).
"'" :
"null").
",";
1595 $sql .= ($method ?
"'".$this->db->escape($method).
"'" :
"null").
",";
1596 $sql .= ($command ?
"'".$this->db->escape($command).
"'" :
"null").
",";
1597 $sql .= ($parameters ?
"'".$this->db->escape($parameters).
"'" :
"null").
",";
1598 $sql .= ($comment ?
"'".$this->db->escape($comment).
"'" :
"null").
",";
1599 if (is_int($frequency)) {
1600 $sql .=
"'".$this->db->escape($frequency).
"', ";
1602 if (is_int($unitfrequency)) {
1603 $sql .=
"'".$this->db->escape($unitfrequency).
"', ";
1605 if (is_int($priority)) {
1606 $sql .=
"'".$this->db->escape($priority).
"', ";
1608 if (!empty($datenextrun)) {
1609 $sql .=
"'".$this->db->idate($datenextrun).
"', ";
1611 if (is_int($status)) {
1612 $sql .= ((int) $status).
", ";
1614 $sql .= $entity.
",";
1615 $sql .=
"'".$this->db->escape($test).
"'";
1618 $resql = $this->db->query($sql);
1625 $this->db->commit();
1627 $this->error = $this->db->lasterror();
1628 $this->db->rollback();
1633 $this->error = $this->db->lasterror();
1656 if (is_array($this->cronjobs)) {
1657 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"cronjob";
1658 $sql .=
" WHERE module_name = '".$this->db->escape(empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class).
"'";
1659 $sql .=
" AND entity = ".$conf->entity;
1660 $sql .=
" AND test = '1'";
1663 dol_syslog(get_class($this).
"::delete_cronjobs", LOG_DEBUG);
1664 $resql = $this->db->query($sql);
1666 $this->error = $this->db->lasterror();
1687 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1688 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" like '".$this->db->escape($this->const_name).
"_TABS_%'";
1689 $sql .=
" AND entity = ".$conf->entity;
1691 dol_syslog(get_class($this).
"::delete_tabs", LOG_DEBUG);
1692 if (!$this->db->query($sql)) {
1693 $this->error = $this->db->lasterror();
1713 if (!empty($this->tabs)) {
1714 dol_syslog(get_class($this).
"::insert_tabs", LOG_DEBUG);
1717 foreach ($this->tabs as $key => $value) {
1718 if (is_array($value) && count($value) == 0) {
1722 $entity = $conf->entity;
1725 if (is_array($value)) {
1726 $newvalue = $value[
'data'];
1727 if (isset($value[
'entity'])) {
1728 $entity = $value[
'entity'];
1733 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (";
1738 $sql .=
", visible";
1741 $sql .=
" VALUES (";
1742 $sql .= $this->db->encrypt($this->const_name.
"_TABS_".$i);
1743 $sql .=
", 'chaine'";
1744 $sql .=
", ".$this->db->encrypt($newvalue);
1747 $sql .=
", ".((int) $entity);
1750 $resql = $this->db->query($sql);
1753 if ($this->db->lasterrno() !=
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1754 $this->error = $this->db->lasterror();
1755 $this->errors[] = $this->db->lasterror();
1780 if (empty($this->
const)) {
1786 foreach ($this->
const as $key => $value) {
1787 $name = $this->
const[$key][0];
1788 $type = $this->
const[$key][1];
1789 $val = $this->
const[$key][2];
1790 $note = isset($this->
const[$key][3]) ? $this->
const[$key][3] :
'';
1791 $visible = isset($this->
const[$key][4]) ? $this->
const[$key][4] : 0;
1792 $entity = (!empty($this->
const[$key][5]) && $this->
const[$key][5] !=
'current') ? 0 : $conf->entity;
1795 if (empty($visible)) {
1798 if (empty($val) && $val !=
'0') {
1802 $sql =
"SELECT count(*) as nb";
1803 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1804 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
1805 $sql .=
" AND entity = ".((int) $entity);
1807 $result = $this->db->query($sql);
1809 $row = $this->db->fetch_row($result);
1812 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (name,type,value,note,visible,entity)";
1813 $sql .=
" VALUES (";
1814 $sql .= $this->db->encrypt($name);
1815 $sql .=
",'".$this->db->escape($type).
"'";
1816 $sql .=
",".(($val !=
'') ? $this->db->encrypt($val) :
"''");
1817 $sql .=
",".($note ?
"'".$this->db->escape($note).
"'" :
"null");
1818 $sql .=
",'".$this->db->escape($visible).
"'";
1819 $sql .=
",".$entity;
1822 if (!$this->db->query($sql)) {
1826 dol_syslog(__METHOD__.
" constant '".$name.
"' already exists", LOG_DEBUG);
1849 if (empty($this->
const)) {
1853 foreach ($this->
const as $key => $value) {
1854 $name = $this->
const[$key][0];
1855 $deleteonunactive = (!empty($this->
const[$key][6])) ? 1 : 0;
1857 if ($deleteonunactive) {
1858 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1859 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
1860 $sql .=
" AND entity in (0, ".$conf->entity.
")";
1861 dol_syslog(get_class($this).
"::delete_const", LOG_DEBUG);
1862 if (!$this->db->query($sql)) {
1863 $this->error = $this->db->lasterror();
1884 global $conf, $user;
1887 $entity = (!empty($force_entity) ? $force_entity : $conf->entity);
1889 dol_syslog(get_class($this).
"::insert_permissions", LOG_DEBUG);
1892 $sql_del =
"SELECT ".$this->db->decrypt(
'value').
" as value";
1893 $sql_del .=
" FROM ".MAIN_DB_PREFIX.
"const";
1894 $sql_del .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1895 $sql_del .=
" AND entity IN (0,".((int) $entity).
")";
1897 $resql = $this->db->query($sql_del);
1900 $obj = $this->db->fetch_object($resql);
1902 if ($obj !==
null && !empty($obj->value) && !empty($this->rights)) {
1903 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1917 foreach ($this->rights as $key => $value) {
1918 $r_id = $this->rights[$key][self::KEY_ID];
1919 $r_label = $this->rights[$key][self::KEY_LABEL];
1920 $r_type = $this->rights[$key][self::KEY_TYPE] ??
'w';
1921 $r_default = $this->rights[$key][self::KEY_DEFAULT] ?? 0;
1922 $r_perms = $this->rights[$key][self::KEY_FIRST_LEVEL] ??
'';
1923 $r_subperms = $this->rights[$key][self::KEY_SECOND_LEVEL] ??
'';
1926 if (empty($r_perms)) {
1931 $r_module = (empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class);
1934 $r_module_origin =
'';
1936 if (isset($this->rights[$key][self::KEY_MODULE])) {
1938 $r_module = $this->rights[$key][self::KEY_MODULE];
1940 $r_module_origin = (empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class);
1944 $r_enabled = $this->rights[$key][self::KEY_ENABLED] ??
'1';
1947 $sql =
"SELECT count(*) as nb FROM ".MAIN_DB_PREFIX.
"rights_def";
1948 $sql .=
" WHERE entity = ".((int) $entity);
1949 $sql .=
" AND id = ".((int) $r_id);
1951 $resqlselect = $this->db->query($sql);
1953 $objcount = $this->db->fetch_object($resqlselect);
1954 if ($objcount && $objcount->nb == 0) {
1955 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"rights_def (";
1958 $sql .=
", libelle";
1960 $sql .=
", module_origin";
1962 $sql .=
", bydefault";
1964 $sql .=
", subperms";
1965 $sql .=
", enabled";
1966 $sql .=
") VALUES (";
1967 $sql .= ((int) $r_id);
1968 $sql .=
", ".((int) $entity);
1969 $sql .=
", '".$this->db->escape($r_label).
"'";
1970 $sql .=
", '".$this->db->escape($r_module).
"'";
1971 $sql .=
", '".$this->db->escape($r_module_origin).
"'";
1972 $sql .=
", '".$this->db->escape($r_type).
"'";
1973 $sql .=
", ".((int) $r_default);
1974 $sql .=
", '".$this->db->escape($r_perms).
"'";
1975 $sql .=
", '".$this->db->escape($r_subperms).
"'";
1976 $sql .=
", '".$this->db->escape($r_enabled).
"'";
1979 $resqlinsert = $this->db->query($sql, 1);
1981 if (!$resqlinsert) {
1982 if ($this->db->errno() !=
"DB_ERROR_RECORD_ALREADY_EXISTS") {
1983 $this->error = $this->db->lasterror();
1987 dol_syslog(get_class($this).
"::insert_permissions record already exists", LOG_INFO);
1991 $this->db->free($resqlinsert);
1994 $this->db->free($resqlselect);
1998 if (!empty($reinitadminperms)) {
1999 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"user WHERE admin = 1";
2000 dol_syslog(get_class($this).
"::insert_permissions Search all admin users", LOG_DEBUG);
2002 $resqlseladmin = $this->db->query($sql, 1);
2004 if ($resqlseladmin) {
2005 $num = $this->db->num_rows($resqlseladmin);
2008 $obj2 = $this->db->fetch_object($resqlseladmin);
2009 dol_syslog(get_class($this).
"::insert_permissions Add permission id ".$r_id.
" to user id=".$obj2->rowid);
2011 $tmpuser =
new User($this->db);
2012 $result = $tmpuser->fetch($obj2->rowid);
2014 $tmpuser->addrights($r_id,
'',
'', 0, 1);
2016 dol_syslog(get_class($this).
"::insert_permissions Failed to add the permission to user because fetch return an error", LOG_ERR);
2026 if (!empty($reinitadminperms) && !empty($user->admin)) {
2028 $user->clearrights();
2032 $this->db->free($resql);
2034 $this->error = $this->db->lasterror();
2055 $module = empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class;
2057 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"rights_def";
2058 $sql .=
" WHERE (module = '".$this->db->escape($module).
"' OR module_origin = '".$this->db->escape($module).
"')";
2061 if (empty($this->core_enabled)) {
2062 $sql .=
" AND entity = ".((int) $conf->entity);
2065 dol_syslog(get_class($this).
"::delete_permissions", LOG_DEBUG);
2066 if (!$this->db->query($sql)) {
2067 $this->error = $this->db->lasterror();
2084 global $conf, $user;
2086 if (!is_array($this->menu) || empty($this->menu)) {
2090 include_once DOL_DOCUMENT_ROOT.
'/core/class/menubase.class.php';
2092 dol_syslog(get_class($this).
"::insert_menus", LOG_DEBUG);
2097 $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity);
2101 foreach ($this->menu as $key => $value) {
2103 $menu->menu_handler =
'all';
2106 $menu->module = (empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class);
2108 if (!$this->menu[$key][
'fk_menu']) {
2112 $fk_parent = $this->menu[$key][
'fk_menu'];
2114 if (preg_match(
'/^r=/', $fk_parent)) {
2115 $fk_parent = str_replace(
'r=',
'', $fk_parent);
2116 if (isset($this->menu[$fk_parent][
'rowid'])) {
2117 $menu->fk_menu = $this->menu[$fk_parent][
'rowid'];
2120 } elseif (preg_match(
'/^fk_mainmenu=([a-zA-Z0-9_]+),fk_leftmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) {
2121 $menu->fk_menu = -1;
2122 $menu->fk_mainmenu = $reg[1];
2123 $menu->fk_leftmenu = $reg[2];
2125 } elseif (preg_match(
'/^fk_mainmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) {
2126 $menu->fk_menu = -1;
2127 $menu->fk_mainmenu = $reg[1];
2128 $menu->fk_leftmenu =
'';
2131 if (!$foundparent) {
2132 $this->error =
"ErrorBadDefinitionOfMenuArrayInModuleDescriptor";
2133 dol_syslog(get_class($this).
"::insert_menus ".$this->error.
" ".$this->menu[$key][
'fk_menu'], LOG_ERR);
2137 $menu->type = $this->menu[$key][
'type'];
2138 $menu->mainmenu = isset($this->menu[$key][
'mainmenu']) ? $this->menu[$key][
'mainmenu'] : (isset($menu->fk_mainmenu) ? $menu->fk_mainmenu :
'');
2139 $menu->leftmenu = isset($this->menu[$key][
'leftmenu']) ? $this->menu[$key][
'leftmenu'] :
'';
2140 $menu->title = $this->menu[$key][
'titre'];
2141 $menu->prefix = isset($this->menu[$key][
'prefix']) ? $this->menu[$key][
'prefix'] :
'';
2142 $menu->url = $this->menu[$key][
'url'];
2143 $menu->langs = isset($this->menu[$key][
'langs']) ? $this->menu[$key][
'langs'] :
'';
2144 $menu->position = $this->menu[$key][
'position'];
2145 $menu->perms = $this->menu[$key][
'perms'];
2146 $menu->target = isset($this->menu[$key][
'target']) ? $this->menu[$key][
'target'] :
'';
2147 $menu->user = $this->menu[$key][
'user'];
2148 $menu->enabled = isset($this->menu[$key][
'enabled']) ? $this->menu[$key][
'enabled'] : 0;
2149 $menu->position = $this->menu[$key][
'position'];
2150 $menu->entity = $entity;
2153 $result = $menu->create($user);
2155 $this->menu[$key][
'rowid'] = $result;
2157 $this->error = $menu->error;
2158 dol_syslog(get_class($this).
'::insert_menus result='.$result.
" ".$this->error, LOG_ERR);
2166 $this->db->commit();
2168 dol_syslog(get_class($this).
"::insert_menus ".$this->error, LOG_ERR);
2169 $this->db->rollback();
2190 $module = empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class;
2192 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"menu";
2193 $sql .=
" WHERE module = '".$this->db->escape($module).
"'";
2194 $sql .=
" AND menu_handler = 'all'";
2195 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
2197 dol_syslog(get_class($this).
"::delete_menus", LOG_DEBUG);
2198 $resql = $this->db->query($sql);
2200 $this->error = $this->db->lasterror();
2216 global $langs, $conf;
2221 if (isset($this->dirs) && is_array($this->dirs)) {
2222 foreach ($this->dirs as $key => $value) {
2225 if (!is_array($value)) {
2228 $constname = $this->const_name.
"_DIR_";
2229 $dir = $this->dirs[$key][1];
2230 $addtodatabase = empty($this->dirs[$key][2]) ?
'' : $this->dirs[$key][2];
2231 $subname = empty($this->dirs[$key][3]) ?
'' : strtoupper($this->dirs[$key][3]);
2232 $forcename = empty($this->dirs[$key][4]) ?
'' : strtoupper($this->dirs[$key][4]);
2234 if (!empty($forcename)) {
2235 $constname =
'MAIN_MODULE_'.$forcename.
"_DIR_";
2237 if (!empty($subname)) {
2238 $constname = $constname.$subname.
"_";
2241 $name = $constname.strtoupper($this->dirs[$key][0]);
2246 $fulldir = DOL_DATA_ROOT.$dir;
2248 $fulldir = DOL_DATA_ROOT.
"/".$conf->entity.$dir;
2251 if (!empty($fulldir) && !file_exists($fulldir)) {
2252 if (
dol_mkdir($fulldir, DOL_DATA_ROOT) < 0) {
2253 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $fulldir);
2254 dol_syslog(get_class($this).
"::_init ".$this->error, LOG_ERR);
2260 if (!empty($addtodatabase) && !empty($name)) {
2289 $sql =
"SELECT count(*)";
2290 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
2291 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
2292 $sql .=
" AND entity = ".$conf->entity;
2294 dol_syslog(get_class($this).
"::insert_dirs", LOG_DEBUG);
2295 $result = $this->db->query($sql);
2297 $row = $this->db->fetch_row($result);
2300 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (name, type, value, note, visible, entity)";
2301 $sql .=
" VALUES (".$this->db->encrypt($name).
", 'chaine', ".$this->db->encrypt($dir).
", '".$this->db->escape(
"Directory for module ".$this->
name).
"', '0', ".((int) $conf->entity).
")";
2303 dol_syslog(get_class($this).
"::insert_dirs", LOG_DEBUG);
2304 $this->db->query($sql);
2307 $this->error = $this->db->lasterror();
2328 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
2329 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" LIKE '".$this->db->escape($this->const_name).
"_DIR_%'";
2330 $sql .=
" AND entity = ".$conf->entity;
2332 dol_syslog(get_class($this).
"::delete_dirs", LOG_DEBUG);
2333 if (!$this->db->query($sql)) {
2334 $this->error = $this->db->lasterror();
2351 global $conf, $langs;
2355 if (is_array($this->module_parts)) {
2356 if (empty($this->module_parts[
'icon']) && !empty($this->picto) && preg_match(
'/^fa\-/', $this->picto)) {
2357 $this->module_parts[
'icon'] = $this->picto;
2360 foreach ($this->module_parts as $key => $value) {
2361 if (is_array($value) && count($value) == 0) {
2366 if ($key ==
'websitetemplates' && $value == 1) {
2370 $docs =
dol_dir_list($srcroot,
'directories', 0,
'website_.*$');
2371 foreach ($docs as $cursorfile) {
2372 $src = $srcroot.
'/'.$cursorfile[
'name'];
2373 $dest = DOL_DATA_ROOT.
'/doctemplates/websites/'.$cursorfile[
'name'];
2380 $result = dol_compress_dir($src, $dest.
'.zip',
'zip');
2383 $this->error = ($errormsg ? $errormsg : $langs->trans(
'ErrorFailToCreateZip', $dest));
2384 $this->errors[] = ($errormsg ? $errormsg : $langs->trans(
'ErrorFailToCreateZip', $dest));
2389 $docs =
dol_dir_list($srcroot,
'files', 0,
'website_.*\.jpg$');
2390 foreach ($docs as $cursorfile) {
2391 $src = $srcroot.
'/'.$cursorfile[
'name'];
2392 $dest = DOL_DATA_ROOT.
'/doctemplates/websites/'.$cursorfile[
'name'];
2398 $entity = $conf->entity;
2402 if (is_array($value)) {
2405 if (isset($value[
'data']) && is_array($value[
'data'])) {
2406 $newvalue = json_encode($value[
'data']);
2407 if (isset($value[
'entity'])) {
2408 $entity = $value[
'entity'];
2410 } elseif (isset($value[
'data']) && !is_array($value[
'data'])) {
2411 $newvalue = $value[
'data'];
2412 if (isset($value[
'entity'])) {
2413 $entity = $value[
'entity'];
2416 $newvalue = json_encode($value);
2420 if (!empty($newvalue)) {
2421 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (";
2426 $sql .=
", visible";
2429 $sql .=
" VALUES (";
2430 $sql .=
" ".$this->db->encrypt($this->const_name.
"_".strtoupper($key), 1);
2431 $sql .=
", 'chaine'";
2432 $sql .=
", ".$this->db->encrypt($newvalue, 1);
2435 $sql .=
", ".((int) $entity);
2438 dol_syslog(get_class($this).
"::insert_module_parts for key=".$this->const_name.
"_".strtoupper($key), LOG_DEBUG);
2440 $resql = $this->db->query($sql, 1);
2442 if ($this->db->lasterrno() !=
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2444 $this->error = $this->db->lasterror();
2446 dol_syslog(get_class($this).
"::insert_module_parts for ".$this->const_name.
"_".strtoupper($key).
" Record already exists.", LOG_WARNING);
2468 if (is_array($this->module_parts)) {
2469 dol_syslog(get_class($this).
"::delete_module_parts", LOG_DEBUG);
2471 if (empty($this->module_parts[
'icon']) && !empty($this->picto) && preg_match(
'/^fa\-/', $this->picto)) {
2472 $this->module_parts[
'icon'] = $this->picto;
2475 foreach ($this->module_parts as $key => $value) {
2477 if (is_array($value) && isset($value[
'entity'])) {
2478 $entity = $value[
'entity'];
2480 $entity = $conf->entity;
2483 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
2484 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" LIKE '".$this->db->escape($this->const_name).
"_".strtoupper($key).
"'";
2485 $sql .=
" AND entity = ".((int) $entity);
2487 if (!$this->db->query($sql)) {
2488 $this->error = $this->db->lasterror();
2505 public function init($options =
'')
2507 return $this->
_init(array(), $options);
2518 public function remove($options =
'')
2520 return $this->
_remove(array(), $options);
2538 $imginfo =
"info_black";
2541 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($this)));
2545 if (preg_match(
'/development/i', $version)) {
2546 $versiontrans .=
'warning';
2548 if (preg_match(
'/experimental/i', $version)) {
2549 $versiontrans .=
'warning';
2551 if (preg_match(
'/deprecated/i', $version)) {
2552 $versiontrans .=
'warning';
2556 <div class="box-flex-item info-box-module'
2557 .(getDolGlobalString($const_name) ?
'' :
' --disabled')
2559 .($this->needUpdate ?
' --need-update' :
'')
2561 <div class="info-box info-box-sm info-box-module">
2562 <div class="info-box-icon'.(!
getDolGlobalString($const_name) ?
'' :
' info-box-icon-module-enabled'.($versiontrans ?
' info-box-icon-module-warning' :
'')).
'">';
2567 if (!empty($this->picto)) {
2568 if (preg_match(
'/^\//i', $this->picto)) {
2569 $return .=
img_picto($alttext, $this->picto,
'class="inline-block valignmiddle"', 1);
2571 $return .=
img_object($alttext, $this->picto,
'class="inline-block valignmiddle"');
2574 $return .=
img_object($alttext,
'generic',
'class="inline-block valignmiddle"');
2577 if ($this->
isCoreOrExternalModule() ==
'external' || preg_match(
'/development|experimental|deprecated/i', $version)) {
2578 $versionTitle = $langs->trans(
"Version").
' '.$this->
getVersion(1);
2579 if ($this->needUpdate) {
2580 $versionTitle .=
'<br>'.$langs->trans(
'ModuleUpdateAvailable').
' : '.
$this->lastVersion;
2583 $return .=
'<span class="info-box-icon-version'.($versiontrans ?
' '.$versiontrans :
'').
' classfortooltip" title="'.
dol_escape_js($versionTitle).
'" >';
2585 $return .=
'</span>';
2589 <div class="info-box-content info-box-text-module'.(!
getDolGlobalString($const_name) ?
'' :
' info-box-module-enabled'.($versiontrans ?
' info-box-content-warning' :
'')).
'">
2590 <span class="info-box-title">'.$this->
getName().
'</span>
2593 $return .=
'<div class="valignmiddle inline-block info-box-more">';
2595 $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>';
2596 $return .= '</div><br>';
2598 $return .= '<div class="valignmiddle
inline-block info-box-actions
">';
2599 $return .= '<div class="valignmiddle
inline-block info-box-setup
">';
2600 $return .= $codetoconfig;
2601 $return .= '</div>';
2602 $return .= '<div class="valignmiddle
inline-block marginleftonly marginrightonly
">';
2603 $return .= $codeenabledisable;
2604 $return .= '</div>';
2605 $return .= '</div>';
2608 </div><!-- /.info-box-content -->
2609 </div><!-- /.info-box -->
2622 public function checkForUpdate()
2624 require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
2625 if (!empty($this->url_last_version)) {
2626 $lastVersion = getURLContent($this->url_last_version, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only
2627 if (isset($lastVersion['content']) && strlen($lastVersion['content']) < 30) {
2628 // 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 _ . -
2629 $this->lastVersion = preg_replace("/[^a-zA-Z0-9_\.\-]+/
", "", $lastVersion['content']);
2630 if (version_compare($this->lastVersion, $this->version) > 0) {
2631 $this->needUpdate = true;
2634 $this->needUpdate = false;
2650 public function checkForCompliance()
2652 global $conf, $langs;
2654 // Get list of illegal modules name or ID
2655 if (empty($conf->cache['noncompliantmodules'])) {
2656 require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
2658 $urlforblacklistmodules = 'https://ping.dolibarr.org/modules-blacklist.txt';
2660 $result = getURLContent($urlforblacklistmodules, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only
2661 if (isset($result['content']) && $result['http_code'] == 200) {
2662 $langs->load("errors
");
2664 // 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 _ . -
2665 $arrayoflines = preg_split("/[\n,]/
", $result['content']);
2666 foreach ($arrayoflines as $line) {
2667 $tmpfieldsofline = explode(';', $line);
2668 $modulekey = strtolower($tmpfieldsofline[0]);
2669 $conf->cache['noncompliantmodules'][$modulekey]['name'] = $tmpfieldsofline[0];
2670 $conf->cache['noncompliantmodules'][$modulekey]['id'] = $tmpfieldsofline[1];
2671 $conf->cache['noncompliantmodules'][$modulekey]['signature'] = $tmpfieldsofline[2];
2672 $conf->cache['noncompliantmodules'][$modulekey]['message'] = $langs->trans(empty($tmpfieldsofline[3]) ? 'WarningModuleAffiliatedToAReportedCompany' : $tmpfieldsofline[3]);
2673 if (!empty($tmpfieldsofline[4])) {
2674 $message2 = $langs->trans("WarningModuleAffiliatedToAPiratPlatform
", '{s}');
2675 $listofillegalurl = '';
2676 foreach (explode(" ", $tmpfieldsofline[4]) as $illegalurl) {
2677 $listofillegalurl .= ($listofillegalurl ? ' '.$langs->trans("or
").' ' : '').'<b>'.preg_replace('/[^a-z0-9\.\-]/', '', $illegalurl).'</b>';
2679 $message2 = str_replace('{s}', $listofillegalurl, $message2);
2680 $conf->cache['noncompliantmodules'][$modulekey]['message2'] = $message2;
2686 if (!empty($conf->cache['noncompliantmodules'])) {
2687 $modulekey = strtolower($this->name);
2688 if (in_array($modulekey, array_keys($conf->cache['noncompliantmodules']))) {
2689 $answer = trim($conf->cache['noncompliantmodules'][$modulekey]['message']);
2690 if (!empty($conf->cache['noncompliantmodules'][$modulekey]['message2'])) {
2691 $answer .= '<br>'.$conf->cache['noncompliantmodules'][$modulekey]['message2'];
2718 protected function declareNewDictionary($dictionaryArray, $langs = '')
2720 $fields = array('name', 'lib', 'sql', 'sqlsort', 'field', 'fieldvalue', 'fieldinsert', 'rowid', 'cond', 'help', 'fieldcheck');
2722 foreach ($fields as $field) {
2723 if (isset($dictionaryArray[$field])) {
2724 $this->dictionaries['tab'.$field][] = $dictionaryArray[$field];
2727 if ($langs && !in_array($langs, $this->dictionaries[$langs])) {
2728 $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 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.