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'] :
'';
1539 $sql =
"SELECT count(*) as nb FROM ".MAIN_DB_PREFIX.
"cronjob";
1541 $sql .=
" WHERE label = '".$this->db->escape($label).
"'";
1557 $sql .=
" AND entity = ".((int) $entity);
1561 $result = $this->db->query($sql);
1563 $obj = $this->db->fetch_object($result);
1564 if ($obj->nb == 0) {
1568 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"cronjob (module_name, datec, datestart, dateend, label, jobtype, classesname, objectname, methodename, command, params, note,";
1569 if (is_int($frequency)) {
1570 $sql .=
' frequency,';
1572 if (is_int($unitfrequency)) {
1573 $sql .=
' unitfrequency,';
1575 if (is_int($priority)) {
1576 $sql .=
' priority,';
1578 if (is_int($status)) {
1581 $sql .=
" entity, test)";
1582 $sql .=
" VALUES (";
1583 $sql .=
"'".$this->db->escape(empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class).
"', ";
1584 $sql .=
"'".$this->db->idate($now).
"', ";
1585 $sql .= ($datestart ?
"'".$this->db->idate($datestart).
"'" :
"'".$this->db->idate($now).
"'").
", ";
1586 $sql .= ($dateend ?
"'".$this->db->idate($dateend).
"'" :
"NULL").
", ";
1587 $sql .=
"'".$this->db->escape($label).
"', ";
1588 $sql .=
"'".$this->db->escape($jobtype).
"', ";
1589 $sql .= ($class ?
"'".$this->db->escape($class).
"'" :
"null").
",";
1590 $sql .= ($objectname ?
"'".$this->db->escape($objectname).
"'" :
"null").
",";
1591 $sql .= ($method ?
"'".$this->db->escape($method).
"'" :
"null").
",";
1592 $sql .= ($command ?
"'".$this->db->escape($command).
"'" :
"null").
",";
1593 $sql .= ($parameters ?
"'".$this->db->escape($parameters).
"'" :
"null").
",";
1594 $sql .= ($comment ?
"'".$this->db->escape($comment).
"'" :
"null").
",";
1595 if (is_int($frequency)) {
1596 $sql .=
"'".$this->db->escape($frequency).
"', ";
1598 if (is_int($unitfrequency)) {
1599 $sql .=
"'".$this->db->escape($unitfrequency).
"', ";
1601 if (is_int($priority)) {
1602 $sql .=
"'".$this->db->escape($priority).
"', ";
1604 if (is_int($status)) {
1605 $sql .= ((int) $status).
", ";
1607 $sql .= $entity.
",";
1608 $sql .=
"'".$this->db->escape($test).
"'";
1611 $resql = $this->db->query($sql);
1618 $this->db->commit();
1620 $this->error = $this->db->lasterror();
1621 $this->db->rollback();
1626 $this->error = $this->db->lasterror();
1649 if (is_array($this->cronjobs)) {
1650 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"cronjob";
1651 $sql .=
" WHERE module_name = '".$this->db->escape(empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class).
"'";
1652 $sql .=
" AND entity = ".$conf->entity;
1653 $sql .=
" AND test = '1'";
1656 dol_syslog(get_class($this).
"::delete_cronjobs", LOG_DEBUG);
1657 $resql = $this->db->query($sql);
1659 $this->error = $this->db->lasterror();
1680 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1681 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" like '".$this->db->escape($this->const_name).
"_TABS_%'";
1682 $sql .=
" AND entity = ".$conf->entity;
1684 dol_syslog(get_class($this).
"::delete_tabs", LOG_DEBUG);
1685 if (!$this->db->query($sql)) {
1686 $this->error = $this->db->lasterror();
1706 if (!empty($this->tabs)) {
1707 dol_syslog(get_class($this).
"::insert_tabs", LOG_DEBUG);
1710 foreach ($this->tabs as $key => $value) {
1711 if (is_array($value) && count($value) == 0) {
1715 $entity = $conf->entity;
1718 if (is_array($value)) {
1719 $newvalue = $value[
'data'];
1720 if (isset($value[
'entity'])) {
1721 $entity = $value[
'entity'];
1726 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (";
1731 $sql .=
", visible";
1734 $sql .=
" VALUES (";
1735 $sql .= $this->db->encrypt($this->const_name.
"_TABS_".$i);
1736 $sql .=
", 'chaine'";
1737 $sql .=
", ".$this->db->encrypt($newvalue);
1740 $sql .=
", ".((int) $entity);
1743 $resql = $this->db->query($sql);
1746 if ($this->db->lasterrno() !=
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1747 $this->error = $this->db->lasterror();
1748 $this->errors[] = $this->db->lasterror();
1773 if (empty($this->
const)) {
1779 foreach ($this->
const as $key => $value) {
1780 $name = $this->
const[$key][0];
1781 $type = $this->
const[$key][1];
1782 $val = $this->
const[$key][2];
1783 $note = isset($this->
const[$key][3]) ? $this->
const[$key][3] :
'';
1784 $visible = isset($this->
const[$key][4]) ? $this->
const[$key][4] : 0;
1785 $entity = (!empty($this->
const[$key][5]) && $this->
const[$key][5] !=
'current') ? 0 : $conf->entity;
1788 if (empty($visible)) {
1791 if (empty($val) && $val !=
'0') {
1795 $sql =
"SELECT count(*) as nb";
1796 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1797 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
1798 $sql .=
" AND entity = ".((int) $entity);
1800 $result = $this->db->query($sql);
1802 $row = $this->db->fetch_row($result);
1805 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (name,type,value,note,visible,entity)";
1806 $sql .=
" VALUES (";
1807 $sql .= $this->db->encrypt($name);
1808 $sql .=
",'".$this->db->escape($type).
"'";
1809 $sql .=
",".(($val !=
'') ? $this->db->encrypt($val) :
"''");
1810 $sql .=
",".($note ?
"'".$this->db->escape($note).
"'" :
"null");
1811 $sql .=
",'".$this->db->escape($visible).
"'";
1812 $sql .=
",".$entity;
1815 if (!$this->db->query($sql)) {
1819 dol_syslog(__METHOD__.
" constant '".$name.
"' already exists", LOG_DEBUG);
1842 if (empty($this->
const)) {
1846 foreach ($this->
const as $key => $value) {
1847 $name = $this->
const[$key][0];
1848 $deleteonunactive = (!empty($this->
const[$key][6])) ? 1 : 0;
1850 if ($deleteonunactive) {
1851 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1852 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
1853 $sql .=
" AND entity in (0, ".$conf->entity.
")";
1854 dol_syslog(get_class($this).
"::delete_const", LOG_DEBUG);
1855 if (!$this->db->query($sql)) {
1856 $this->error = $this->db->lasterror();
1877 global $conf, $user;
1880 $entity = (!empty($force_entity) ? $force_entity : $conf->entity);
1882 dol_syslog(get_class($this).
"::insert_permissions", LOG_DEBUG);
1885 $sql_del =
"SELECT ".$this->db->decrypt(
'value').
" as value";
1886 $sql_del .=
" FROM ".MAIN_DB_PREFIX.
"const";
1887 $sql_del .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1888 $sql_del .=
" AND entity IN (0,".((int) $entity).
")";
1890 $resql = $this->db->query($sql_del);
1893 $obj = $this->db->fetch_object($resql);
1895 if ($obj !==
null && !empty($obj->value) && !empty($this->rights)) {
1896 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1910 foreach ($this->rights as $key => $value) {
1911 $r_id = $this->rights[$key][self::KEY_ID];
1912 $r_label = $this->rights[$key][self::KEY_LABEL];
1913 $r_type = $this->rights[$key][self::KEY_TYPE] ??
'w';
1914 $r_default = $this->rights[$key][self::KEY_DEFAULT] ?? 0;
1915 $r_perms = $this->rights[$key][self::KEY_FIRST_LEVEL] ??
'';
1916 $r_subperms = $this->rights[$key][self::KEY_SECOND_LEVEL] ??
'';
1919 if (empty($r_perms)) {
1924 $r_module = (empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class);
1927 $r_module_origin =
'';
1929 if (isset($this->rights[$key][self::KEY_MODULE])) {
1931 $r_module = $this->rights[$key][self::KEY_MODULE];
1933 $r_module_origin = (empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class);
1937 $r_enabled = $this->rights[$key][self::KEY_ENABLED] ??
'1';
1940 $sql =
"SELECT count(*) as nb FROM ".MAIN_DB_PREFIX.
"rights_def";
1941 $sql .=
" WHERE entity = ".((int) $entity);
1942 $sql .=
" AND id = ".((int) $r_id);
1944 $resqlselect = $this->db->query($sql);
1946 $objcount = $this->db->fetch_object($resqlselect);
1947 if ($objcount && $objcount->nb == 0) {
1948 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"rights_def (";
1951 $sql .=
", libelle";
1953 $sql .=
", module_origin";
1955 $sql .=
", bydefault";
1957 $sql .=
", subperms";
1958 $sql .=
", enabled";
1959 $sql .=
") VALUES (";
1960 $sql .= ((int) $r_id);
1961 $sql .=
", ".((int) $entity);
1962 $sql .=
", '".$this->db->escape($r_label).
"'";
1963 $sql .=
", '".$this->db->escape($r_module).
"'";
1964 $sql .=
", '".$this->db->escape($r_module_origin).
"'";
1965 $sql .=
", '".$this->db->escape($r_type).
"'";
1966 $sql .=
", ".((int) $r_default);
1967 $sql .=
", '".$this->db->escape($r_perms).
"'";
1968 $sql .=
", '".$this->db->escape($r_subperms).
"'";
1969 $sql .=
", '".$this->db->escape($r_enabled).
"'";
1972 $resqlinsert = $this->db->query($sql, 1);
1974 if (!$resqlinsert) {
1975 if ($this->db->errno() !=
"DB_ERROR_RECORD_ALREADY_EXISTS") {
1976 $this->error = $this->db->lasterror();
1980 dol_syslog(get_class($this).
"::insert_permissions record already exists", LOG_INFO);
1984 $this->db->free($resqlinsert);
1987 $this->db->free($resqlselect);
1991 if (!empty($reinitadminperms)) {
1992 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"user WHERE admin = 1";
1993 dol_syslog(get_class($this).
"::insert_permissions Search all admin users", LOG_DEBUG);
1995 $resqlseladmin = $this->db->query($sql, 1);
1997 if ($resqlseladmin) {
1998 $num = $this->db->num_rows($resqlseladmin);
2001 $obj2 = $this->db->fetch_object($resqlseladmin);
2002 dol_syslog(get_class($this).
"::insert_permissions Add permission id ".$r_id.
" to user id=".$obj2->rowid);
2004 $tmpuser =
new User($this->db);
2005 $result = $tmpuser->fetch($obj2->rowid);
2007 $tmpuser->addrights($r_id,
'',
'', 0, 1);
2009 dol_syslog(get_class($this).
"::insert_permissions Failed to add the permission to user because fetch return an error", LOG_ERR);
2019 if (!empty($reinitadminperms) && !empty($user->admin)) {
2021 $user->clearrights();
2025 $this->db->free($resql);
2027 $this->error = $this->db->lasterror();
2048 $module = empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class;
2050 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"rights_def";
2051 $sql .=
" WHERE (module = '".$this->db->escape($module).
"' OR module_origin = '".$this->db->escape($module).
"')";
2054 if (empty($this->core_enabled)) {
2055 $sql .=
" AND entity = ".((int) $conf->entity);
2058 dol_syslog(get_class($this).
"::delete_permissions", LOG_DEBUG);
2059 if (!$this->db->query($sql)) {
2060 $this->error = $this->db->lasterror();
2077 global $conf, $user;
2079 if (!is_array($this->menu) || empty($this->menu)) {
2083 include_once DOL_DOCUMENT_ROOT.
'/core/class/menubase.class.php';
2085 dol_syslog(get_class($this).
"::insert_menus", LOG_DEBUG);
2090 $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity);
2094 foreach ($this->menu as $key => $value) {
2096 $menu->menu_handler =
'all';
2099 $menu->module = (empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class);
2101 if (!$this->menu[$key][
'fk_menu']) {
2105 $fk_parent = $this->menu[$key][
'fk_menu'];
2107 if (preg_match(
'/^r=/', $fk_parent)) {
2108 $fk_parent = str_replace(
'r=',
'', $fk_parent);
2109 if (isset($this->menu[$fk_parent][
'rowid'])) {
2110 $menu->fk_menu = $this->menu[$fk_parent][
'rowid'];
2113 } elseif (preg_match(
'/^fk_mainmenu=([a-zA-Z0-9_]+),fk_leftmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) {
2114 $menu->fk_menu = -1;
2115 $menu->fk_mainmenu = $reg[1];
2116 $menu->fk_leftmenu = $reg[2];
2118 } elseif (preg_match(
'/^fk_mainmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) {
2119 $menu->fk_menu = -1;
2120 $menu->fk_mainmenu = $reg[1];
2121 $menu->fk_leftmenu =
'';
2124 if (!$foundparent) {
2125 $this->error =
"ErrorBadDefinitionOfMenuArrayInModuleDescriptor";
2126 dol_syslog(get_class($this).
"::insert_menus ".$this->error.
" ".$this->menu[$key][
'fk_menu'], LOG_ERR);
2130 $menu->type = $this->menu[$key][
'type'];
2131 $menu->mainmenu = isset($this->menu[$key][
'mainmenu']) ? $this->menu[$key][
'mainmenu'] : (isset($menu->fk_mainmenu) ? $menu->fk_mainmenu :
'');
2132 $menu->leftmenu = isset($this->menu[$key][
'leftmenu']) ? $this->menu[$key][
'leftmenu'] :
'';
2133 $menu->title = $this->menu[$key][
'titre'];
2134 $menu->prefix = isset($this->menu[$key][
'prefix']) ? $this->menu[$key][
'prefix'] :
'';
2135 $menu->url = $this->menu[$key][
'url'];
2136 $menu->langs = isset($this->menu[$key][
'langs']) ? $this->menu[$key][
'langs'] :
'';
2137 $menu->position = $this->menu[$key][
'position'];
2138 $menu->perms = $this->menu[$key][
'perms'];
2139 $menu->target = isset($this->menu[$key][
'target']) ? $this->menu[$key][
'target'] :
'';
2140 $menu->user = $this->menu[$key][
'user'];
2141 $menu->enabled = isset($this->menu[$key][
'enabled']) ? $this->menu[$key][
'enabled'] : 0;
2142 $menu->position = $this->menu[$key][
'position'];
2143 $menu->entity = $entity;
2146 $result = $menu->create($user);
2148 $this->menu[$key][
'rowid'] = $result;
2150 $this->error = $menu->error;
2151 dol_syslog(get_class($this).
'::insert_menus result='.$result.
" ".$this->error, LOG_ERR);
2159 $this->db->commit();
2161 dol_syslog(get_class($this).
"::insert_menus ".$this->error, LOG_ERR);
2162 $this->db->rollback();
2183 $module = empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class;
2185 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"menu";
2186 $sql .=
" WHERE module = '".$this->db->escape($module).
"'";
2187 $sql .=
" AND menu_handler = 'all'";
2188 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
2190 dol_syslog(get_class($this).
"::delete_menus", LOG_DEBUG);
2191 $resql = $this->db->query($sql);
2193 $this->error = $this->db->lasterror();
2209 global $langs, $conf;
2214 if (isset($this->dirs) && is_array($this->dirs)) {
2215 foreach ($this->dirs as $key => $value) {
2218 if (!is_array($value)) {
2221 $constname = $this->const_name.
"_DIR_";
2222 $dir = $this->dirs[$key][1];
2223 $addtodatabase = empty($this->dirs[$key][2]) ?
'' : $this->dirs[$key][2];
2224 $subname = empty($this->dirs[$key][3]) ?
'' : strtoupper($this->dirs[$key][3]);
2225 $forcename = empty($this->dirs[$key][4]) ?
'' : strtoupper($this->dirs[$key][4]);
2227 if (!empty($forcename)) {
2228 $constname =
'MAIN_MODULE_'.$forcename.
"_DIR_";
2230 if (!empty($subname)) {
2231 $constname = $constname.$subname.
"_";
2234 $name = $constname.strtoupper($this->dirs[$key][0]);
2239 $fulldir = DOL_DATA_ROOT.$dir;
2241 $fulldir = DOL_DATA_ROOT.
"/".$conf->entity.$dir;
2244 if (!empty($fulldir) && !file_exists($fulldir)) {
2245 if (
dol_mkdir($fulldir, DOL_DATA_ROOT) < 0) {
2246 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $fulldir);
2247 dol_syslog(get_class($this).
"::_init ".$this->error, LOG_ERR);
2253 if (!empty($addtodatabase) && !empty($name)) {
2282 $sql =
"SELECT count(*)";
2283 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
2284 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
2285 $sql .=
" AND entity = ".$conf->entity;
2287 dol_syslog(get_class($this).
"::insert_dirs", LOG_DEBUG);
2288 $result = $this->db->query($sql);
2290 $row = $this->db->fetch_row($result);
2293 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (name, type, value, note, visible, entity)";
2294 $sql .=
" VALUES (".$this->db->encrypt($name).
", 'chaine', ".$this->db->encrypt($dir).
", '".$this->db->escape(
"Directory for module ".$this->
name).
"', '0', ".((int) $conf->entity).
")";
2296 dol_syslog(get_class($this).
"::insert_dirs", LOG_DEBUG);
2297 $this->db->query($sql);
2300 $this->error = $this->db->lasterror();
2321 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
2322 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" LIKE '".$this->db->escape($this->const_name).
"_DIR_%'";
2323 $sql .=
" AND entity = ".$conf->entity;
2325 dol_syslog(get_class($this).
"::delete_dirs", LOG_DEBUG);
2326 if (!$this->db->query($sql)) {
2327 $this->error = $this->db->lasterror();
2344 global $conf, $langs;
2348 if (is_array($this->module_parts)) {
2349 if (empty($this->module_parts[
'icon']) && !empty($this->picto) && preg_match(
'/^fa\-/', $this->picto)) {
2350 $this->module_parts[
'icon'] = $this->picto;
2353 foreach ($this->module_parts as $key => $value) {
2354 if (is_array($value) && count($value) == 0) {
2359 if ($key ==
'websitetemplates' && $value == 1) {
2363 $docs =
dol_dir_list($srcroot,
'directories', 0,
'website_.*$');
2364 foreach ($docs as $cursorfile) {
2365 $src = $srcroot.
'/'.$cursorfile[
'name'];
2366 $dest = DOL_DATA_ROOT.
'/doctemplates/websites/'.$cursorfile[
'name'];
2373 $result = dol_compress_dir($src, $dest.
'.zip',
'zip');
2376 $this->error = ($errormsg ? $errormsg : $langs->trans(
'ErrorFailToCreateZip', $dest));
2377 $this->errors[] = ($errormsg ? $errormsg : $langs->trans(
'ErrorFailToCreateZip', $dest));
2382 $docs =
dol_dir_list($srcroot,
'files', 0,
'website_.*\.jpg$');
2383 foreach ($docs as $cursorfile) {
2384 $src = $srcroot.
'/'.$cursorfile[
'name'];
2385 $dest = DOL_DATA_ROOT.
'/doctemplates/websites/'.$cursorfile[
'name'];
2391 $entity = $conf->entity;
2395 if (is_array($value)) {
2398 if (isset($value[
'data']) && is_array($value[
'data'])) {
2399 $newvalue = json_encode($value[
'data']);
2400 if (isset($value[
'entity'])) {
2401 $entity = $value[
'entity'];
2403 } elseif (isset($value[
'data']) && !is_array($value[
'data'])) {
2404 $newvalue = $value[
'data'];
2405 if (isset($value[
'entity'])) {
2406 $entity = $value[
'entity'];
2409 $newvalue = json_encode($value);
2413 if (!empty($newvalue)) {
2414 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (";
2419 $sql .=
", visible";
2422 $sql .=
" VALUES (";
2423 $sql .=
" ".$this->db->encrypt($this->const_name.
"_".strtoupper($key), 1);
2424 $sql .=
", 'chaine'";
2425 $sql .=
", ".$this->db->encrypt($newvalue, 1);
2428 $sql .=
", ".((int) $entity);
2431 dol_syslog(get_class($this).
"::insert_module_parts for key=".$this->const_name.
"_".strtoupper($key), LOG_DEBUG);
2433 $resql = $this->db->query($sql, 1);
2435 if ($this->db->lasterrno() !=
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2437 $this->error = $this->db->lasterror();
2439 dol_syslog(get_class($this).
"::insert_module_parts for ".$this->const_name.
"_".strtoupper($key).
" Record already exists.", LOG_WARNING);
2461 if (is_array($this->module_parts)) {
2462 dol_syslog(get_class($this).
"::delete_module_parts", LOG_DEBUG);
2464 if (empty($this->module_parts[
'icon']) && !empty($this->picto) && preg_match(
'/^fa\-/', $this->picto)) {
2465 $this->module_parts[
'icon'] = $this->picto;
2468 foreach ($this->module_parts as $key => $value) {
2470 if (is_array($value) && isset($value[
'entity'])) {
2471 $entity = $value[
'entity'];
2473 $entity = $conf->entity;
2476 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
2477 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" LIKE '".$this->db->escape($this->const_name).
"_".strtoupper($key).
"'";
2478 $sql .=
" AND entity = ".((int) $entity);
2480 if (!$this->db->query($sql)) {
2481 $this->error = $this->db->lasterror();
2498 public function init($options =
'')
2500 return $this->
_init(array(), $options);
2511 public function remove($options =
'')
2513 return $this->
_remove(array(), $options);
2531 $imginfo =
"info_black";
2534 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($this)));
2538 if (preg_match(
'/development/i', $version)) {
2539 $versiontrans .=
'warning';
2541 if (preg_match(
'/experimental/i', $version)) {
2542 $versiontrans .=
'warning';
2544 if (preg_match(
'/deprecated/i', $version)) {
2545 $versiontrans .=
'warning';
2549 <div class="box-flex-item info-box-module'
2550 .(getDolGlobalString($const_name) ?
'' :
' --disabled')
2552 .($this->needUpdate ?
' --need-update' :
'')
2554 <div class="info-box info-box-sm info-box-module">
2555 <div class="info-box-icon'.(!
getDolGlobalString($const_name) ?
'' :
' info-box-icon-module-enabled'.($versiontrans ?
' info-box-icon-module-warning' :
'')).
'">';
2560 if (!empty($this->picto)) {
2561 if (preg_match(
'/^\//i', $this->picto)) {
2562 $return .=
img_picto($alttext, $this->picto,
'class="inline-block valignmiddle"', 1);
2564 $return .=
img_object($alttext, $this->picto,
'class="inline-block valignmiddle"');
2567 $return .=
img_object($alttext,
'generic',
'class="inline-block valignmiddle"');
2570 if ($this->
isCoreOrExternalModule() ==
'external' || preg_match(
'/development|experimental|deprecated/i', $version)) {
2571 $versionTitle = $langs->trans(
"Version").
' '.$this->
getVersion(1);
2572 if ($this->needUpdate) {
2573 $versionTitle .=
'<br>'.$langs->trans(
'ModuleUpdateAvailable').
' : '.
$this->lastVersion;
2576 $return .=
'<span class="info-box-icon-version'.($versiontrans ?
' '.$versiontrans :
'').
' classfortooltip" title="'.
dol_escape_js($versionTitle).
'" >';
2578 $return .=
'</span>';
2582 <div class="info-box-content info-box-text-module'.(!
getDolGlobalString($const_name) ?
'' :
' info-box-module-enabled'.($versiontrans ?
' info-box-content-warning' :
'')).
'">
2583 <span class="info-box-title">'.$this->
getName().
'</span>
2586 $return .=
'<div class="valignmiddle inline-block info-box-more">';
2588 $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>';
2589 $return .= '</div><br>';
2591 $return .= '<div class="valignmiddle
inline-block info-box-actions
">';
2592 $return .= '<div class="valignmiddle
inline-block info-box-setup
">';
2593 $return .= $codetoconfig;
2594 $return .= '</div>';
2595 $return .= '<div class="valignmiddle
inline-block marginleftonly marginrightonly
">';
2596 $return .= $codeenabledisable;
2597 $return .= '</div>';
2598 $return .= '</div>';
2601 </div><!-- /.info-box-content -->
2602 </div><!-- /.info-box -->
2615 public function checkForUpdate()
2617 require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
2618 if (!empty($this->url_last_version)) {
2619 $lastVersion = getURLContent($this->url_last_version, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only
2620 if (isset($lastVersion['content']) && strlen($lastVersion['content']) < 30) {
2621 // 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 _ . -
2622 $this->lastVersion = preg_replace("/[^a-zA-Z0-9_\.\-]+/
", "", $lastVersion['content']);
2623 if (version_compare($this->lastVersion, $this->version) > 0) {
2624 $this->needUpdate = true;
2627 $this->needUpdate = false;
2643 public function checkForCompliance()
2645 global $conf, $langs;
2647 // Get list of illegal modules name or ID
2648 if (empty($conf->cache['noncompliantmodules'])) {
2649 require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
2651 $urlforblacklistmodules = 'https://ping.dolibarr.org/modules-blacklist.txt';
2653 $result = getURLContent($urlforblacklistmodules, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only
2654 if (isset($result['content']) && $result['http_code'] == 200) {
2655 $langs->load("errors
");
2657 // 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 _ . -
2658 $arrayoflines = preg_split("/[\n,]/
", $result['content']);
2659 foreach ($arrayoflines as $line) {
2660 $tmpfieldsofline = explode(';', $line);
2661 $modulekey = strtolower($tmpfieldsofline[0]);
2662 $conf->cache['noncompliantmodules'][$modulekey]['name'] = $tmpfieldsofline[0];
2663 $conf->cache['noncompliantmodules'][$modulekey]['id'] = $tmpfieldsofline[1];
2664 $conf->cache['noncompliantmodules'][$modulekey]['signature'] = $tmpfieldsofline[2];
2665 $conf->cache['noncompliantmodules'][$modulekey]['message'] = $langs->trans(empty($tmpfieldsofline[3]) ? 'WarningModuleAffiliatedToAReportedCompany' : $tmpfieldsofline[3]);
2666 if (!empty($tmpfieldsofline[4])) {
2667 $message2 = $langs->trans("WarningModuleAffiliatedToAPiratPlatform
", '{s}');
2668 $listofillegalurl = '';
2669 foreach (explode(" ", $tmpfieldsofline[4]) as $illegalurl) {
2670 $listofillegalurl .= ($listofillegalurl ? ' '.$langs->trans("or
").' ' : '').'<b>'.preg_replace('/[^a-z0-9\.\-]/', '', $illegalurl).'</b>';
2672 $message2 = str_replace('{s}', $listofillegalurl, $message2);
2673 $conf->cache['noncompliantmodules'][$modulekey]['message2'] = $message2;
2679 if (!empty($conf->cache['noncompliantmodules'])) {
2680 $modulekey = strtolower($this->name);
2681 if (in_array($modulekey, array_keys($conf->cache['noncompliantmodules']))) {
2682 $answer = trim($conf->cache['noncompliantmodules'][$modulekey]['message']);
2683 if (!empty($conf->cache['noncompliantmodules'][$modulekey]['message2'])) {
2684 $answer .= '<br>'.$conf->cache['noncompliantmodules'][$modulekey]['message2'];
2711 protected function declareNewDictionary($dictionaryArray, $langs = '')
2713 $fields = array('name', 'lib', 'sql', 'sqlsort', 'field', 'fieldvalue', 'fieldinsert', 'rowid', 'cond', 'help', 'fieldcheck');
2715 foreach ($fields as $field) {
2716 if (isset($dictionaryArray[$field])) {
2717 $this->dictionaries['tab'.$field][] = $dictionaryArray[$field];
2720 if ($langs && !in_array($langs, $this->dictionaries[$langs])) {
2721 $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.