88 public $module_position =
'50';
105 public $dirs = array();
110 public $boxes = array();
115 public $const = array();
120 public $cronjobs = array();
130 public $rights_admin_allowed;
135 public $rights_class;
140 public $menu = array();
169 public $module_parts = array();
181 public $dbversion =
"-";
230 public $descriptionlong;
235 public $dictionaries;
252 public $export_label;
259 public $export_enabled;
260 public $export_permission;
261 public $export_fields_array;
262 public $export_TypeFields_array;
263 public $export_entities_array;
264 public $export_aggregate_array;
265 public $export_examplevalues_array;
266 public $export_help_array;
267 public $export_special_array;
268 public $export_dependencies_array;
269 public $export_sql_start;
270 public $export_sql_end;
271 public $export_sql_order;
284 public $import_label;
287 public $import_entities_array;
288 public $import_tables_array;
289 public $import_tables_creator_array;
290 public $import_fields_array;
291 public $import_fieldshidden_array;
292 public $import_convertvalue_array;
293 public $import_regex_array;
294 public $import_examplevalues_array;
295 public $import_updatekeys_array;
296 public $import_run_sql_after_array;
297 public $import_TypeFields_array;
298 public $import_help_array;
308 public $always_enabled;
318 public $core_enabled;
334 public $config_page_url;
353 public $conflictwith;
365 public $warnings_activation;
372 public $warnings_activation_ext;
379 public $warnings_unactivation;
393 public $need_dolibarr_version;
395 public $need_javascript_ajax;
397 public $enabled_bydefault;
402 public $hidden =
false;
407 public $url_last_version;
436 protected function _init($array_sql, $options =
'')
460 if (!$err && !preg_match(
'/newboxdefonly/', $options)) {
465 if (!$err && !preg_match(
'/noboxes/', $options)) {
490 $num = count($array_sql);
491 for ($i = 0; $i < $num; $i++) {
493 $val = $array_sql[$i];
496 if (is_array($val)) {
498 $ignoreerror = $val[
'ignoreerror'];
501 $sql = str_replace(
'__ENTITY__', $conf->entity, $sql);
503 dol_syslog(get_class($this).
"::_init ignoreerror=".$ignoreerror, LOG_DEBUG);
504 $result = $this->db->query($sql, $ignoreerror);
507 $this->error = $this->db->lasterror();
510 dol_syslog(get_class($this).
"::_init Warning ".$this->db->lasterror(), LOG_WARNING);
521 $this->db->rollback();
535 protected function _remove($array_sql, $options =
'')
563 if (!$err && !preg_match(
'/(newboxdefonly|noboxes)/', $options)) {
588 $num = count((array) $array_sql);
589 for ($i = 0; $i < $num; $i++) {
591 dol_syslog(get_class($this).
"::_remove", LOG_DEBUG);
592 $result = $this->db->query($array_sql[$i]);
594 $this->error = $this->db->error();
605 $this->db->rollback();
620 $langs->load(
"admin");
622 if ($langs->transnoentitiesnoconv(
"Module".$this->numero.
"Name") !=
"Module".$this->numero.
"Name") {
624 return $langs->transnoentitiesnoconv(
"Module".$this->numero.
"Name");
627 if (is_array($this->langfiles)) {
628 foreach ($this->langfiles as $val) {
635 if ($langs->trans(
"Module".$this->name.
"Name") !=
"Module".$this->name.
"Name") {
637 return $langs->transnoentitiesnoconv(
"Module".$this->
name.
"Name");
641 return $langs->transnoentitiesnoconv($this->
name);
654 $langs->load(
"admin");
656 if ($langs->transnoentitiesnoconv(
"Module".$this->numero.
"Desc") !=
"Module".$this->numero.
"Desc") {
658 return $langs->transnoentitiesnoconv(
"Module".$this->numero.
"Desc");
661 if (is_array($this->langfiles)) {
662 foreach ($this->langfiles as $val) {
669 if ($langs->transnoentitiesnoconv(
"Module".$this->name.
"Desc") !=
"Module".$this->name.
"Desc") {
671 return $langs->trans(
"Module".$this->
name.
"Desc");
688 $langs->load(
"admin");
690 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
691 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
697 $content = file_get_contents($pathoffile);
699 if ((
float) DOL_VERSION >= 6.0) {
700 @include_once DOL_DOCUMENT_ROOT.
'/core/lib/parsemd.lib.php';
712 $content = preg_replace(
'/<a href="/',
'<a target="_blank" rel="noopener noreferrer" href="', $content);
714 $content = nl2br($content);
718 if (!empty($this->descriptionlong)) {
719 if (is_array($this->langfiles)) {
720 foreach ($this->langfiles as $val) {
727 $content = $langs->transnoentitiesnoconv($this->descriptionlong);
747 $pathoffile =
dol_buildpath(strtolower($this->
name).
'/README-'.$langs->defaultlang.
'.md', 0);
752 $tmp = explode(
'_', $langs->defaultlang);
753 $pathoffile =
dol_buildpath(strtolower($this->
name).
'/README-'.$tmp[0].
'.md', 0);
765 return ($filefound ? $pathoffile :
'');
777 $langs->load(
"admin");
779 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
780 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
786 $pathoffile =
dol_buildpath(strtolower($this->
name).
'/ChangeLog-'.$langs->defaultlang.
'.md', 0);
798 $content = file_get_contents($pathoffile);
800 if ((
float) DOL_VERSION >= 6.0) {
801 @include_once DOL_DOCUMENT_ROOT.
'/core/lib/parsemd.lib.php';
805 $content = nl2br($content);
819 return $this->editor_name;
829 return $this->editor_url;
843 $langs->load(
"admin");
847 $newversion = preg_replace(
'/_deprecated/',
'', $this->version);
848 if ($newversion ==
'experimental') {
849 $ret = ($translated ? $langs->transnoentitiesnoconv(
"VersionExperimental") : $newversion);
850 } elseif ($newversion ==
'development') {
851 $ret = ($translated ? $langs->transnoentitiesnoconv(
"VersionDevelopment") : $newversion);
852 } elseif ($newversion ==
'dolibarr') {
854 } elseif ($newversion) {
857 $ret = ($translated ? $langs->transnoentitiesnoconv(
"VersionUnknown") :
'unknown');
860 if (preg_match(
'/_deprecated/', $this->version)) {
861 $ret .= ($translated ?
' ('.$langs->transnoentitiesnoconv(
"Deprecated").
')' : $this->version);
873 if (in_array($this->version, array(
'dolibarr',
'experimental',
'development'))) {
874 return $this->module_position;
876 if ($this->module_position >= 100000) {
877 return $this->module_position;
879 return $this->module_position + 100000;
893 if ($this->version ==
'dolibarr' || $this->version ==
'dolibarr_deprecated') {
896 if (!empty($this->version) && !in_array($this->version, array(
'experimental',
'development'))) {
899 if (!empty($this->editor_name) || !empty($this->editor_url)) {
902 if ($this->numero >= 100000) {
916 return $this->langfiles;
930 $langstring =
"ExportDataset_".$this->export_code[$r];
931 if ($langs->trans($langstring) == $langstring) {
933 return $langs->trans($this->export_label[$r]);
936 return $langs->trans($langstring);
952 $langstring =
"ImportDataset_".$this->import_code[$r];
954 if ($langs->trans($langstring) == $langstring) {
956 return $langs->transnoentitiesnoconv($this->import_label[$r]);
959 return $langs->transnoentitiesnoconv($langstring);
975 $sql =
"SELECT tms FROM ".MAIN_DB_PREFIX.
"const";
976 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
977 $sql .=
" AND entity IN (0, ".((int) $conf->entity).
")";
979 dol_syslog(get_class($this).
"::getLastActiveDate", LOG_DEBUG);
980 $resql = $this->db->query($sql);
984 $obj = $this->db->fetch_object($resql);
986 return $this->db->jdate($obj->tms);
1005 $sql =
"SELECT tms, note FROM ".MAIN_DB_PREFIX.
"const";
1006 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1007 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
1009 dol_syslog(get_class($this).
"::getLastActiveDate", LOG_DEBUG);
1010 $resql = $this->db->query($sql);
1014 $obj = $this->db->fetch_object($resql);
1018 $tmp = json_decode($obj->note,
true);
1021 'authorid' => empty($tmp[
'authorid']) ?
'' : $tmp[
'authorid'],
1022 'ip' => empty($tmp[
'ip']) ?
'' : $tmp[
'ip'],
1023 'lastactivationdate' => $this->db->jdate($obj->tms),
1024 'lastactivationversion' => (!empty($tmp[
'lastactivationversion']) ? $tmp[
'lastactivationversion'] :
'unknown'),
1042 global $conf, $user;
1047 $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity);
1049 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1050 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1051 $sql .=
" AND entity IN (0, ".$entity.
")";
1053 dol_syslog(get_class($this).
"::_active delete activation constant", LOG_DEBUG);
1054 $resql = $this->db->query($sql);
1059 $note = json_encode(
1061 'authorid' => (is_object($user) ? $user->id : 0),
1062 'ip' => (empty($_SERVER[
'REMOTE_ADDR']) ?
'' : $_SERVER[
'REMOTE_ADDR']),
1063 'lastactivationversion' => $this->version,
1067 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (name, value, visible, entity, note) VALUES";
1068 $sql .=
" (".$this->db->encrypt($this->const_name);
1069 $sql .=
", ".$this->db->encrypt(
'1');
1070 $sql .=
", 0, ".((int) $entity);
1071 $sql .=
", '".$this->db->escape($note).
"')";
1073 dol_syslog(get_class($this).
"::_active insert activation constant", LOG_DEBUG);
1074 $resql = $this->db->query($sql);
1097 $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity);
1099 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1100 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1101 $sql .=
" AND entity IN (0, ".$entity.
")";
1103 dol_syslog(get_class($this).
"::_unactive", LOG_DEBUG);
1104 $this->db->query($sql);
1134 if (empty($reldir)) {
1138 include_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
1141 foreach ($conf->file->dol_document_root as $dirroot) {
1143 $dirsql = $dirroot.$reldir;
1147 $listofsubdir = array(
'',
'tables/',
'data/');
1148 if ($this->db->type ==
'pgsql') {
1149 $listofsubdir[] =
'../pgsql/functions/';
1152 foreach ($listofsubdir as $subdir) {
1153 $dir = $dirsql.$subdir;
1155 $handle = @opendir($dir);
1156 if (is_resource($handle)) {
1161 while (($file = readdir($handle)) !==
false) {
1165 foreach ($files as $file) {
1166 if ($onlywithsuffix) {
1167 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1174 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 4) ==
'llx_') {
1186 while (($file = readdir($handle)) !==
false) {
1190 foreach ($files as $file) {
1191 if ($onlywithsuffix) {
1192 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1199 if (preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 4) ==
'llx_') {
1211 while (($file = readdir($handle)) !==
false) {
1215 foreach ($files as $file) {
1216 if ($onlywithsuffix) {
1217 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1224 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 9) ==
'functions') {
1236 while (($file = readdir($handle)) !==
false) {
1240 foreach ($files as $file) {
1241 if ($onlywithsuffix) {
1242 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1249 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 4) ==
'data') {
1261 while (($file = readdir($handle)) !==
false) {
1265 foreach ($files as $file) {
1266 if ($onlywithsuffix) {
1267 if (!preg_match(
'/\-'.preg_quote($onlywithsuffix,
'/').
'\./i', $file)) {
1274 if (preg_match(
'/\.sql$/i', $file) && !preg_match(
'/\.key\.sql$/i', $file) && substr($file, 0, 6) ==
'update') {
1293 dol_syslog(
"A module ask to load sql files into ".$reldir.
" but this directory was not found.", LOG_WARNING);
1310 include_once DOL_DOCUMENT_ROOT.
'/core/class/infobox.class.php';
1316 if (is_array($this->boxes)) {
1317 dol_syslog(get_class($this).
"::insert_boxes", LOG_DEBUG);
1321 foreach ($this->boxes as $key => $value) {
1322 $file = isset($this->boxes[$key][
'file']) ? $this->boxes[$key][
'file'] :
'';
1323 $note = isset($this->boxes[$key][
'note']) ? $this->boxes[$key][
'note'] :
'';
1324 $enabledbydefaulton = isset($this->boxes[$key][
'enabledbydefaulton']) ? $this->boxes[$key][
'enabledbydefaulton'] :
'Home';
1327 $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] :
'';
1330 $note = isset($this->boxes[$key][2]) ? $this->boxes[$key][2] :
'';
1334 $sql =
"SELECT count(*) as nb FROM ".MAIN_DB_PREFIX.
"boxes_def";
1335 $sql .=
" WHERE file = '".$this->db->escape($file).
"'";
1336 $sql .=
" AND entity = ".$conf->entity;
1338 $sql .=
" AND note ='".$this->db->escape($note).
"'";
1341 $result = $this->db->query($sql);
1343 $obj = $this->db->fetch_object($result);
1344 if ($obj->nb == 0) {
1348 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"boxes_def (file, entity, note)";
1349 $sql .=
" VALUES ('".$this->db->escape($file).
"', ";
1350 $sql .= $conf->entity.
", ";
1351 $sql .= $note ?
"'".$this->db->escape($note).
"'" :
"null";
1354 dol_syslog(get_class($this).
"::insert_boxes", LOG_DEBUG);
1355 $resql = $this->db->query($sql);
1360 if (!$err && !preg_match(
'/newboxdefonly/', $option)) {
1361 $lastid = $this->db->last_insert_id(MAIN_DB_PREFIX.
"boxes_def",
"rowid");
1363 foreach ($pos_name as $key2 => $val2) {
1365 if ($enabledbydefaulton && $val2 != $enabledbydefaulton) {
1369 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"boxes (box_id, position, box_order, fk_user, entity)";
1370 $sql .=
" VALUES (".((int) $lastid).
", ".((int) $key2).
", '0', 0, ".((int) $conf->entity).
")";
1372 dol_syslog(get_class($this).
"::insert_boxes onto page ".$key2.
"=".$val2, LOG_DEBUG);
1373 $resql = $this->db->query($sql);
1381 $this->db->commit();
1383 $this->error = $this->db->lasterror();
1384 $this->db->rollback();
1389 $this->error = $this->db->lasterror();
1412 if (is_array($this->boxes)) {
1413 foreach ($this->boxes as $key => $value) {
1415 if (empty($this->boxes[$key][
'file'])) {
1416 $file = isset($this->boxes[$key][1]) ? $this->boxes[$key][1] :
'';
1418 $file = $this->boxes[$key][
'file'];
1426 if ($file ==
'box_graph_product_distribution.php') {
1427 if (isModEnabled(
"product") || isModEnabled(
"service")) {
1428 dol_syslog(
"We discard deleting module ".$file.
" because another module still active requires it.");
1433 if ($this->db->type ==
'sqlite3') {
1436 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes ";
1437 $sql .=
"WHERE ".MAIN_DB_PREFIX.
"boxes.box_id IN (";
1438 $sql .=
"SELECT ".MAIN_DB_PREFIX.
"boxes_def.rowid ";
1439 $sql .=
"FROM ".MAIN_DB_PREFIX.
"boxes_def ";
1440 $sql .=
"WHERE ".MAIN_DB_PREFIX.
"boxes_def.file = '".$this->db->escape($file).
"') ";
1441 $sql .=
"AND ".MAIN_DB_PREFIX.
"boxes.entity = ".$conf->entity;
1443 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes";
1444 $sql .=
" USING ".MAIN_DB_PREFIX.
"boxes, ".MAIN_DB_PREFIX.
"boxes_def";
1445 $sql .=
" WHERE ".MAIN_DB_PREFIX.
"boxes.box_id = ".MAIN_DB_PREFIX.
"boxes_def.rowid";
1446 $sql .=
" AND ".MAIN_DB_PREFIX.
"boxes_def.file = '".$this->db->escape($file).
"'";
1447 $sql .=
" AND ".MAIN_DB_PREFIX.
"boxes.entity = ".$conf->entity;
1450 dol_syslog(get_class($this).
"::delete_boxes", LOG_DEBUG);
1451 $resql = $this->db->query($sql);
1453 $this->error = $this->db->lasterror();
1457 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"boxes_def";
1458 $sql .=
" WHERE file = '".$this->db->escape($file).
"'";
1459 $sql .=
" AND entity = ".$conf->entity;
1461 dol_syslog(get_class($this).
"::delete_boxes", LOG_DEBUG);
1462 $resql = $this->db->query($sql);
1464 $this->error = $this->db->lasterror();
1482 include_once DOL_DOCUMENT_ROOT.
'/core/class/infobox.class.php';
1488 if (is_array($this->cronjobs)) {
1489 dol_syslog(get_class($this).
"::insert_cronjobs", LOG_DEBUG);
1491 foreach ($this->cronjobs as $key => $value) {
1492 $entity = isset($this->cronjobs[$key][
'entity']) ? $this->cronjobs[$key][
'entity'] : $conf->entity;
1493 $label = isset($this->cronjobs[$key][
'label']) ? $this->cronjobs[$key][
'label'] :
'';
1494 $jobtype = isset($this->cronjobs[$key][
'jobtype']) ? $this->cronjobs[$key][
'jobtype'] :
'';
1495 $class = isset($this->cronjobs[$key][
'class']) ? $this->cronjobs[$key][
'class'] :
'';
1496 $objectname = isset($this->cronjobs[$key][
'objectname']) ? $this->cronjobs[$key][
'objectname'] :
'';
1497 $method = isset($this->cronjobs[$key][
'method']) ? $this->cronjobs[$key][
'method'] :
'';
1498 $command = isset($this->cronjobs[$key][
'command']) ? $this->cronjobs[$key][
'command'] :
'';
1499 $parameters = isset($this->cronjobs[$key][
'parameters']) ? $this->cronjobs[$key][
'parameters'] :
'';
1500 $comment = isset($this->cronjobs[$key][
'comment']) ? $this->cronjobs[$key][
'comment'] :
'';
1501 $frequency = isset($this->cronjobs[$key][
'frequency']) ? $this->cronjobs[$key][
'frequency'] :
'';
1502 $unitfrequency = isset($this->cronjobs[$key][
'unitfrequency']) ? $this->cronjobs[$key][
'unitfrequency'] :
'';
1503 $priority = isset($this->cronjobs[$key][
'priority']) ? $this->cronjobs[$key][
'priority'] :
'';
1504 $datestart = isset($this->cronjobs[$key][
'datestart']) ? $this->cronjobs[$key][
'datestart'] :
'';
1505 $dateend = isset($this->cronjobs[$key][
'dateend']) ? $this->cronjobs[$key][
'dateend'] :
'';
1506 $status = isset($this->cronjobs[$key][
'status']) ? $this->cronjobs[$key][
'status'] :
'';
1507 $test = isset($this->cronjobs[$key][
'test']) ? $this->cronjobs[$key][
'test'] :
'';
1510 $sql =
"SELECT count(*) as nb FROM ".MAIN_DB_PREFIX.
"cronjob";
1512 $sql .=
" WHERE label = '".$this->db->escape($label).
"'";
1528 $sql .=
" AND entity = ".((int) $entity);
1532 $result = $this->db->query($sql);
1534 $obj = $this->db->fetch_object($result);
1535 if ($obj->nb == 0) {
1539 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"cronjob (module_name, datec, datestart, dateend, label, jobtype, classesname, objectname, methodename, command, params, note,";
1540 if (is_int($frequency)) {
1541 $sql .=
' frequency,';
1543 if (is_int($unitfrequency)) {
1544 $sql .=
' unitfrequency,';
1546 if (is_int($priority)) {
1547 $sql .=
' priority,';
1549 if (is_int($status)) {
1552 $sql .=
" entity, test)";
1553 $sql .=
" VALUES (";
1554 $sql .=
"'".$this->db->escape(empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class).
"', ";
1555 $sql .=
"'".$this->db->idate($now).
"', ";
1556 $sql .= ($datestart ?
"'".$this->db->idate($datestart).
"'" :
"'".$this->db->idate($now).
"'").
", ";
1557 $sql .= ($dateend ?
"'".$this->db->idate($dateend).
"'" :
"NULL").
", ";
1558 $sql .=
"'".$this->db->escape($label).
"', ";
1559 $sql .=
"'".$this->db->escape($jobtype).
"', ";
1560 $sql .= ($class ?
"'".$this->db->escape($class).
"'" :
"null").
",";
1561 $sql .= ($objectname ?
"'".$this->db->escape($objectname).
"'" :
"null").
",";
1562 $sql .= ($method ?
"'".$this->db->escape($method).
"'" :
"null").
",";
1563 $sql .= ($command ?
"'".$this->db->escape($command).
"'" :
"null").
",";
1564 $sql .= ($parameters ?
"'".$this->db->escape($parameters).
"'" :
"null").
",";
1565 $sql .= ($comment ?
"'".$this->db->escape($comment).
"'" :
"null").
",";
1566 if (is_int($frequency)) {
1567 $sql .=
"'".$this->db->escape($frequency).
"', ";
1569 if (is_int($unitfrequency)) {
1570 $sql .=
"'".$this->db->escape($unitfrequency).
"', ";
1572 if (is_int($priority)) {
1573 $sql .=
"'".$this->db->escape($priority).
"', ";
1575 if (is_int($status)) {
1576 $sql .= ((int) $status).
", ";
1578 $sql .= $entity.
",";
1579 $sql .=
"'".$this->db->escape($test).
"'";
1582 $resql = $this->db->query($sql);
1589 $this->db->commit();
1591 $this->error = $this->db->lasterror();
1592 $this->db->rollback();
1597 $this->error = $this->db->lasterror();
1620 if (is_array($this->cronjobs)) {
1621 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"cronjob";
1622 $sql .=
" WHERE module_name = '".$this->db->escape(empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class).
"'";
1623 $sql .=
" AND entity = ".$conf->entity;
1624 $sql .=
" AND test = '1'";
1627 dol_syslog(get_class($this).
"::delete_cronjobs", LOG_DEBUG);
1628 $resql = $this->db->query($sql);
1630 $this->error = $this->db->lasterror();
1651 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1652 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" like '".$this->db->escape($this->const_name).
"_TABS_%'";
1653 $sql .=
" AND entity = ".$conf->entity;
1655 dol_syslog(get_class($this).
"::delete_tabs", LOG_DEBUG);
1656 if (!$this->db->query($sql)) {
1657 $this->error = $this->db->lasterror();
1677 if (!empty($this->tabs)) {
1678 dol_syslog(get_class($this).
"::insert_tabs", LOG_DEBUG);
1681 foreach ($this->tabs as $key => $value) {
1682 if (is_array($value) && count($value) == 0) {
1686 $entity = $conf->entity;
1689 if (is_array($value)) {
1690 $newvalue = $value[
'data'];
1691 if (isset($value[
'entity'])) {
1692 $entity = $value[
'entity'];
1697 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (";
1702 $sql .=
", visible";
1705 $sql .=
" VALUES (";
1706 $sql .= $this->db->encrypt($this->const_name.
"_TABS_".$i);
1707 $sql .=
", 'chaine'";
1708 $sql .=
", ".$this->db->encrypt($newvalue);
1711 $sql .=
", ".((int) $entity);
1714 $resql = $this->db->query($sql);
1717 if ($this->db->lasterrno() !=
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1718 $this->error = $this->db->lasterror();
1719 $this->errors[] = $this->db->lasterror();
1744 if (empty($this->
const)) {
1748 dol_syslog(get_class($this).
"::insert_const", LOG_DEBUG);
1750 foreach ($this->
const as $key => $value) {
1751 $name = $this->
const[$key][0];
1752 $type = $this->
const[$key][1];
1753 $val = $this->
const[$key][2];
1754 $note = isset($this->
const[$key][3]) ? $this->
const[$key][3] :
'';
1755 $visible = isset($this->
const[$key][4]) ? $this->
const[$key][4] : 0;
1756 $entity = (!empty($this->
const[$key][5]) && $this->
const[$key][5] !=
'current') ? 0 : $conf->entity;
1759 if (empty($visible)) {
1762 if (empty($val) && $val !=
'0') {
1766 $sql =
"SELECT count(*) as nb";
1767 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1768 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
1769 $sql .=
" AND entity = ".((int) $entity);
1771 $result = $this->db->query($sql);
1773 $row = $this->db->fetch_row($result);
1776 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (name,type,value,note,visible,entity)";
1777 $sql .=
" VALUES (";
1778 $sql .= $this->db->encrypt($name);
1779 $sql .=
",'".$this->db->escape($type).
"'";
1780 $sql .=
",".(($val !=
'') ? $this->db->encrypt($val) :
"''");
1781 $sql .=
",".($note ?
"'".$this->db->escape($note).
"'" :
"null");
1782 $sql .=
",'".$this->db->escape($visible).
"'";
1783 $sql .=
",".$entity;
1786 if (!$this->db->query($sql)) {
1790 dol_syslog(get_class($this).
"::insert_const constant '".$name.
"' already exists", LOG_DEBUG);
1813 if (empty($this->
const)) {
1817 foreach ($this->
const as $key => $value) {
1818 $name = $this->
const[$key][0];
1819 $deleteonunactive = (!empty($this->
const[$key][6])) ? 1 : 0;
1821 if ($deleteonunactive) {
1822 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1823 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
1824 $sql .=
" AND entity in (0, ".$conf->entity.
")";
1825 dol_syslog(get_class($this).
"::delete_const", LOG_DEBUG);
1826 if (!$this->db->query($sql)) {
1827 $this->error = $this->db->lasterror();
1848 global $conf, $user;
1851 $entity = (!empty($force_entity) ? $force_entity : $conf->entity);
1853 dol_syslog(get_class($this).
"::insert_permissions", LOG_DEBUG);
1856 $sql_del =
"SELECT ".$this->db->decrypt(
'value').
" as value";
1857 $sql_del .=
" FROM ".MAIN_DB_PREFIX.
"const";
1858 $sql_del .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1859 $sql_del .=
" AND entity IN (0,".$entity.
")";
1861 $resql = $this->db->query($sql_del);
1864 $obj = $this->db->fetch_object($resql);
1866 if ($obj !==
null && !empty($obj->value) && !empty($this->rights)) {
1867 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1870 foreach ($this->rights as $key => $value) {
1871 $r_id = $this->rights[$key][0];
1872 $r_desc = $this->rights[$key][1];
1873 $r_type = isset($this->rights[$key][2]) ? $this->rights[$key][2] :
'';
1874 $r_def = empty($this->rights[$key][3]) ? 0 : $this->rights[$key][3];
1875 $r_perms = $this->rights[$key][4];
1876 $r_subperms = isset($this->rights[$key][5]) ? $this->rights[$key][5] :
'';
1877 $r_modul = empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class;
1879 if (empty($r_type)) {
1884 $sql =
"SELECT count(*) as nb FROM ".MAIN_DB_PREFIX.
"rights_def";
1885 $sql .=
" WHERE id = ".((int) $r_id).
" AND entity = ".((int) $entity);
1887 $resqlselect = $this->db->query($sql);
1889 $objcount = $this->db->fetch_object($resqlselect);
1890 if ($objcount && $objcount->nb == 0) {
1893 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"rights_def";
1894 $sql .=
" (id, entity, libelle, module, type, bydefault, perms, subperms)";
1896 $sql .=
"(".$r_id.
",".$entity.
",'".$this->db->escape($r_desc).
"','".$this->db->escape($r_modul).
"','".$this->db->escape($r_type).
"',".$r_def.
",'".$this->db->escape($r_perms).
"','".$this->db->escape($r_subperms).
"')";
1898 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"rights_def";
1899 $sql .=
" (id, entity, libelle, module, type, bydefault, perms)";
1901 $sql .=
"(".$r_id.
",".$entity.
",'".$this->db->escape($r_desc).
"','".$this->db->escape($r_modul).
"','".$this->db->escape($r_type).
"',".$r_def.
",'".$this->db->escape($r_perms).
"')";
1904 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"rights_def ";
1905 $sql .=
" (id, entity, libelle, module, type, bydefault)";
1907 $sql .=
"(".$r_id.
",".$entity.
",'".$this->db->escape($r_desc).
"','".$this->db->escape($r_modul).
"','".$this->db->escape($r_type).
"',".$r_def.
")";
1910 $resqlinsert = $this->db->query($sql, 1);
1912 if (!$resqlinsert) {
1913 if ($this->db->errno() !=
"DB_ERROR_RECORD_ALREADY_EXISTS") {
1914 $this->error = $this->db->lasterror();
1918 dol_syslog(get_class($this).
"::insert_permissions record already exists", LOG_INFO);
1922 $this->db->free($resqlinsert);
1925 $this->db->free($resqlselect);
1929 if ($reinitadminperms) {
1930 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"user WHERE admin = 1";
1931 dol_syslog(get_class($this).
"::insert_permissions Search all admin users", LOG_DEBUG);
1933 $resqlseladmin = $this->db->query($sql, 1);
1935 if ($resqlseladmin) {
1936 $num = $this->db->num_rows($resqlseladmin);
1939 $obj2 = $this->db->fetch_object($resqlseladmin);
1940 dol_syslog(get_class($this).
"::insert_permissions Add permission id ".$r_id.
" to user id=".$obj2->rowid);
1942 $tmpuser =
new User($this->db);
1943 $result = $tmpuser->fetch($obj2->rowid);
1945 $tmpuser->addrights($r_id,
'',
'', 0, 1);
1947 dol_syslog(get_class($this).
"::insert_permissions Failed to add the permission to user because fetch return an error", LOG_ERR);
1957 if ($reinitadminperms && !empty($user->admin)) {
1959 $user->clearrights();
1963 $this->db->free($resql);
1965 $this->error = $this->db->lasterror();
1986 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"rights_def";
1987 $sql .=
" WHERE module = '".$this->db->escape(empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class).
"'";
1988 $sql .=
" AND entity = ".$conf->entity;
1989 dol_syslog(get_class($this).
"::delete_permissions", LOG_DEBUG);
1990 if (!$this->db->query($sql)) {
1991 $this->error = $this->db->lasterror();
2008 global $conf, $user;
2010 if (!is_array($this->menu) || empty($this->menu)) {
2014 include_once DOL_DOCUMENT_ROOT.
'/core/class/menubase.class.php';
2016 dol_syslog(get_class($this).
"::insert_menus", LOG_DEBUG);
2021 $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity);
2025 foreach ($this->menu as $key => $value) {
2027 $menu->menu_handler =
'all';
2030 $menu->module = (empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class);
2032 if (!$this->menu[$key][
'fk_menu']) {
2036 $fk_parent = $this->menu[$key][
'fk_menu'];
2038 if (preg_match(
'/^r=/', $fk_parent)) {
2039 $fk_parent = str_replace(
'r=',
'', $fk_parent);
2040 if (isset($this->menu[$fk_parent][
'rowid'])) {
2041 $menu->fk_menu = $this->menu[$fk_parent][
'rowid'];
2044 } elseif (preg_match(
'/^fk_mainmenu=([a-zA-Z0-9_]+),fk_leftmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) {
2045 $menu->fk_menu = -1;
2046 $menu->fk_mainmenu = $reg[1];
2047 $menu->fk_leftmenu = $reg[2];
2049 } elseif (preg_match(
'/^fk_mainmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) {
2050 $menu->fk_menu = -1;
2051 $menu->fk_mainmenu = $reg[1];
2052 $menu->fk_leftmenu =
'';
2055 if (!$foundparent) {
2056 $this->error =
"ErrorBadDefinitionOfMenuArrayInModuleDescriptor";
2057 dol_syslog(get_class($this).
"::insert_menus ".$this->error.
" ".$this->menu[$key][
'fk_menu'], LOG_ERR);
2061 $menu->type = $this->menu[$key][
'type'];
2062 $menu->mainmenu = isset($this->menu[$key][
'mainmenu']) ? $this->menu[$key][
'mainmenu'] : (isset($menu->fk_mainmenu) ? $menu->fk_mainmenu :
'');
2063 $menu->leftmenu = isset($this->menu[$key][
'leftmenu']) ? $this->menu[$key][
'leftmenu'] :
'';
2064 $menu->title = $this->menu[$key][
'titre'];
2065 $menu->prefix = isset($this->menu[$key][
'prefix']) ? $this->menu[$key][
'prefix'] :
'';
2066 $menu->url = $this->menu[$key][
'url'];
2067 $menu->langs = isset($this->menu[$key][
'langs']) ? $this->menu[$key][
'langs'] :
'';
2068 $menu->position = $this->menu[$key][
'position'];
2069 $menu->perms = $this->menu[$key][
'perms'];
2070 $menu->target = isset($this->menu[$key][
'target']) ? $this->menu[$key][
'target'] :
'';
2071 $menu->user = $this->menu[$key][
'user'];
2072 $menu->enabled = isset($this->menu[$key][
'enabled']) ? $this->menu[$key][
'enabled'] : 0;
2073 $menu->position = $this->menu[$key][
'position'];
2074 $menu->entity = $entity;
2077 $result = $menu->create($user);
2079 $this->menu[$key][
'rowid'] = $result;
2081 $this->error = $menu->error;
2082 dol_syslog(get_class($this).
'::insert_menus result='.$result.
" ".$this->error, LOG_ERR);
2090 $this->db->commit();
2092 dol_syslog(get_class($this).
"::insert_menus ".$this->error, LOG_ERR);
2093 $this->db->rollback();
2114 $module = empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class;
2116 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"menu";
2117 $sql .=
" WHERE module = '".$this->db->escape($module).
"'";
2118 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
2120 dol_syslog(get_class($this).
"::delete_menus", LOG_DEBUG);
2121 $resql = $this->db->query($sql);
2123 $this->error = $this->db->lasterror();
2139 global $langs, $conf;
2144 if (isset($this->dirs) && is_array($this->dirs)) {
2145 foreach ($this->dirs as $key => $value) {
2148 if (!is_array($value)) {
2151 $constname = $this->const_name.
"_DIR_";
2152 $dir = $this->dirs[$key][1];
2153 $addtodatabase = empty($this->dirs[$key][2]) ?
'' : $this->dirs[$key][2];
2154 $subname = empty($this->dirs[$key][3]) ?
'' : strtoupper($this->dirs[$key][3]);
2155 $forcename = empty($this->dirs[$key][4]) ?
'' : strtoupper($this->dirs[$key][4]);
2157 if (!empty($forcename)) {
2158 $constname =
'MAIN_MODULE_'.$forcename.
"_DIR_";
2160 if (!empty($subname)) {
2161 $constname = $constname.$subname.
"_";
2164 $name = $constname.strtoupper($this->dirs[$key][0]);
2169 $fulldir = DOL_DATA_ROOT.$dir;
2171 $fulldir = DOL_DATA_ROOT.
"/".$conf->entity.$dir;
2174 if (!empty($fulldir) && !file_exists($fulldir)) {
2175 if (
dol_mkdir($fulldir, DOL_DATA_ROOT) < 0) {
2176 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $fulldir);
2177 dol_syslog(get_class($this).
"::_init ".$this->error, LOG_ERR);
2183 if (!empty($addtodatabase) && !empty($name)) {
2212 $sql =
"SELECT count(*)";
2213 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
2214 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
2215 $sql .=
" AND entity = ".$conf->entity;
2217 dol_syslog(get_class($this).
"::insert_dirs", LOG_DEBUG);
2218 $result = $this->db->query($sql);
2220 $row = $this->db->fetch_row($result);
2223 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (name, type, value, note, visible, entity)";
2224 $sql .=
" VALUES (".$this->db->encrypt($name).
", 'chaine', ".$this->db->encrypt($dir).
", '".$this->db->escape(
"Directory for module ".$this->
name).
"', '0', ".((int) $conf->entity).
")";
2226 dol_syslog(get_class($this).
"::insert_dirs", LOG_DEBUG);
2227 $this->db->query($sql);
2230 $this->error = $this->db->lasterror();
2251 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
2252 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" LIKE '".$this->db->escape($this->const_name).
"_DIR_%'";
2253 $sql .=
" AND entity = ".$conf->entity;
2255 dol_syslog(get_class($this).
"::delete_dirs", LOG_DEBUG);
2256 if (!$this->db->query($sql)) {
2257 $this->error = $this->db->lasterror();
2277 if (is_array($this->module_parts)) {
2278 if (empty($this->module_parts[
'icon']) && !empty($this->picto) && preg_match(
'/^fa\-/', $this->picto)) {
2279 $this->module_parts[
'icon'] = $this->picto;
2282 foreach ($this->module_parts as $key => $value) {
2283 if (is_array($value) && count($value) == 0) {
2287 $entity = $conf->entity;
2291 if (is_array($value)) {
2294 if (isset($value[
'data']) && is_array($value[
'data'])) {
2295 $newvalue = json_encode($value[
'data']);
2296 if (isset($value[
'entity'])) {
2297 $entity = $value[
'entity'];
2299 } elseif (isset($value[
'data']) && !is_array($value[
'data'])) {
2300 $newvalue = $value[
'data'];
2301 if (isset($value[
'entity'])) {
2302 $entity = $value[
'entity'];
2305 $newvalue = json_encode($value);
2309 if (!empty($newvalue)) {
2310 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (";
2315 $sql .=
", visible";
2318 $sql .=
" VALUES (";
2319 $sql .=
" ".$this->db->encrypt($this->const_name.
"_".strtoupper($key), 1);
2320 $sql .=
", 'chaine'";
2321 $sql .=
", ".$this->db->encrypt($newvalue, 1);
2324 $sql .=
", ".((int) $entity);
2327 dol_syslog(get_class($this).
"::insert_module_parts for key=".$this->const_name.
"_".strtoupper($key), LOG_DEBUG);
2329 $resql = $this->db->query($sql, 1);
2331 if ($this->db->lasterrno() !=
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2333 $this->error = $this->db->lasterror();
2335 dol_syslog(get_class($this).
"::insert_module_parts for ".$this->const_name.
"_".strtoupper($key).
" Record already exists.", LOG_WARNING);
2357 if (is_array($this->module_parts)) {
2358 dol_syslog(get_class($this).
"::delete_module_parts", LOG_DEBUG);
2360 if (empty($this->module_parts[
'icon']) && !empty($this->picto) && preg_match(
'/^fa\-/', $this->picto)) {
2361 $this->module_parts[
'icon'] = $this->picto;
2364 foreach ($this->module_parts as $key => $value) {
2366 if (is_array($value) && isset($value[
'entity'])) {
2367 $entity = $value[
'entity'];
2369 $entity = $conf->entity;
2372 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
2373 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" LIKE '".$this->db->escape($this->const_name).
"_".strtoupper($key).
"'";
2374 $sql .=
" AND entity = ".((int) $entity);
2376 if (!$this->db->query($sql)) {
2377 $this->error = $this->db->lasterror();
2394 public function init($options =
'')
2396 return $this->
_init(array(), $options);
2407 public function remove($options =
'')
2409 return $this->
_remove(array(), $options);
2422 global $conf, $langs;
2427 $imginfo =
"info_black";
2430 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($this)));
2434 if (preg_match(
'/development/i', $version)) {
2435 $versiontrans .=
'warning';
2437 if (preg_match(
'/experimental/i', $version)) {
2438 $versiontrans .=
'warning';
2440 if (preg_match(
'/deprecated/i', $version)) {
2441 $versiontrans .=
'warning';
2445 <div class="box-flex-item info-box-module'
2446 .(getDolGlobalString($const_name) ?
'' :
' --disabled')
2448 .($this->needUpdate ?
' --need-update' :
'')
2450 <div class="info-box info-box-sm info-box-module">
2451 <div class="info-box-icon'.(!
getDolGlobalString($const_name) ?
'' :
' info-box-icon-module-enabled'.($versiontrans ?
' info-box-icon-module-warning' :
'')).
'">';
2456 if (!empty($this->picto)) {
2457 if (preg_match(
'/^\//i', $this->picto)) {
2458 $return .=
img_picto($alttext, $this->picto,
'class="inline-block valignmiddle"', 1);
2460 $return .=
img_object($alttext, $this->picto,
'class="inline-block valignmiddle"');
2463 $return .=
img_object($alttext,
'generic',
'class="inline-block valignmiddle"');
2466 if ($this->
isCoreOrExternalModule() ==
'external' || preg_match(
'/development|experimental|deprecated/i', $version)) {
2467 $versionTitle = $langs->trans(
"Version").
' '.$this->
getVersion(1);
2468 if ($this->needUpdate) {
2469 $versionTitle.=
'<br>'.$langs->trans(
'ModuleUpdateAvailable').
' : '.
$this->lastVersion;
2472 $return .=
'<span class="info-box-icon-version'.($versiontrans ?
' '.$versiontrans :
'').
' classfortooltip" title="'.
dol_escape_js($versionTitle).
'" >';
2474 $return .=
'</span>';
2478 <div class="info-box-content info-box-text-module'.(!
getDolGlobalString($const_name) ?
'' :
' info-box-module-enabled'.($versiontrans ?
' info-box-content-warning' :
'')).
'">
2479 <span class="info-box-title">'.$this->
getName().
'</span>
2482 $return .=
'<div class="valignmiddle inline-block info-box-more">';
2484 $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>';
2485 $return .= '</div><br>';
2487 $return .= '<div class="valignmiddle
inline-block info-box-actions
">';
2488 $return .= '<div class="valignmiddle
inline-block info-box-setup
">';
2489 $return .= $codetoconfig;
2490 $return .= '</div>';
2491 $return .= '<div class="valignmiddle
inline-block marginleftonly marginrightonly
">';
2492 $return .= $codeenabledisable;
2493 $return .= '</div>';
2494 $return .= '</div>';
2497 </div><!-- /.info-box-content -->
2498 </div><!-- /.info-box -->
2511 public function checkForUpdate()
2513 require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
2514 if (!empty($this->url_last_version)) {
2515 $lastVersion = getURLContent($this->url_last_version, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only
2516 if (isset($lastVersion['content']) && strlen($lastVersion['content']) < 30) {
2517 // 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 _ . -
2518 $this->lastVersion = preg_replace("/[^a-zA-Z0-9_\.\-]+/
", "", $lastVersion['content']);
2519 if (version_compare($this->lastVersion, $this->version) > 0) {
2520 $this->needUpdate = true;
2523 $this->needUpdate = false;
2539 public function checkForCompliance()
2541 global $conf, $langs;
2543 // Get list of illegal modules name or ID
2544 if (empty($conf->cache['noncompliantmodules'])) {
2545 require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
2547 $urlforblacklistmodules = 'https://ping.dolibarr.org/modules-blacklist.txt';
2549 $result = getURLContent($urlforblacklistmodules, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only
2550 if (isset($result['content']) && $result['http_code'] == 200) {
2551 $langs->load("errors
");
2553 // 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 _ . -
2554 $arrayoflines = preg_split("/[\n,]/
", $result['content']);
2555 foreach ($arrayoflines as $line) {
2556 $tmpfieldsofline = explode(';', $line);
2557 $modulekey = strtolower($tmpfieldsofline[0]);
2558 $conf->cache['noncompliantmodules'][$modulekey]['name'] = $tmpfieldsofline[0];
2559 $conf->cache['noncompliantmodules'][$modulekey]['id'] = $tmpfieldsofline[1];
2560 $conf->cache['noncompliantmodules'][$modulekey]['signature'] = $tmpfieldsofline[2];
2561 $conf->cache['noncompliantmodules'][$modulekey]['message'] = $langs->trans(empty($tmpfieldsofline[3]) ? 'WarningModuleAffiliatedToAReportedCompany' : $tmpfieldsofline[3]);
2562 if (!empty($tmpfieldsofline[4])) {
2563 $message2 = $langs->trans("WarningModuleAffiliatedToAPiratPlatform
", '{s}');
2564 $listofillegalurl = '';
2565 foreach (explode(" ", $tmpfieldsofline[4]) as $illegalurl) {
2566 $listofillegalurl .= ($listofillegalurl ? ' '.$langs->trans("or
").' ' : '').'<b>'.preg_replace('/[^a-z0-9\.\-]/', '', $illegalurl).'</b>';
2568 $message2 = str_replace('{s}', $listofillegalurl, $message2);
2569 $conf->cache['noncompliantmodules'][$modulekey]['message2'] = $message2;
2575 if (!empty($conf->cache['noncompliantmodules'])) {
2576 $modulekey = strtolower($this->name);
2577 if (in_array($modulekey, array_keys($conf->cache['noncompliantmodules']))) {
2578 $answer = trim($conf->cache['noncompliantmodules'][$modulekey]['message']);
2579 if (!empty($conf->cache['noncompliantmodules'][$modulekey]['message2'])) {
2580 $answer .= '<br>'.$conf->cache['noncompliantmodules'][$modulekey]['message2'];
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()
Adds generic parts.
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_is_file($pathoffile)
Return if path is a file.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.