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, ".$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_') {
1175 $result =
run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0,
'', 1);
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_') {
1200 $result =
run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0,
'', 1);
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') {
1225 $result =
run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0,
'', 1);
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') {
1250 $result =
run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0,
'', 1);
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') {
1275 $result =
run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0,
'', 1);
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 $datenextrun = isset($this->cronjobs[$key][
'datenextrun']) ? $this->cronjobs[$key][
'datenextrun'] :
'';
1505 $datestart = isset($this->cronjobs[$key][
'datestart']) ? $this->cronjobs[$key][
'datestart'] :
'';
1506 $dateend = isset($this->cronjobs[$key][
'dateend']) ? $this->cronjobs[$key][
'dateend'] :
'';
1507 $status = isset($this->cronjobs[$key][
'status']) ? $this->cronjobs[$key][
'status'] :
'';
1508 $test = isset($this->cronjobs[$key][
'test']) ? $this->cronjobs[$key][
'test'] :
'';
1511 $sql =
"SELECT count(*) as nb FROM ".MAIN_DB_PREFIX.
"cronjob";
1513 $sql .=
" WHERE label = '".$this->db->escape($label).
"'";
1529 $sql .=
" AND entity = ".((int) $entity);
1533 $result = $this->db->query($sql);
1535 $obj = $this->db->fetch_object($result);
1536 if ($obj->nb == 0) {
1540 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"cronjob (module_name, datec, datenextrun, datestart, dateend, label, jobtype, classesname, objectname, methodename, command, params, note,";
1541 if (is_int($frequency)) {
1542 $sql .=
' frequency,';
1544 if (is_int($unitfrequency)) {
1545 $sql .=
' unitfrequency,';
1547 if (is_int($priority)) {
1548 $sql .=
' priority,';
1550 if (is_int($status)) {
1553 $sql .=
" entity, test)";
1554 $sql .=
" VALUES (";
1555 $sql .=
"'".$this->db->escape(empty($this->rights_class) ?strtolower($this->
name) : $this->rights_class).
"', ";
1556 $sql .=
"'".$this->db->idate($now).
"', ";
1557 $sql .= ($datenextrun ?
"'".$this->db->idate($datenextrun).
"'" :
"'".$this->db->idate($now).
"'").
", ";
1558 $sql .= ($datestart ?
"'".$this->db->idate($datestart).
"'" :
"'".$this->db->idate($now).
"'").
", ";
1559 $sql .= ($dateend ?
"'".$this->db->idate($dateend).
"'" :
"NULL").
", ";
1560 $sql .=
"'".$this->db->escape($label).
"', ";
1561 $sql .=
"'".$this->db->escape($jobtype).
"', ";
1562 $sql .= ($class ?
"'".$this->db->escape($class).
"'" :
"null").
",";
1563 $sql .= ($objectname ?
"'".$this->db->escape($objectname).
"'" :
"null").
",";
1564 $sql .= ($method ?
"'".$this->db->escape($method).
"'" :
"null").
",";
1565 $sql .= ($command ?
"'".$this->db->escape($command).
"'" :
"null").
",";
1566 $sql .= ($parameters ?
"'".$this->db->escape($parameters).
"'" :
"null").
",";
1567 $sql .= ($comment ?
"'".$this->db->escape($comment).
"'" :
"null").
",";
1568 if (is_int($frequency)) {
1569 $sql .=
"'".$this->db->escape($frequency).
"', ";
1571 if (is_int($unitfrequency)) {
1572 $sql .=
"'".$this->db->escape($unitfrequency).
"', ";
1574 if (is_int($priority)) {
1575 $sql .=
"'".$this->db->escape($priority).
"', ";
1577 if (is_int($status)) {
1578 $sql .= ((int) $status).
", ";
1580 $sql .= $entity.
",";
1581 $sql .=
"'".$this->db->escape($test).
"'";
1584 $resql = $this->db->query($sql);
1591 $this->db->commit();
1593 $this->error = $this->db->lasterror();
1594 $this->db->rollback();
1599 $this->error = $this->db->lasterror();
1622 if (is_array($this->cronjobs)) {
1623 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"cronjob";
1624 $sql .=
" WHERE module_name = '".$this->db->escape(empty($this->rights_class) ?strtolower($this->
name) : $this->rights_class).
"'";
1625 $sql .=
" AND entity = ".$conf->entity;
1626 $sql .=
" AND test = '1'";
1629 dol_syslog(get_class($this).
"::delete_cronjobs", LOG_DEBUG);
1630 $resql = $this->db->query($sql);
1632 $this->error = $this->db->lasterror();
1653 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1654 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" like '".$this->db->escape($this->const_name).
"_TABS_%'";
1655 $sql .=
" AND entity = ".$conf->entity;
1657 dol_syslog(get_class($this).
"::delete_tabs", LOG_DEBUG);
1658 if (!$this->db->query($sql)) {
1659 $this->error = $this->db->lasterror();
1679 if (!empty($this->tabs)) {
1680 dol_syslog(get_class($this).
"::insert_tabs", LOG_DEBUG);
1683 foreach ($this->tabs as $key => $value) {
1684 if (is_array($value) && count($value) == 0) {
1688 $entity = $conf->entity;
1691 if (is_array($value)) {
1692 $newvalue = $value[
'data'];
1693 if (isset($value[
'entity'])) {
1694 $entity = $value[
'entity'];
1699 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (";
1704 $sql .=
", visible";
1707 $sql .=
" VALUES (";
1708 $sql .= $this->db->encrypt($this->const_name.
"_TABS_".$i);
1709 $sql .=
", 'chaine'";
1710 $sql .=
", ".$this->db->encrypt($newvalue);
1713 $sql .=
", ".((int) $entity);
1716 $resql = $this->db->query($sql);
1719 if ($this->db->lasterrno() !=
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1720 $this->error = $this->db->lasterror();
1721 $this->errors[] = $this->db->lasterror();
1746 if (empty($this->
const)) {
1750 dol_syslog(get_class($this).
"::insert_const", LOG_DEBUG);
1752 foreach ($this->
const as $key => $value) {
1753 $name = $this->
const[$key][0];
1754 $type = $this->
const[$key][1];
1755 $val = $this->
const[$key][2];
1756 $note = isset($this->
const[$key][3]) ? $this->
const[$key][3] :
'';
1757 $visible = isset($this->
const[$key][4]) ? $this->
const[$key][4] : 0;
1758 $entity = (!empty($this->
const[$key][5]) && $this->
const[$key][5] !=
'current') ? 0 : $conf->entity;
1761 if (empty($visible)) {
1764 if (empty($val) && $val !=
'0') {
1768 $sql =
"SELECT count(*) as nb";
1769 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1770 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
1771 $sql .=
" AND entity = ".((int) $entity);
1773 $result = $this->db->query($sql);
1775 $row = $this->db->fetch_row($result);
1778 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (name,type,value,note,visible,entity)";
1779 $sql .=
" VALUES (";
1780 $sql .= $this->db->encrypt($name);
1781 $sql .=
",'".$this->db->escape($type).
"'";
1782 $sql .=
",".(($val !=
'') ? $this->db->encrypt($val) :
"''");
1783 $sql .=
",".($note ?
"'".$this->db->escape($note).
"'" :
"null");
1784 $sql .=
",'".$this->db->escape($visible).
"'";
1785 $sql .=
",".$entity;
1788 if (!$this->db->query($sql)) {
1792 dol_syslog(get_class($this).
"::insert_const constant '".$name.
"' already exists", LOG_DEBUG);
1815 if (empty($this->
const)) {
1819 foreach ($this->
const as $key => $value) {
1820 $name = $this->
const[$key][0];
1821 $deleteonunactive = (!empty($this->
const[$key][6])) ? 1 : 0;
1823 if ($deleteonunactive) {
1824 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
1825 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
1826 $sql .=
" AND entity in (0, ".$conf->entity.
")";
1827 dol_syslog(get_class($this).
"::delete_const", LOG_DEBUG);
1828 if (!$this->db->query($sql)) {
1829 $this->error = $this->db->lasterror();
1850 global $conf, $user;
1853 $entity = (!empty($force_entity) ? $force_entity : $conf->entity);
1855 dol_syslog(get_class($this).
"::insert_permissions", LOG_DEBUG);
1858 $sql_del =
"SELECT ".$this->db->decrypt(
'value').
" as value";
1859 $sql_del .=
" FROM ".MAIN_DB_PREFIX.
"const";
1860 $sql_del .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($this->const_name).
"'";
1861 $sql_del .=
" AND entity IN (0,".$entity.
")";
1863 $resql = $this->db->query($sql_del);
1866 $obj = $this->db->fetch_object($resql);
1868 if ($obj !==
null && !empty($obj->value) && !empty($this->rights)) {
1869 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1872 foreach ($this->rights as $key => $value) {
1873 $r_id = $this->rights[$key][0];
1874 $r_desc = $this->rights[$key][1];
1875 $r_type = isset($this->rights[$key][2]) ? $this->rights[$key][2] :
'';
1876 $r_def = empty($this->rights[$key][3]) ? 0 : $this->rights[$key][3];
1877 $r_perms = $this->rights[$key][4];
1878 $r_subperms = isset($this->rights[$key][5]) ? $this->rights[$key][5] :
'';
1879 $r_modul = empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class;
1881 if (empty($r_type)) {
1886 $sql =
"SELECT count(*) as nb FROM ".MAIN_DB_PREFIX.
"rights_def";
1887 $sql .=
" WHERE id = ".((int) $r_id).
" AND entity = ".((int) $entity);
1889 $resqlselect = $this->db->query($sql);
1891 $objcount = $this->db->fetch_object($resqlselect);
1892 if ($objcount && $objcount->nb == 0) {
1895 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"rights_def";
1896 $sql .=
" (id, entity, libelle, module, type, bydefault, perms, subperms)";
1898 $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).
"')";
1900 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"rights_def";
1901 $sql .=
" (id, entity, libelle, module, type, bydefault, perms)";
1903 $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).
"')";
1906 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"rights_def ";
1907 $sql .=
" (id, entity, libelle, module, type, bydefault)";
1909 $sql .=
"(".$r_id.
",".$entity.
",'".$this->db->escape($r_desc).
"','".$this->db->escape($r_modul).
"','".$this->db->escape($r_type).
"',".$r_def.
")";
1912 $resqlinsert = $this->db->query($sql, 1);
1914 if (!$resqlinsert) {
1915 if ($this->db->errno() !=
"DB_ERROR_RECORD_ALREADY_EXISTS") {
1916 $this->error = $this->db->lasterror();
1920 dol_syslog(get_class($this).
"::insert_permissions record already exists", LOG_INFO);
1924 $this->db->free($resqlinsert);
1927 $this->db->free($resqlselect);
1931 if ($reinitadminperms) {
1932 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"user WHERE admin = 1";
1933 dol_syslog(get_class($this).
"::insert_permissions Search all admin users", LOG_DEBUG);
1935 $resqlseladmin = $this->db->query($sql, 1);
1937 if ($resqlseladmin) {
1938 $num = $this->db->num_rows($resqlseladmin);
1941 $obj2 = $this->db->fetch_object($resqlseladmin);
1942 dol_syslog(get_class($this).
"::insert_permissions Add permission id ".$r_id.
" to user id=".$obj2->rowid);
1944 $tmpuser =
new User($this->db);
1945 $result = $tmpuser->fetch($obj2->rowid);
1947 $tmpuser->addrights($r_id,
'',
'', 0, 1);
1949 dol_syslog(get_class($this).
"::insert_permissions Failed to add the permission to user because fetch return an error", LOG_ERR);
1959 if ($reinitadminperms && !empty($user->admin)) {
1961 $user->clearrights();
1965 $this->db->free($resql);
1967 $this->error = $this->db->lasterror();
1988 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"rights_def";
1989 $sql .=
" WHERE module = '".$this->db->escape(empty($this->rights_class) ?strtolower($this->
name) : $this->rights_class).
"'";
1990 $sql .=
" AND entity = ".$conf->entity;
1991 dol_syslog(get_class($this).
"::delete_permissions", LOG_DEBUG);
1992 if (!$this->db->query($sql)) {
1993 $this->error = $this->db->lasterror();
2010 global $conf, $user;
2012 if (!is_array($this->menu) || empty($this->menu)) {
2016 include_once DOL_DOCUMENT_ROOT.
'/core/class/menubase.class.php';
2018 dol_syslog(get_class($this).
"::insert_menus", LOG_DEBUG);
2023 $entity = ((!empty($this->always_enabled) || !empty($this->core_enabled)) ? 0 : $conf->entity);
2027 foreach ($this->menu as $key => $value) {
2029 $menu->menu_handler =
'all';
2032 $menu->module = (empty($this->rights_class) ? strtolower($this->
name) : $this->rights_class);
2034 if (!$this->menu[$key][
'fk_menu']) {
2038 $fk_parent = $this->menu[$key][
'fk_menu'];
2040 if (preg_match(
'/^r=/', $fk_parent)) {
2041 $fk_parent = str_replace(
'r=',
'', $fk_parent);
2042 if (isset($this->menu[$fk_parent][
'rowid'])) {
2043 $menu->fk_menu = $this->menu[$fk_parent][
'rowid'];
2046 } elseif (preg_match(
'/^fk_mainmenu=([a-zA-Z0-9_]+),fk_leftmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) {
2047 $menu->fk_menu = -1;
2048 $menu->fk_mainmenu = $reg[1];
2049 $menu->fk_leftmenu = $reg[2];
2051 } elseif (preg_match(
'/^fk_mainmenu=([a-zA-Z0-9_]+)$/', $fk_parent, $reg)) {
2052 $menu->fk_menu = -1;
2053 $menu->fk_mainmenu = $reg[1];
2054 $menu->fk_leftmenu =
'';
2057 if (!$foundparent) {
2058 $this->error =
"ErrorBadDefinitionOfMenuArrayInModuleDescriptor";
2059 dol_syslog(get_class($this).
"::insert_menus ".$this->error.
" ".$this->menu[$key][
'fk_menu'], LOG_ERR);
2063 $menu->type = $this->menu[$key][
'type'];
2064 $menu->mainmenu = isset($this->menu[$key][
'mainmenu']) ? $this->menu[$key][
'mainmenu'] : (isset($menu->fk_mainmenu) ? $menu->fk_mainmenu :
'');
2065 $menu->leftmenu = isset($this->menu[$key][
'leftmenu']) ? $this->menu[$key][
'leftmenu'] :
'';
2066 $menu->title = $this->menu[$key][
'titre'];
2067 $menu->prefix = isset($this->menu[$key][
'prefix']) ? $this->menu[$key][
'prefix'] :
'';
2068 $menu->url = $this->menu[$key][
'url'];
2069 $menu->langs = isset($this->menu[$key][
'langs']) ? $this->menu[$key][
'langs'] :
'';
2070 $menu->position = $this->menu[$key][
'position'];
2071 $menu->perms = $this->menu[$key][
'perms'];
2072 $menu->target = isset($this->menu[$key][
'target']) ? $this->menu[$key][
'target'] :
'';
2073 $menu->user = $this->menu[$key][
'user'];
2074 $menu->enabled = isset($this->menu[$key][
'enabled']) ? $this->menu[$key][
'enabled'] : 0;
2075 $menu->position = $this->menu[$key][
'position'];
2076 $menu->entity = $entity;
2079 $result = $menu->create($user);
2081 $this->menu[$key][
'rowid'] = $result;
2083 $this->error = $menu->error;
2084 dol_syslog(get_class($this).
'::insert_menus result='.$result.
" ".$this->error, LOG_ERR);
2092 $this->db->commit();
2094 dol_syslog(get_class($this).
"::insert_menus ".$this->error, LOG_ERR);
2095 $this->db->rollback();
2116 $module = empty($this->rights_class) ?strtolower($this->
name) : $this->rights_class;
2118 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"menu";
2119 $sql .=
" WHERE module = '".$this->db->escape($module).
"'";
2120 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
2122 dol_syslog(get_class($this).
"::delete_menus", LOG_DEBUG);
2123 $resql = $this->db->query($sql);
2125 $this->error = $this->db->lasterror();
2141 global $langs, $conf;
2145 if (isset($this->dirs) && is_array($this->dirs)) {
2146 foreach ($this->dirs as $key => $value) {
2149 if (!is_array($value)) {
2152 $constname = $this->const_name.
"_DIR_";
2153 $dir = $this->dirs[$key][1];
2154 $addtodatabase = empty($this->dirs[$key][2]) ?
'' : $this->dirs[$key][2];
2155 $subname = empty($this->dirs[$key][3]) ?
'' : strtoupper($this->dirs[$key][3]);
2156 $forcename = empty($this->dirs[$key][4]) ?
'' : strtoupper($this->dirs[$key][4]);
2158 if (!empty($forcename)) {
2159 $constname =
'MAIN_MODULE_'.$forcename.
"_DIR_";
2161 if (!empty($subname)) {
2162 $constname = $constname.$subname.
"_";
2165 $name = $constname.strtoupper($this->dirs[$key][0]);
2169 if (empty($conf->global->MAIN_MODULE_MULTICOMPANY) || $conf->entity == 1) {
2170 $fulldir = DOL_DATA_ROOT.$dir;
2172 $fulldir = DOL_DATA_ROOT.
"/".$conf->entity.$dir;
2175 if (!empty($fulldir) && !file_exists($fulldir)) {
2176 if (
dol_mkdir($fulldir, DOL_DATA_ROOT) < 0) {
2177 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $fulldir);
2178 dol_syslog(get_class($this).
"::_init ".$this->error, LOG_ERR);
2184 if (!empty($addtodatabase)) {
2213 $sql =
"SELECT count(*)";
2214 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
2215 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" = '".$this->db->escape($name).
"'";
2216 $sql .=
" AND entity = ".$conf->entity;
2218 dol_syslog(get_class($this).
"::insert_dirs", LOG_DEBUG);
2219 $result = $this->db->query($sql);
2221 $row = $this->db->fetch_row($result);
2224 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (name, type, value, note, visible, entity)";
2225 $sql .=
" VALUES (".$this->db->encrypt($name).
", 'chaine', ".$this->db->encrypt($dir).
", '".$this->db->escape(
"Directory for module ".$this->
name).
"', '0', ".((int) $conf->entity).
")";
2227 dol_syslog(get_class($this).
"::insert_dirs", LOG_DEBUG);
2228 $this->db->query($sql);
2231 $this->error = $this->db->lasterror();
2252 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
2253 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" LIKE '".$this->db->escape($this->const_name).
"_DIR_%'";
2254 $sql .=
" AND entity = ".$conf->entity;
2256 dol_syslog(get_class($this).
"::delete_dirs", LOG_DEBUG);
2257 if (!$this->db->query($sql)) {
2258 $this->error = $this->db->lasterror();
2278 if (is_array($this->module_parts) && !empty($this->module_parts)) {
2279 foreach ($this->module_parts as $key => $value) {
2280 if (is_array($value) && count($value) == 0) {
2284 $entity = $conf->entity;
2288 if (is_array($value)) {
2291 if (isset($value[
'data']) && is_array($value[
'data'])) {
2292 $newvalue = json_encode($value[
'data']);
2293 if (isset($value[
'entity'])) {
2294 $entity = $value[
'entity'];
2296 } elseif (isset($value[
'data']) && !is_array($value[
'data'])) {
2297 $newvalue = $value[
'data'];
2298 if (isset($value[
'entity'])) {
2299 $entity = $value[
'entity'];
2302 $newvalue = json_encode($value);
2306 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const (";
2311 $sql .=
", visible";
2314 $sql .=
" VALUES (";
2315 $sql .=
" ".$this->db->encrypt($this->const_name.
"_".strtoupper($key));
2316 $sql .=
", 'chaine'";
2317 $sql .=
", ".$this->db->encrypt($newvalue);
2320 $sql .=
", ".((int) $entity);
2323 dol_syslog(get_class($this).
"::insert_module_parts for key=".$this->const_name.
"_".strtoupper($key), LOG_DEBUG);
2325 $resql = $this->db->query($sql, 1);
2327 if ($this->db->lasterrno() !=
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2329 $this->error = $this->db->lasterror();
2331 dol_syslog(get_class($this).
"::insert_module_parts for ".$this->const_name.
"_".strtoupper($key).
" Record already exists.", LOG_WARNING);
2352 if (is_array($this->module_parts) && !empty($this->module_parts)) {
2353 dol_syslog(get_class($this).
"::delete_module_parts", LOG_DEBUG);
2355 foreach ($this->module_parts as $key => $value) {
2357 if (is_array($value) && isset($value[
'entity'])) {
2358 $entity = $value[
'entity'];
2360 $entity = $conf->entity;
2363 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
2364 $sql .=
" WHERE ".$this->db->decrypt(
'name').
" LIKE '".$this->db->escape($this->const_name).
"_".strtoupper($key).
"'";
2365 $sql .=
" AND entity = ".((int) $entity);
2367 if (!$this->db->query($sql)) {
2368 $this->error = $this->db->lasterror();
2385 public function init($options =
'')
2387 return $this->
_init(array(), $options);
2398 public function remove($options =
'')
2400 return $this->
_remove(array(), $options);
2413 global $conf, $langs;
2418 $imginfo =
"info_black";
2421 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($this)));
2425 if (preg_match(
'/development/i', $version)) {
2426 $versiontrans .=
'warning';
2428 if (preg_match(
'/experimental/i', $version)) {
2429 $versiontrans .=
'warning';
2431 if (preg_match(
'/deprecated/i', $version)) {
2432 $versiontrans .=
'warning';
2436 <div class="box-flex-item info-box-module'
2437 .(empty($conf->global->$const_name) ?
' --disabled' :
'')
2439 .($this->needUpdate ?
' --need-update' :
'')
2441 <div class="info-box info-box-sm info-box-module">
2442 <div class="info-box-icon'.(empty($conf->global->$const_name) ?
'' :
' info-box-icon-module-enabled'.($versiontrans ?
' info-box-icon-module-warning' :
'')).
'">';
2447 if (!empty($this->picto)) {
2448 if (preg_match(
'/^\//i', $this->picto)) {
2449 $return .=
img_picto($alttext, $this->picto,
'class="inline-block valignmiddle"', 1);
2451 $return .=
img_object($alttext, $this->picto,
'class="inline-block valignmiddle"');
2454 $return .=
img_object($alttext,
'generic',
'class="inline-block valignmiddle"');
2457 if ($this->
isCoreOrExternalModule() ==
'external' || preg_match(
'/development|experimental|deprecated/i', $version)) {
2458 $versionTitle = $langs->trans(
"Version").
' '.$this->
getVersion(1);
2459 if ($this->needUpdate) {
2460 $versionTitle.=
'<br>'.$langs->trans(
'ModuleUpdateAvailable').
' : '.
$this->lastVersion;
2463 $return .=
'<span class="info-box-icon-version'.($versiontrans ?
' '.$versiontrans :
'').
' classfortooltip" title="'.
dol_escape_js($versionTitle).
'" >';
2465 $return .=
'</span>';
2469 <div class="info-box-content info-box-text-module'.(empty($conf->global->$const_name) ?
'' :
' info-box-module-enabled'.($versiontrans ?
' info-box-content-warning' :
'')).
'">
2470 <span class="info-box-title">'.$this->
getName().
'</span>
2473 $return .=
'<div class="valignmiddle inline-block info-box-more">';
2475 $return .=
'<a class="valignmiddle inline-block" href="javascript:document_preview(\''.DOL_URL_ROOT.
'/admin/modulehelp.php?id='.$this->numero.
'\',\
'text/html\',\''.dol_escape_js($langs->trans(
"Module")).
'\')
">'.img_picto(($this->isCoreOrExternalModule() == 'external' ? $langs->trans("ExternalModule
").' - ' : '').$langs->trans("ClickToShowDescription
"), $imginfo).'</a>';
2476 $return .= '</div><br>';
2478 $return .= '<div class="valignmiddle
inline-block info-box-actions
">';
2479 $return .= '<div class="valignmiddle
inline-block info-box-setup
">';
2480 $return .= $codetoconfig;
2481 $return .= '</div>';
2482 $return .= '<div class="valignmiddle
inline-block marginleftonly marginrightonly
">';
2483 $return .= $codeenabledisable;
2484 $return .= '</div>';
2485 $return .= '</div>';
2488 </div><!-- /.info-box-content -->
2489 </div><!-- /.info-box -->
2502 public function checkForUpdate()
2504 require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
2505 if (!empty($this->url_last_version)) {
2506 $lastVersion = getURLContent($this->url_last_version, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only
2507 if (isset($lastVersion['content']) && strlen($lastVersion['content']) < 30) {
2508 // 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 _ . -
2509 $this->lastVersion = preg_replace("/[^a-zA-Z0-9_\.\-]+/
", "", $lastVersion['content']);
2510 if (version_compare($this->lastVersion, $this->version) > 0) {
2511 $this->needUpdate = true;
2514 $this->needUpdate = false;
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.
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.