dolibarr  20.0.0-beta
modules.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
4  * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
6  * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
7  * Copyright (C) 2011-2023 Juanjo Menent <jmenent@2byte.es>
8  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
9  * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
10  * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
11  * Copyright (C) 2021-2023 Frédéric France <frederic.france@netlogic.fr>
12  * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program. If not, see <https://www.gnu.org/licenses/>.
26  */
27 
33 if (!defined('CSRFCHECK_WITH_TOKEN') && (empty($_GET['action']) || $_GET['action'] != 'reset')) { // We force security except to disable modules so we can do it if a problem occurs on a module
34  define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
35 }
36 
37 // Load Dolibarr environment
38 require '../main.inc.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
43 require_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/dolistore.class.php';
44 
45 // Load translation files required by the page
46 $langs->loadLangs(array("errors", "admin", "modulebuilder"));
47 
48 // if we set another view list mode, we keep it (till we change one more time)
49 if (GETPOSTISSET('mode')) {
50  $mode = GETPOST('mode', 'alpha');
51  if ($mode == 'common' || $mode == 'commonkanban') {
52  dolibarr_set_const($db, "MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT", $mode, 'chaine', 0, '', $conf->entity);
53  }
54 } else {
55  $mode = (!getDolGlobalString('MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT') ? 'commonkanban' : $conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT);
56 }
57 
58 $action = GETPOST('action', 'aZ09');
59 $value = GETPOST('value', 'alpha');
60 $page_y = GETPOSTINT('page_y');
61 $search_keyword = GETPOST('search_keyword', 'alpha');
62 $search_status = GETPOST('search_status', 'alpha');
63 $search_nature = GETPOST('search_nature', 'alpha');
64 $search_version = GETPOST('search_version', 'alpha');
65 
66 
67 // For dolistore search
68 $options = array();
69 $options['per_page'] = 20;
70 $options['categorie'] = ((int) (GETPOSTINT('categorie') ? GETPOSTINT('categorie') : 0));
71 $options['start'] = ((int) (GETPOSTINT('start') ? GETPOSTINT('start') : 0));
72 $options['end'] = ((int) (GETPOSTINT('end') ? GETPOSTINT('end') : 0));
73 $options['search'] = GETPOST('search_keyword', 'alpha');
74 $dolistore = new Dolistore(false);
75 
76 
77 if (!$user->admin) {
79 }
80 
81 $familyinfo = array(
82  'hr' => array('position' => '001', 'label' => $langs->trans("ModuleFamilyHr")),
83  'crm' => array('position' => '006', 'label' => $langs->trans("ModuleFamilyCrm")),
84  'srm' => array('position' => '007', 'label' => $langs->trans("ModuleFamilySrm")),
85  'financial' => array('position' => '009', 'label' => $langs->trans("ModuleFamilyFinancial")),
86  'products' => array('position' => '012', 'label' => $langs->trans("ModuleFamilyProducts")),
87  'projects' => array('position' => '015', 'label' => $langs->trans("ModuleFamilyProjects")),
88  'ecm' => array('position' => '018', 'label' => $langs->trans("ModuleFamilyECM")),
89  'technic' => array('position' => '021', 'label' => $langs->trans("ModuleFamilyTechnic")),
90  'portal' => array('position' => '040', 'label' => $langs->trans("ModuleFamilyPortal")),
91  'interface' => array('position' => '050', 'label' => $langs->trans("ModuleFamilyInterface")),
92  'base' => array('position' => '060', 'label' => $langs->trans("ModuleFamilyBase")),
93  'other' => array('position' => '100', 'label' => $langs->trans("ModuleFamilyOther")),
94 );
95 
96 $param = '';
97 if (!GETPOST('buttonreset', 'alpha')) {
98  if ($search_keyword) {
99  $param .= '&search_keyword='.urlencode($search_keyword);
100  }
101  if ($search_status && $search_status != '-1') {
102  $param .= '&search_status='.urlencode($search_status);
103  }
104  if ($search_nature && $search_nature != '-1') {
105  $param .= '&search_nature='.urlencode($search_nature);
106  }
107  if ($search_version && $search_version != '-1') {
108  $param .= '&search_version='.urlencode($search_version);
109  }
110 }
111 
112 $dirins = DOL_DOCUMENT_ROOT.'/custom';
113 $urldolibarrmodules = 'https://www.dolistore.com/';
114 
115 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
116 $hookmanager->initHooks(array('adminmodules', 'globaladmin'));
117 
118 // Execution Time
119 $max_execution_time_for_deploy = (!getDolGlobalString('MODULE_UPLOAD_MAX_EXECUTION_TIME') ? 300 : $conf->global->MODULE_UPLOAD_MAX_EXECUTION_TIME); // 5mn if not defined
120 $max_time = @ini_get("max_execution_time");
121 if ($max_time && $max_time < $max_execution_time_for_deploy) {
122  dol_syslog("max_execution_time=".$max_time." is lower than max_execution_time_for_deploy=".$max_execution_time_for_deploy.". We try to increase it dynamically.");
123  @ini_set("max_execution_time", $max_execution_time_for_deploy); // This work only if safe mode is off. also web servers has timeout of 300
124 }
125 
126 $dolibarrdataroot = preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT);
127 $allowonlineinstall = true;
128 $allowfromweb = 1;
129 if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) {
130  $allowonlineinstall = false;
131 }
132 
133 
134 /*
135  * Actions
136  */
137 
138 $formconfirm = '';
139 
140 $parameters = array();
141 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
142 if ($reshook < 0) {
143  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
144 }
145 
146 if (GETPOST('buttonreset', 'alpha')) {
147  $search_keyword = '';
148  $search_status = '';
149  $search_nature = '';
150  $search_version = '';
151 }
152 
153 if ($action == 'install' && $allowonlineinstall) {
154  $error = 0;
155 
156  // $original_file should match format module_modulename-x.y[.z].zip
157  $original_file = basename($_FILES["fileinstall"]["name"]);
158  $original_file = preg_replace('/\s*\‍(\d+\‍)\.zip$/i', '.zip', $original_file);
159  $newfile = $conf->admin->dir_temp.'/'.$original_file.'/'.$original_file;
160 
161  if (!$original_file) {
162  $langs->load("Error");
163  setEventMessages($langs->trans("ErrorModuleFileRequired"), null, 'warnings');
164  $error++;
165  } else {
166  if (!$error && !preg_match('/\.zip$/i', $original_file)) {
167  $langs->load("errors");
168  setEventMessages($langs->trans("ErrorFileMustBeADolibarrPackage", $original_file), null, 'errors');
169  $error++;
170  }
171  if (!$error && !preg_match('/^(module[a-zA-Z0-9]*|theme)_.*\-([0-9][0-9\.]*)\.zip$/i', $original_file)) {
172  $langs->load("errors");
173  setEventMessages($langs->trans("ErrorFilenameDosNotMatchDolibarrPackageRules", $original_file, 'module_*-x.y*.zip'), null, 'errors');
174  $error++;
175  }
176  if (empty($_FILES['fileinstall']['tmp_name'])) {
177  $langs->load("errors");
178  setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors');
179  $error++;
180  }
181  }
182 
183  if (!$error) {
184  if ($original_file) {
185  @dol_delete_dir_recursive($conf->admin->dir_temp.'/'.$original_file);
186  dol_mkdir($conf->admin->dir_temp.'/'.$original_file);
187  }
188 
189  $tmpdir = preg_replace('/\.zip$/i', '', $original_file).'.dir';
190  if ($tmpdir) {
191  @dol_delete_dir_recursive($conf->admin->dir_temp.'/'.$tmpdir);
192  dol_mkdir($conf->admin->dir_temp.'/'.$tmpdir);
193  }
194 
195  $result = dol_move_uploaded_file($_FILES['fileinstall']['tmp_name'], $newfile, 1, 0, $_FILES['fileinstall']['error']);
196  if ($result > 0) {
197  $result = dol_uncompress($newfile, $conf->admin->dir_temp.'/'.$tmpdir);
198 
199  if (!empty($result['error'])) {
200  $langs->load("errors");
201  setEventMessages($langs->trans($result['error'], $original_file), null, 'errors');
202  $error++;
203  } else {
204  // Now we move the dir of the module
205  $modulename = preg_replace('/module_/', '', $original_file);
206  $modulename = preg_replace('/\-([0-9][0-9\.]*)\.zip$/i', '', $modulename);
207  // Search dir $modulename
208  $modulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulename; // Example ./mymodule
209 
210  if (!dol_is_dir($modulenamedir)) {
211  $modulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulename; // Example ./htdocs/mymodule
212  //var_dump($modulenamedir);
213  if (!dol_is_dir($modulenamedir)) {
214  setEventMessages($langs->trans("ErrorModuleFileSeemsToHaveAWrongFormat").'<br>'.$langs->trans("ErrorModuleFileSeemsToHaveAWrongFormat2", $modulename, 'htdocs/'.$modulename), null, 'errors');
215  $error++;
216  }
217  }
218 
219  if (!$error) {
220  // TODO Make more test
221  }
222 
223  dol_syslog("Uncompress of module file is a success.");
224 
225  // We check if this is a metapackage
226  $modulenamearrays = array();
227  if (dol_is_file($modulenamedir.'/metapackage.conf')) {
228  // This is a meta package
229  $metafile = file_get_contents($modulenamedir.'/metapackage.conf');
230  $modulenamearrays = explode("\n", $metafile);
231  }
232  $modulenamearrays[$modulename] = $modulename;
233  //var_dump($modulenamearrays);exit;
234 
235  // Lop on each package of the metapackage
236  foreach ($modulenamearrays as $modulenameval) {
237  if (strpos($modulenameval, '#') === 0) {
238  continue; // Discard comments
239  }
240  if (strpos($modulenameval, '//') === 0) {
241  continue; // Discard comments
242  }
243  if (!trim($modulenameval)) {
244  continue;
245  }
246 
247  // Now we install the module
248  if (!$error) {
249  @dol_delete_dir_recursive($dirins.'/'.$modulenameval); // delete the target directory
250  $submodulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulenameval;
251  if (!dol_is_dir($submodulenamedir)) {
252  $submodulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulenameval;
253  }
254  dol_syslog("We copy now directory ".$submodulenamedir." into target dir ".$dirins.'/'.$modulenameval);
255  $result = dolCopyDir($submodulenamedir, $dirins.'/'.$modulenameval, '0444', 1);
256  if ($result <= 0) {
257  dol_syslog('Failed to call dolCopyDir result='.$result." with param ".$submodulenamedir." and ".$dirins.'/'.$modulenameval, LOG_WARNING);
258  $langs->load("errors");
259  setEventMessages($langs->trans("ErrorFailToCopyDir", $submodulenamedir, $dirins.'/'.$modulenameval), null, 'errors');
260  $error++;
261  }
262  }
263  }
264  }
265  } else {
266  setEventMessages($langs->trans("ErrorFailToRenameFile", $_FILES['fileinstall']['tmp_name'], $newfile), null, 'errors');
267  $error++;
268  }
269  }
270 
271  if (!$error) {
272  $message = $langs->trans("SetupIsReadyForUse", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentitiesnoconv("Home").' - '.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Modules"));
273  setEventMessages($message, null, 'warnings');
274  }
275 } elseif ($action == 'install' && !$allowonlineinstall) {
276  httponly_accessforbidden("You try to bypass the protection to disallow deployment of an external module. Hack attempt ?");
277 }
278 
279 if ($action == 'set' && $user->admin) {
280  $checkOldValue = getDolGlobalInt('CHECKLASTVERSION_EXTERNALMODULE');
281  $csrfCheckOldValue = getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN');
282  $resarray = activateModule($value);
283  if ($checkOldValue != getDolGlobalInt('CHECKLASTVERSION_EXTERNALMODULE')) {
284  setEventMessage($langs->trans('WarningModuleHasChangedLastVersionCheckParameter', $value), 'warnings');
285  }
286  if ($csrfCheckOldValue != getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN')) {
287  setEventMessage($langs->trans('WarningModuleHasChangedSecurityCsrfParameter', $value), 'warnings');
288  }
289  dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity);
290  if (!empty($resarray['errors'])) {
291  setEventMessages('', $resarray['errors'], 'errors');
292  } else {
293  //var_dump($resarray);exit;
294  if ($resarray['nbperms'] > 0) {
295  $tmpsql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."user WHERE admin <> 1";
296  $resqltmp = $db->query($tmpsql);
297  if ($resqltmp) {
298  $obj = $db->fetch_object($resqltmp);
299  //var_dump($obj->nb);exit;
300  if ($obj && $obj->nb > 1) {
301  $msg = $langs->trans('ModuleEnabledAdminMustCheckRights');
302  setEventMessages($msg, null, 'warnings');
303  }
304  } else {
305  dol_print_error($db);
306  }
307  }
308  }
309  header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : ''));
310  exit;
311 } elseif ($action == 'reset' && $user->admin && GETPOST('confirm') == 'yes') {
312  $result = unActivateModule($value);
313  dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity);
314  if ($result) {
315  setEventMessages($result, null, 'errors');
316  }
317  header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : ''));
318  exit;
319 } elseif (getDolGlobalInt("MAIN_FEATURES_LEVEL") > 1 && $action == 'reload' && $user->admin && GETPOST('confirm') == 'yes') {
320  $result = unActivateModule($value, 0);
321  dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity);
322  if ($result) {
323  setEventMessages($result, null, 'errors');
324  header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : ''));
325  }
326  $resarray = activateModule($value, 0, 1);
327  dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity);
328  if (!empty($resarray['errors'])) {
329  setEventMessages('', $resarray['errors'], 'errors');
330  } else {
331  if ($resarray['nbperms'] > 0) {
332  $tmpsql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."user WHERE admin <> 1";
333  $resqltmp = $db->query($tmpsql);
334  if ($resqltmp) {
335  $obj = $db->fetch_object($resqltmp);
336  if ($obj && $obj->nb > 1) {
337  $msg = $langs->trans('ModuleEnabledAdminMustCheckRights');
338  setEventMessages($msg, null, 'warnings');
339  }
340  } else {
341  dol_print_error($db);
342  }
343  }
344  }
345  header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : ''));
346  exit;
347 }
348 
349 
350 
351 
352 /*
353  * View
354  */
355 
356 $form = new Form($db);
357 
358 $morejs = array();
359 $morecss = array("/admin/dolistore/css/dolistore.css");
360 
361 // Set dir where external modules are installed
362 if (!dol_is_dir($dirins)) {
363  dol_mkdir($dirins);
364 }
365 $dirins_ok = (dol_is_dir($dirins));
366 
367 $help_url = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
368 llxHeader('', $langs->trans("Setup"), $help_url, '', '', '', $morejs, $morecss, 0, 0);
369 
370 
371 // Search modules dirs
372 $modulesdir = dolGetModulesDirs();
373 
374 $arrayofnatures = array(
375  'core' => array('label' => $langs->transnoentitiesnoconv("NativeModules")),
376  'external' => array('label' => $langs->transnoentitiesnoconv("External").' - ['.$langs->trans("AllPublishers").']')
377 );
378 $arrayofwarnings = array(); // Array of warning each module want to show when activated
379 $arrayofwarningsext = array(); // Array of warning each module want to show when we activate an external module
380 $filename = array();
381 $modules = array();
382 $orders = array();
383 $categ = array();
384 $publisherlogoarray = array();
385 
386 $i = 0; // is a sequencer of modules found
387 $j = 0; // j is module number. Automatically affected if module number not defined.
388 $modNameLoaded = array();
389 
390 foreach ($modulesdir as $dir) {
391  // Load modules attributes in arrays (name, numero, orders) from dir directory
392  //print $dir."\n<br>";
393  dol_syslog("Scan directory ".$dir." for module descriptor files (modXXX.class.php)");
394  $handle = @opendir($dir);
395  if (is_resource($handle)) {
396  while (($file = readdir($handle)) !== false) {
397  //print "$i ".$file."\n<br>";
398  if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') {
399  $modName = substr($file, 0, dol_strlen($file) - 10);
400 
401  if ($modName) {
402  if (!empty($modNameLoaded[$modName])) { // In cache of already loaded modules ?
403  $mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.<br>";
404  setEventMessages($mesg, null, 'warnings');
405  dol_syslog($mesg, LOG_ERR);
406  continue;
407  }
408 
409  try {
410  $res = include_once $dir.$file; // A class already exists in a different file will send a non catchable fatal error.
411  if (class_exists($modName)) {
412  $objMod = new $modName($db);
413  '@phan-var-force DolibarrModules $objMod';
414  $modNameLoaded[$modName] = $dir;
415  if (!$objMod->numero > 0 && $modName != 'modUser') {
416  dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR);
417  }
418  $j = $objMod->numero;
419 
420  $modulequalified = 1;
421 
422  // We discard modules according to features level (PS: if module is activated we always show it)
423  $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod)));
424  if ($objMod->version == 'development' && (!getDolGlobalString($const_name) && (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2))) {
425  $modulequalified = 0;
426  }
427  if ($objMod->version == 'experimental' && (!getDolGlobalString($const_name) && (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1))) {
428  $modulequalified = 0;
429  }
430  if (preg_match('/deprecated/', $objMod->version) && (!getDolGlobalString($const_name) && (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 0))) {
431  $modulequalified = 0;
432  }
433 
434  // We discard modules according to property ->hidden
435  if (!empty($objMod->hidden)) {
436  $modulequalified = 0;
437  }
438 
439  if ($modulequalified > 0) {
440  $publisher = dol_escape_htmltag($objMod->getPublisher());
441  $external = ($objMod->isCoreOrExternalModule() == 'external');
442  if ($external) {
443  if ($publisher) {
444  // Check if there is a logo forpublisher
445  /* Do not show the company logo in combo. Make combo list dirty.
446  if (!empty($objMod->editor_squarred_logo)) {
447  $publisherlogoarray['external_'.$publisher] = img_picto('', $objMod->editor_squarred_logo, 'class="publisherlogoinline"');
448  }
449  $publisherlogo = empty($publisherlogoarray['external_'.$publisher]) ? '' : $publisherlogoarray['external_'.$publisher];
450  */
451  $arrayofnatures['external_'.$publisher] = array('label' => $langs->trans("External").' - '.$publisher, 'data-html' => $langs->trans("External").' - <span class="opacitymedium inine-block valignmiddle">'.$publisher.'</span>');
452  } else {
453  $arrayofnatures['external_'] = array('label' => $langs->trans("External").' - ['.$langs->trans("UnknownPublishers").']');
454  }
455  }
456  ksort($arrayofnatures);
457 
458  // Define array $categ with categ with at least one qualified module
459  $filename[$i] = $modName;
460  $modules[$modName] = $objMod;
461 
462  // Gives the possibility to the module, to provide his own family info and position of this family
463  if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) {
464  $familyinfo = array_merge($familyinfo, $objMod->familyinfo);
465  $familykey = key($objMod->familyinfo);
466  } else {
467  $familykey = $objMod->family;
468  }
469  '@phan-var-force string $familykey'; // if not, phan considers $familykey may be null
470 
471  $moduleposition = ($objMod->module_position ? $objMod->module_position : '50');
472  if ($objMod->isCoreOrExternalModule() == 'external' && $moduleposition < 100000) {
473  // an external module should never return a value lower than '80'.
474  $moduleposition = '80'; // External modules at end by default
475  }
476 
477  // Add list of warnings to show into arrayofwarnings and arrayofwarningsext
478  if (!empty($objMod->warnings_activation)) {
479  $arrayofwarnings[$modName] = $objMod->warnings_activation;
480  }
481  if (!empty($objMod->warnings_activation_ext)) {
482  $arrayofwarningsext[$modName] = $objMod->warnings_activation_ext;
483  }
484 
485  $familyposition = (empty($familyinfo[$familykey]['position']) ? '0' : $familyinfo[$familykey]['position']);
486  $listOfOfficialModuleGroups = array('hr', 'technic', 'interface', 'technic', 'portal', 'financial', 'crm', 'base', 'products', 'srm', 'ecm', 'projects', 'other');
487  if ($external && !in_array($familykey, $listOfOfficialModuleGroups)) {
488  // If module is extern and into a custom group (not into an official predefined one), it must appear at end (custom groups should not be before official groups).
489  if (is_numeric($familyposition)) {
490  $familyposition = sprintf("%03d", (int) $familyposition + 100);
491  }
492  }
493 
494  $orders[$i] = $familyposition."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number
495 
496  // Set categ[$i]
497  $specialstring = 'unknown';
498  if ($objMod->version == 'development' || $objMod->version == 'experimental') {
499  $specialstring = 'expdev';
500  }
501  if (isset($categ[$specialstring])) {
502  $categ[$specialstring]++; // Array of all different modules categories
503  } else {
504  $categ[$specialstring] = 1;
505  }
506  $j++;
507  $i++;
508  } else {
509  dol_syslog("Module ".get_class($objMod)." not qualified");
510  }
511  } else {
512  print info_admin("admin/modules.php Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)", 0, 0, '1', 'warning');
513  }
514  } catch (Exception $e) {
515  dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
516  }
517  }
518  }
519  }
520  closedir($handle);
521  } else {
522  dol_syslog("htdocs/admin/modules.php: Failed to open directory ".$dir.". See permission and open_basedir option.", LOG_WARNING);
523  }
524 }
525 
526 if ($action == 'reset_confirm' && $user->admin) {
527  if (!empty($modules[$value])) {
528  $objMod = $modules[$value];
529 
530  if (!empty($objMod->langfiles)) {
531  $langs->loadLangs($objMod->langfiles);
532  }
533 
534  $form = new Form($db);
535  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?value='.$value.'&mode='.$mode.$param, $langs->trans('ConfirmUnactivation'), $langs->trans(GETPOST('confirm_message_code')), 'reset', '', 'no', 1);
536  }
537 }
538 
539 if ($action == 'reload_confirm' && $user->admin) {
540  if (!empty($modules[$value])) {
541  $objMod = $modules[$value];
542 
543  if (!empty($objMod->langfiles)) {
544  $langs->loadLangs($objMod->langfiles);
545  }
546 
547  $form = new Form($db);
548  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?value='.$value.'&mode='.$mode.$param, $langs->trans('ConfirmReload'), $langs->trans(GETPOST('confirm_message_code')), 'reload', '', 'no', 1);
549  }
550 }
551 
552 print $formconfirm;
553 
554 asort($orders);
555 //var_dump($orders);
556 //var_dump($categ);
557 //var_dump($modules);
558 
559 $nbofactivatedmodules = count($conf->modules);
560 
561 $nbmodulesnotautoenabled = count($conf->modules);
562 if (in_array('fckeditor', $conf->modules)) {
563  $nbmodulesnotautoenabled--;
564 }
565 if (in_array('export', $conf->modules)) {
566  $nbmodulesnotautoenabled--;
567 }
568 if (in_array('import', $conf->modules)) {
569  $nbmodulesnotautoenabled--;
570 }
571 
572 print load_fiche_titre($langs->trans("ModulesSetup"), '', 'title_setup');
573 
574 // Start to show page
575 $deschelp = '';
576 if ($mode == 'common' || $mode == 'commonkanban') {
577  $desc = $langs->trans("ModulesDesc", '{picto}');
578  $desc .= ' '.$langs->trans("ModulesDesc2", '{picto2}');
579  $desc = str_replace('{picto}', img_picto('', 'switch_off', 'class="size15x"'), $desc);
580  $desc = str_replace('{picto2}', img_picto('', 'setup', 'class="size15x"'), $desc);
581  if ($nbmodulesnotautoenabled <= getDolGlobalInt('MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) { // If only minimal initial modules enabled
582  $deschelp .= '<div class="info hideonsmartphone">'.$desc."<br></div>\n";
583  }
584  if (getDolGlobalString('MAIN_SETUP_MODULES_INFO')) { // Show a custom message
585  $deschelp .= '<div class="info">'.$langs->trans(getDolGlobalString('MAIN_SETUP_MODULES_INFO'))."<br></div>\n";
586  }
587  if ($deschelp) {
588  $deschelp .= '<br>';
589  }
590 }
591 if ($mode == 'marketplace') {
592  //$deschelp = '<div class="info hideonsmartphone">'.$langs->trans("ModulesMarketPlaceDesc")."<br></div><br>\n";
593 }
594 if ($mode == 'deploy') {
595  $deschelp = '<div class="info hideonsmartphone">'.$langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."<br></div><br>\n";
596 }
597 if ($mode == 'develop') {
598  $deschelp = '<div class="info hideonsmartphone">'.$langs->trans("ModulesDevelopDesc")."<br></div><br>\n";
599 }
600 
601 $head = modules_prepare_head($nbofactivatedmodules, count($modules), $nbmodulesnotautoenabled);
602 
603 
604 if ($mode == 'common' || $mode == 'commonkanban') {
605  dol_set_focus('#search_keyword');
606 
607  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
608  print '<input type="hidden" name="token" value="'.newToken().'">';
609  if (isset($optioncss) && $optioncss != '') {
610  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
611  }
612  if (isset($sortfield) && $sortfield != '') {
613  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
614  }
615  if (isset($sortorder) && $sortorder != '') {
616  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
617  }
618  if (isset($page) && $page != '') {
619  print '<input type="hidden" name="page" value="'.$page.'">';
620  }
621  print '<input type="hidden" name="mode" value="'.$mode.'">';
622 
623  print dol_get_fiche_head($head, 'modules', '', -1);
624 
625  print $deschelp;
626 
627  $moreforfilter = '<div class="valignmiddle">';
628 
629  $moreforfilter .= '<div class="floatright right pagination paddingtop --module-list"><ul><li>';
630  $moreforfilter .= dolGetButtonTitle($langs->trans('CheckForModuleUpdate'), $langs->trans('CheckForModuleUpdate').'<br>'.$langs->trans('CheckForModuleUpdateHelp'), 'fa fa-sync', $_SERVER["PHP_SELF"].'?action=checklastversion&token='.newToken().'&mode='.$mode.$param, '', 1, array('morecss' => 'reposition'));
631  $moreforfilter .= dolGetButtonTitleSeparator();
632  $moreforfilter .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.$param, '', ($mode == 'common' ? 2 : 1), array('morecss' => 'reposition'));
633  $moreforfilter .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=commonkanban'.$param, '', ($mode == 'commonkanban' ? 2 : 1), array('morecss' => 'reposition'));
634  $moreforfilter .= '</li></ul></div>';
635 
636  $moreforfilter .= '<div class="divfilteralone colorbacktimesheet float valignmiddle">';
637  $moreforfilter .= '<div class="divsearchfield paddingtop paddingbottom valignmiddle inline-block">';
638  $moreforfilter .= img_picto($langs->trans("Filter"), 'filter', 'class="paddingright opacityhigh hideonsmartphone"').'<input type="text" id="search_keyword" name="search_keyword" class="maxwidth125" value="'.dol_escape_htmltag($search_keyword).'" placeholder="'.dol_escape_htmltag($langs->trans('Keyword')).'">';
639  $moreforfilter .= '</div>';
640  $moreforfilter .= '<div class="divsearchfield paddingtop paddingbottom valignmiddle inline-block">';
641  $moreforfilter .= $form->selectarray('search_nature', $arrayofnatures, dol_escape_htmltag($search_nature), $langs->trans('Origin'), 0, 0, '', 0, 0, 0, '', 'maxwidth250', 1);
642  $moreforfilter .= '</div>';
643 
644  if (getDolGlobalInt('MAIN_FEATURES_LEVEL')) {
645  $array_version = array('stable' => $langs->transnoentitiesnoconv("Stable"));
646  if (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 0) {
647  $array_version['deprecated'] = $langs->trans("Deprecated");
648  }
649  if (getDolGlobalInt('MAIN_FEATURES_LEVEL') > 0) {
650  $array_version['experimental'] = $langs->trans("Experimental");
651  }
652  if (getDolGlobalInt('MAIN_FEATURES_LEVEL') > 1) {
653  $array_version['development'] = $langs->trans("Development");
654  }
655  $moreforfilter .= '<div class="divsearchfield paddingtop paddingbottom valignmiddle inline-block">';
656  $moreforfilter .= $form->selectarray('search_version', $array_version, $search_version, $langs->transnoentitiesnoconv('Version'), 0, 0, '', 0, 0, 0, '', 'maxwidth150', 1);
657  $moreforfilter .= '</div>';
658  }
659  $array_status = array('active' => $langs->transnoentitiesnoconv("Enabled"), 'disabled' => $langs->transnoentitiesnoconv("Disabled"));
660  $moreforfilter .= '<div class="divsearchfield paddingtop paddingbottom valignmiddle inline-block">';
661  $moreforfilter .= $form->selectarray('search_status', $array_status, $search_status, $langs->transnoentitiesnoconv('Status'), 0, 0, '', 0, 0, 0, '', 'maxwidth150', 1);
662  $moreforfilter .= '</div>';
663  $moreforfilter .= ' ';
664  $moreforfilter .= '<div class="divsearchfield valignmiddle inline-block">';
665  $moreforfilter .= '<input type="submit" name="buttonsubmit" class="button small nomarginleft" value="'.dol_escape_htmltag($langs->trans("Refresh")).'">';
666  if ($search_keyword || ($search_nature && $search_nature != '-1') || ($search_version && $search_version != '-1') || ($search_status && $search_status != '-1')) {
667  $moreforfilter .= ' ';
668  $moreforfilter .= '<input type="submit" name="buttonreset" class="buttonreset noborderbottom" value="'.dol_escape_htmltag($langs->trans("Reset")).'">';
669  }
670  $moreforfilter .= '</div>';
671  $moreforfilter .= '</div>';
672 
673  $moreforfilter .= '</div>';
674 
675  if (!empty($moreforfilter)) {
676  print $moreforfilter;
677  $parameters = array();
678  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
679  print $hookmanager->resPrint;
680  }
681 
682  $moreforfilter = '';
683 
684  print '<div class="clearboth"></div><br>';
685 
686  $object = new stdClass();
687  $parameters = array();
688  $reshook = $hookmanager->executeHooks('insertExtraHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
689  if ($reshook < 0) {
690  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
691  }
692 
693  $disabled_modules = array();
694  if (!empty($_SESSION["disablemodules"])) {
695  $disabled_modules = explode(',', $_SESSION["disablemodules"]);
696  }
697 
698  // Show list of modules
699  $oldfamily = '';
700  $foundoneexternalmodulewithupdate = 0;
701  $linenum = 0;
702  $atleastonequalified = 0;
703  $atleastoneforfamily = 0;
704 
705  foreach ($orders as $key => $value) {
706  $linenum++;
707  $tab = explode('_', $value);
708  $familykey = $tab[1];
709  $module_position = $tab[2];
710 
711  $modName = $filename[$key];
712 
714  $objMod = $modules[$modName];
715 
716  //print $objMod->name." - ".$key." - ".$objMod->version."<br>";
717  if ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental') {
718  continue; // Discard if not for current tab
719  }
720 
721  if (!$objMod->getName()) {
722  dol_syslog("Error for module ".$key." - Property name of module looks empty", LOG_WARNING);
723  continue;
724  }
725 
726  $modulenameshort = strtolower(preg_replace('/^mod/i', '', get_class($objMod)));
727  $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod)));
728 
729  // Check filters
730  $modulename = $objMod->getName();
731  $moduletechnicalname = $objMod->name;
732  $moduledesc = $objMod->getDesc();
733  $moduledesclong = $objMod->getDescLong();
734  $moduleauthor = $objMod->getPublisher();
735 
736  // We discard showing according to filters
737  if ($search_keyword) {
738  $qualified = 0;
739  if (preg_match('/'.preg_quote($search_keyword, '/').'/i', $modulename)
740  || preg_match('/'.preg_quote($search_keyword, '/').'/i', $moduletechnicalname)
741  || ($moduledesc && preg_match('/'.preg_quote($search_keyword, '/').'/i', $moduledesc))
742  || ($moduledesclong && preg_match('/'.preg_quote($search_keyword, '/').'/i', $moduledesclong))
743  || ($moduleauthor && preg_match('/'.preg_quote($search_keyword, '/').'/i', $moduleauthor))
744  ) {
745  $qualified = 1;
746  }
747  if (!$qualified) {
748  continue;
749  }
750  }
751  if ($search_status) {
752  if ($search_status == 'active' && !getDolGlobalString($const_name)) {
753  continue;
754  }
755  if ($search_status == 'disabled' && getDolGlobalString($const_name)) {
756  continue;
757  }
758  }
759  if ($search_nature) {
760  if (preg_match('/^external/', $search_nature) && $objMod->isCoreOrExternalModule() != 'external') {
761  continue;
762  }
763  $reg = array();
764  if (preg_match('/^external_(.*)$/', $search_nature, $reg)) {
765  //print $reg[1].'-'.dol_escape_htmltag($objMod->getPublisher());
766  $publisher = dol_escape_htmltag($objMod->getPublisher());
767  if ($reg[1] && dol_escape_htmltag($reg[1]) != $publisher) {
768  continue;
769  }
770  if (!$reg[1] && !empty($publisher)) {
771  continue;
772  }
773  }
774  if ($search_nature == 'core' && $objMod->isCoreOrExternalModule() == 'external') {
775  continue;
776  }
777  }
778  if ($search_version) {
779  if (($objMod->version == 'development' || $objMod->version == 'experimental' || preg_match('/deprecated/', $objMod->version)) && $search_version == 'stable') {
780  continue;
781  }
782  if ($objMod->version != 'development' && ($search_version == 'development')) {
783  continue;
784  }
785  if ($objMod->version != 'experimental' && ($search_version == 'experimental')) {
786  continue;
787  }
788  if (!preg_match('/deprecated/', $objMod->version) && ($search_version == 'deprecated')) {
789  continue;
790  }
791  }
792 
793  $atleastonequalified++;
794 
795  // Load all language files of the qualified module
796  if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
797  foreach ($objMod->langfiles as $domain) {
798  $langs->load($domain);
799  }
800  }
801 
802  // Print a separator if we change family
803  if ($familykey != $oldfamily) {
804  if ($oldfamily) {
805  print '</table></div><br>';
806  }
807 
808  $familytext = empty($familyinfo[$familykey]['label']) ? $familykey : $familyinfo[$familykey]['label'];
809 
810  print load_fiche_titre($familytext, '', '', 0, '', 'modulefamilygroup');
811 
812  if ($mode == 'commonkanban') {
813  print '<div class="box-flex-container kanban">';
814  } else {
815  print '<div class="div-table-responsive">';
816  print '<table class="tagtable liste" summary="list_of_modules">'."\n";
817  }
818 
819  $atleastoneforfamily = 0;
820  }
821 
822  $atleastoneforfamily++;
823 
824  if ($familykey != $oldfamily) {
825  $familytext = empty($familyinfo[$familykey]['label']) ? $familykey : $familyinfo[$familykey]['label'];
826  $oldfamily = $familykey;
827  }
828 
829  // Version (with picto warning or not)
830  $version = $objMod->getVersion(0);
831  $versiontrans = '';
832  $warningstring = '';
833  if (preg_match('/development/i', $version)) {
834  $warningstring = $langs->trans("Development");
835  }
836  if (preg_match('/experimental/i', $version)) {
837  $warningstring = $langs->trans("Experimental");
838  }
839  if (preg_match('/deprecated/i', $version)) {
840  $warningstring = $langs->trans("Deprecated");
841  }
842 
843  if ($objMod->isCoreOrExternalModule() == 'external' || preg_match('/development|experimental|deprecated/i', $version)) {
844  $versiontrans .= $objMod->getVersion(1);
845  }
846 
847  if ($objMod->isCoreOrExternalModule() == 'external'
848  && (
849  $action == 'checklastversion'
850  // This is a bad practice to activate a check on an external access during the building of the admin page. 1 external module can hang the application.
851  // Adding a cron job could be a good idea: see DolibarrModules::checkForUpdate()
852  || getDolGlobalString('CHECKLASTVERSION_EXTERNALMODULE')
853  )
854  ) {
855  $checkRes = $objMod->checkForUpdate();
856  if ($checkRes > 0) {
857  setEventMessage($objMod->getName().' : '.$versiontrans.' -> '.$objMod->lastVersion);
858  } elseif ($checkRes < 0) {
859  setEventMessage($objMod->getName().' '.$langs->trans('CheckVersionFail'), 'warnings');
860  }
861  }
862 
863  // Define imginfo
864  $imginfo = "info";
865  if ($objMod->isCoreOrExternalModule() == 'external') {
866  $imginfo = "info_black";
867  }
868 
869  $codeenabledisable = '';
870  $codetoconfig = '';
871 
872  // Force disable of module disabled into session (for demo for example)
873  if (in_array($modulenameshort, $disabled_modules)) {
874  $objMod->disabled = true;
875  }
876 
877  // Activate/Disable and Setup (2 columns)
878  if (getDolGlobalString($const_name)) { // If module is already activated
879  // Set $codeenabledisable
880  $disableSetup = 0;
881  if (!empty($arrayofwarnings[$modName])) {
882  $codeenabledisable .= '<!-- This module has a warning to show when we activate it (note: your country is '.$mysoc->country_code.') -->'."\n";
883  }
884 
885  if (!empty($objMod->disabled)) {
886  $codeenabledisable .= $langs->trans("Disabled");
887  } elseif (!empty($objMod->always_enabled) || ((isModEnabled('multicompany') && $objMod->core_enabled) && ($user->entity || $conf->entity != 1))) {
888  // @phan-suppress-next-line PhanUndeclaredMethodCall
889  if (method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) {
890  $codeenabledisable .= $langs->trans("Used");
891  } else {
892  $codeenabledisable .= img_picto($langs->trans("Required"), 'switch_on', '', false, 0, 0, '', 'opacitymedium valignmiddle');
893  //print $langs->trans("Required");
894  }
895  if (isModEnabled('multicompany') && $user->entity) {
896  $disableSetup++;
897  }
898  } else {
899  // @phan-suppress-next-line PhanUndeclaredMethodCall
900  if (!empty($objMod->warnings_unactivation[$mysoc->country_code]) && method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) {
901  $codeenabledisable .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?id='.$objMod->numero.'&amp;token='.newToken().'&amp;module_position='.$module_position.'&amp;action=reset_confirm&amp;confirm_message_code='.urlencode($objMod->warnings_unactivation[$mysoc->country_code]).'&amp;value='.$modName.'&amp;mode='.$mode.$param.'">';
902  $codeenabledisable .= img_picto($langs->trans("Activated").($warningstring ? ' '.$warningstring : ''), 'switch_on');
903  $codeenabledisable .= '</a>';
904  if (getDolGlobalInt("MAIN_FEATURES_LEVEL") > 1) {
905  $codeenabledisable .= '&nbsp;';
906  $codeenabledisable .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$objMod->numero.'&amp;token='.newToken().'&amp;module_position='.$module_position.'&amp;action=reload_confirm&amp;value='.$modName.'&amp;mode='.$mode.'&amp;confirm=yes'.$param.'">';
907  $codeenabledisable .= img_picto($langs->trans("Reload"), 'refresh', 'class="opacitymedium"');
908  $codeenabledisable .= '</a>';
909  }
910  } else {
911  $codeenabledisable .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?id='.$objMod->numero.'&amp;token='.newToken().'&amp;module_position='.$module_position.'&amp;action=reset&amp;value='.$modName.'&amp;mode='.$mode.'&amp;confirm=yes'.$param.'">';
912  $codeenabledisable .= img_picto($langs->trans("Activated").($warningstring ? ' '.$warningstring : ''), 'switch_on');
913  $codeenabledisable .= '</a>';
914  if (getDolGlobalInt("MAIN_FEATURES_LEVEL") > 1) {
915  $codeenabledisable .= '&nbsp;';
916  $codeenabledisable .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$objMod->numero.'&amp;token='.newToken().'&amp;module_position='.$module_position.'&amp;action=reload&amp;value='.$modName.'&amp;mode='.$mode.'&amp;confirm=yes'.$param.'">';
917  $codeenabledisable .= img_picto($langs->trans("Reload"), 'refresh', 'class="opacitymedium"');
918  $codeenabledisable .= '</a>';
919  }
920  }
921  }
922 
923  // Set $codetoconfig
924  if (!empty($objMod->config_page_url) && !$disableSetup) {
925  $backtourlparam = '';
926  if ($search_keyword != '') {
927  $backtourlparam .= ($backtourlparam ? '&' : '?').'search_keyword='.urlencode($search_keyword); // No urlencode here, done later
928  }
929  if ($search_nature > -1) {
930  $backtourlparam .= ($backtourlparam ? '&' : '?').'search_nature='.urlencode($search_nature); // No urlencode here, done later
931  }
932  if ($search_version > -1) {
933  $backtourlparam .= ($backtourlparam ? '&' : '?').'search_version='.urlencode($search_version); // No urlencode here, done later
934  }
935  if ($search_status > -1) {
936  $backtourlparam .= ($backtourlparam ? '&' : '?').'search_status='.urlencode($search_status); // No urlencode here, done later
937  }
938  $backtourl = $_SERVER["PHP_SELF"].$backtourlparam;
939 
940  $regs = array();
941  if (is_array($objMod->config_page_url)) {
942  $i = 0;
943  foreach ($objMod->config_page_url as $page) {
944  $urlpage = $page;
945  if ($i++) {
946  $codetoconfig .= '<a href="'.$urlpage.'" title="'.$langs->trans($page).'">'.img_picto(ucfirst($page), "setup").'</a>';
947  // print '<a href="'.$page.'">'.ucfirst($page).'</a>&nbsp;';
948  } else {
949  if (preg_match('/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) {
950  $urltouse = dol_buildpath('/'.$regs[2].'/admin/'.$regs[1], 1);
951  $codetoconfig .= '<a href="'.$urltouse.(preg_match('/\?/', $urltouse) ? '&' : '?').'save_lastsearch_values=1&backtopage='.urlencode($backtourl).'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').'</a>';
952  } else {
953  $urltouse = $urlpage;
954  $codetoconfig .= '<a href="'.$urltouse.(preg_match('/\?/', $urltouse) ? '&' : '?').'save_lastsearch_values=1&backtopage='.urlencode($backtourl).'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').'</a>';
955  }
956  }
957  }
958  } elseif (preg_match('/^([^@]+)@([^@]+)$/i', (string) $objMod->config_page_url, $regs)) {
959  $codetoconfig .= '<a class="valignmiddle" href="'.dol_buildpath('/'.$regs[2].'/admin/'.$regs[1], 1).'?save_lastsearch_values=1&backtopage='.urlencode($backtourl).'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').'</a>';
960  } else {
961  $codetoconfig .= '<a class="valignmiddle" href="'.((string) $objMod->config_page_url).'?save_lastsearch_values=1&backtopage='.urlencode($backtourl).'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').'</a>';
962  }
963  } else {
964  $codetoconfig .= img_picto($langs->trans("NothingToSetup"), "setup", 'class="opacitytransp" style="padding-right: 6px"', false, 0, 0, '', 'fa-15');
965  }
966  } else { // Module not yet activated
967  // Set $codeenabledisable
968  if (!empty($objMod->always_enabled)) {
969  // A 'always_enabled' module should not never be disabled. If this happen, we keep a link to re-enable it.
970  $codeenabledisable .= '<!-- Message to show: an always_enabled module has been disabled -->'."\n";
971  $codeenabledisable .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$objMod->numero.'&token='.newToken().'&module_position='.$module_position.'&action=set&token='.newToken().'&value='.$modName.'&mode='.$mode.$param.'"';
972  $codeenabledisable .= '>';
973  $codeenabledisable .= img_picto($langs->trans("Disabled"), 'switch_off');
974  $codeenabledisable .= "</a>\n";
975  } elseif (!empty($objMod->disabled)) {
976  $codeenabledisable .= $langs->trans("Disabled");
977  } else {
978  // Module qualified for activation
979  $warningmessage = '';
980  if (!empty($arrayofwarnings[$modName])) {
981  $codeenabledisable .= '<!-- This module is a core module and it may have a warning to show when we activate it (note: your country is '.$mysoc->country_code.') -->'."\n";
982  foreach ($arrayofwarnings[$modName] as $keycountry => $cursorwarningmessage) {
983  if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry))) {
984  $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code);
985  }
986  }
987  }
988  if ($objMod->isCoreOrExternalModule() == 'external' && !empty($arrayofwarningsext)) {
989  $codeenabledisable .= '<!-- This module is an external module and it may have a warning to show (note: your country is '.$mysoc->country_code.') -->'."\n";
990  foreach ($arrayofwarningsext as $keymodule => $arrayofwarningsextbycountry) {
991  $keymodulelowercase = strtolower(preg_replace('/^mod/', '', $keymodule));
992  if (in_array($keymodulelowercase, $conf->modules)) { // If module that request warning is on
993  foreach ($arrayofwarningsextbycountry as $keycountry => $cursorwarningmessage) {
994  if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry))) {
995  $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code, $modules[$keymodule]->getName());
996  $warningmessage .= ($warningmessage ? "\n" : "").($warningmessage ? "\n" : "").$langs->trans("Module").' : '.$objMod->getName();
997  if (!empty($objMod->editor_name)) {
998  $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans("Publisher").' : '.$objMod->editor_name;
999  }
1000  if (!empty($objMod->editor_name)) {
1001  $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans("ModuleTriggeringThisWarning").' : '.$modules[$keymodule]->getName();
1002  }
1003  }
1004  }
1005  }
1006  }
1007  }
1008  $codeenabledisable .= '<!-- Message to show: '.$warningmessage.' -->'."\n";
1009  $codeenabledisable .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$objMod->numero.'&token='.newToken().'&module_position='.$module_position.'&action=set&token='.newToken().'&value='.$modName.'&mode='.$mode.$param.'"';
1010  if ($warningmessage) {
1011  $codeenabledisable .= ' onclick="return confirm(\''.dol_escape_js($warningmessage).'\');"';
1012  }
1013  $codeenabledisable .= '>';
1014  $codeenabledisable .= img_picto($langs->trans("Disabled"), 'switch_off');
1015  $codeenabledisable .= "</a>\n";
1016  }
1017 
1018  // Set $codetoconfig
1019  $codetoconfig .= img_picto($langs->trans("NothingToSetup"), "setup", 'class="opacitytransp" style="padding-right: 6px"');
1020  }
1021 
1022  if ($mode == 'commonkanban') {
1023  // Output Kanban
1024  print $objMod->getKanbanView($codeenabledisable, $codetoconfig);
1025  } else {
1026  print '<tr class="oddeven'.($warningstring ? ' info-box-content-warning' : '').'">'."\n";
1027  if (getDolGlobalString('MAIN_MODULES_SHOW_LINENUMBERS')) {
1028  print '<td class="width50">'.$linenum.'</td>';
1029  }
1030 
1031  // Picto + Name of module
1032  print ' <td class="tdoverflowmax200 minwidth200imp" title="'.dol_escape_htmltag($objMod->getName()).'">';
1033  $alttext = '';
1034  //if (is_array($objMod->need_dolibarr_version)) $alttext.=($alttext?' - ':'').'Dolibarr >= '.join('.',$objMod->need_dolibarr_version);
1035  //if (is_array($objMod->phpmin)) $alttext.=($alttext?' - ':'').'PHP >= '.join('.',$objMod->phpmin);
1036  if (!empty($objMod->picto)) {
1037  if (preg_match('/^\//i', $objMod->picto)) {
1038  print img_picto($alttext, $objMod->picto, 'class="valignmiddle pictomodule paddingrightonly"', 1);
1039  } else {
1040  print img_object($alttext, $objMod->picto, 'class="valignmiddle pictomodule paddingrightonly"');
1041  }
1042  } else {
1043  print img_object($alttext, 'generic', 'class="valignmiddle paddingrightonly"');
1044  }
1045  print ' <span class="valignmiddle">'.$objMod->getName().'</span>';
1046  print "</td>\n";
1047 
1048  // Desc
1049  print '<td class="valignmiddle tdoverflowmax300 minwidth200imp">';
1050  print nl2br($objMod->getDesc());
1051  print "</td>\n";
1052 
1053  // Help
1054  print '<td class="center nowrap" style="width: 82px;">';
1055  //print $form->textwithpicto('', $text, 1, $imginfo, 'minheight20', 0, 2, 1);
1056  print '<a href="javascript:document_preview(\''.DOL_URL_ROOT.'/admin/modulehelp.php?id='.((int) $objMod->numero).'\',\'text/html\',\''.dol_escape_js($langs->trans("Module")).'\')">'.img_picto(($objMod->isCoreOrExternalModule() == 'external' ? $langs->trans("ExternalModule").' - ' : '').$langs->trans("ClickToShowDescription"), $imginfo).'</a>';
1057  print '</td>';
1058 
1059  // Version
1060  print '<td class="center nowrap width150" title="'.dol_escape_htmltag(dol_string_nohtmltag($versiontrans)).'">';
1061  if ($objMod->needUpdate) {
1062  $versionTitle = $langs->trans('ModuleUpdateAvailable').' : '.$objMod->lastVersion;
1063  print '<span class="badge badge-warning classfortooltip" title="'.dol_escape_htmltag($versionTitle).'">'.$versiontrans.'</span>';
1064  } else {
1065  print $versiontrans;
1066  }
1067  print "</td>\n";
1068 
1069  // Link enable/disable
1070  print '<td class="center valignmiddle left nowraponall" width="60px">';
1071  print $codeenabledisable;
1072  print "</td>\n";
1073 
1074  // Link config
1075  print '<td class="tdsetuppicto right valignmiddle" width="60px">';
1076  print $codetoconfig;
1077  print '</td>';
1078 
1079  print "</tr>\n";
1080  }
1081  if ($objMod->needUpdate) {
1082  $foundoneexternalmodulewithupdate++;
1083  }
1084  }
1085 
1086  if ($action == 'checklastversion') {
1087  if ($foundoneexternalmodulewithupdate) {
1088  setEventMessages($langs->trans("ModuleUpdateAvailable"), null, 'mesgs');
1089  } else {
1090  setEventMessages($langs->trans("NoExternalModuleWithUpdate"), null, 'mesgs');
1091  }
1092  }
1093 
1094  if ($oldfamily) {
1095  if ($mode == 'commonkanban') {
1096  print '</div>';
1097  } else {
1098  print "</table>\n";
1099  print '</div>';
1100  }
1101  }
1102 
1103  if (!$atleastonequalified) {
1104  print '<br><span class="opacitymedium">'.$langs->trans("NoDeployedModulesFoundWithThisSearchCriteria").'</span><br><br>';
1105  }
1106 
1107  print dol_get_fiche_end();
1108 
1109  print '<br>';
1110 
1111  // Show warning about external users
1112  print info_admin(showModulesExludedForExternal($modules))."\n";
1113 
1114  print '</form>';
1115 }
1116 
1117 if ($mode == 'marketplace') {
1118  print dol_get_fiche_head($head, $mode, '', -1);
1119 
1120  print $deschelp;
1121 
1122  print '<br>';
1123 
1124  // Marketplace
1125  print '<div class="div-table-responsive-no-min">';
1126  print '<table summary="list_of_modules" class="noborder centpercent">'."\n";
1127  print '<tr class="liste_titre">'."\n";
1128  print '<td class="hideonsmartphone">'.$form->textwithpicto($langs->trans("Provider"), $langs->trans("WebSiteDesc")).'</td>';
1129  print '<td></td>';
1130  print '<td>'.$langs->trans("URL").'</td>';
1131  print '</tr>';
1132 
1133  print '<tr class="oddeven">'."\n";
1134  $url = 'https://www.dolistore.com';
1135  print '<td class="hideonsmartphone"><a href="'.$url.'" target="_blank" rel="noopener noreferrer external"><img border="0" class="imgautosize imgmaxwidth180" src="'.DOL_URL_ROOT.'/theme/dolistore_logo.png"></a></td>';
1136  print '<td><span class="opacitymedium">'.$langs->trans("DoliStoreDesc").'</span></td>';
1137  print '<td><a href="'.$url.'" target="_blank" rel="noopener noreferrer external">'.$url.'</a></td>';
1138  print '</tr>';
1139 
1140  print "</table>\n";
1141  print '</div>';
1142 
1143  print dol_get_fiche_end();
1144 
1145  print '<br>';
1146 
1147  if (!getDolGlobalString('MAIN_DISABLE_DOLISTORE_SEARCH') && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1) {
1148  // $options is array with filter criteria
1149  //var_dump($options);
1150  $dolistore->getRemoteCategories();
1151  $dolistore->getRemoteProducts($options);
1152 
1153  print '<span class="opacitymedium">'.$langs->trans('DOLISTOREdescriptionLong').'</span><br><br>';
1154 
1155  $previouslink = $dolistore->get_previous_link();
1156  $nextlink = $dolistore->get_next_link();
1157 
1158  print '<div class="liste_titre liste_titre_bydiv centpercent"><div class="divsearchfield">';
1159 
1160  print '<form method="POST" class="centpercent" id="searchFormList" action="'.$dolistore->url.'">'; ?>
1161  <input type="hidden" name="token" value="<?php echo newToken(); ?>">
1162  <input type="hidden" name="mode" value="marketplace">
1163  <div class="divsearchfield">
1164  <input name="search_keyword" placeholder="<?php echo $langs->trans('Keyword') ?>" id="search_keyword" type="text" class="minwidth200" value="<?php echo dol_escape_htmltag($options['search']) ?>"><br>
1165  </div>
1166  <div class="divsearchfield">
1167  <input class="button buttongen" value="<?php echo $langs->trans('Rechercher') ?>" type="submit">
1168  <a class="buttonreset" href="<?php echo urlencode($dolistore->url) ?>"><?php echo $langs->trans('Reset') ?></a>
1169 
1170  &nbsp;
1171  </div>
1172  <?php
1173  print $previouslink;
1174  print $nextlink;
1175  print '</form>';
1176 
1177  print '</div></div>';
1178  print '<div class="clearboth"></div>';
1179  ?>
1180 
1181  <div id="category-tree-left">
1182  <ul class="tree">
1183  <?php
1184  echo $dolistore->get_categories(); // Do not use dol_escape_htmltag here, it is already a structured content?>
1185  </ul>
1186  </div>
1187  <div id="listing-content">
1188  <table summary="list_of_modules" id="list_of_modules" class="productlist centpercent">
1189  <tbody id="listOfModules">
1190  <?php echo $dolistore->get_products(); ?>
1191  </tbody>
1192  </table>
1193  </div>
1194  <?php
1195  }
1196 }
1197 
1198 
1199 // Install external module
1200 
1201 if ($mode == 'deploy') {
1202  print dol_get_fiche_head($head, $mode, '', -1);
1203 
1204  $fullurl = '<a href="'.$urldolibarrmodules.'" target="_blank" rel="noopener noreferrer">'.$urldolibarrmodules.'</a>';
1205  $message = '';
1206  if ($allowonlineinstall) {
1207  if (!in_array('/custom', explode(',', $dolibarr_main_url_root_alt))) {
1208  $message = info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT));
1209  $allowfromweb = -1;
1210  } else {
1211  if ($dirins_ok) {
1212  if (!is_writable(dol_osencode($dirins))) {
1213  $langs->load("errors");
1214  $message = info_admin($langs->trans("ErrorFailedToWriteInDir", $dirins), 0, 0, '1', 'warning');
1215  $allowfromweb = 0;
1216  }
1217  } else {
1218  $message = info_admin($langs->trans("NotExistsDirect", $dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample"));
1219  $allowfromweb = 0;
1220  }
1221  }
1222  } else {
1223  if (getDolGlobalString('MAIN_MESSAGE_INSTALL_MODULES_DISABLED_CONTACT_US')) {
1224  // Show clean message
1225  if (!is_numeric(getDolGlobalString('MAIN_MESSAGE_INSTALL_MODULES_DISABLED_CONTACT_US'))) {
1226  $message = info_admin($langs->trans(getDolGlobalString('MAIN_MESSAGE_INSTALL_MODULES_DISABLED_CONTACT_US')), 0, 0, 'warning');
1227  } else {
1228  $message = info_admin($langs->trans('InstallModuleFromWebHasBeenDisabledContactUs'), 0, 0, 'warning');
1229  }
1230  } else {
1231  // Show technical message
1232  $message = info_admin($langs->trans("InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.'/installmodules.lock'), 0, 0, 'warning');
1233  }
1234  $allowfromweb = 0;
1235  }
1236 
1237  print $deschelp;
1238 
1239  if ($allowfromweb < 1) {
1240  print $langs->trans("SomethingMakeInstallFromWebNotPossible");
1241  print $message;
1242  //print $langs->trans("SomethingMakeInstallFromWebNotPossible2");
1243  print '<br>';
1244  }
1245 
1246  print '<br>';
1247 
1248  // $allowfromweb = -1 if installation or setup not correct, 0 if not allowed, 1 if allowed
1249  if ($allowfromweb >= 0) {
1250  if ($allowfromweb == 1) {
1251  //print $langs->trans("ThisIsProcessToFollow").'<br>';
1252  } else {
1253  print $langs->trans("ThisIsAlternativeProcessToFollow").'<br>';
1254  print '<b>'.$langs->trans("StepNb", 1).'</b>: ';
1255  print str_replace('{s1}', $fullurl, $langs->trans("FindPackageFromWebSite", '{s1}')).'<br>';
1256  print '<b>'.$langs->trans("StepNb", 2).'</b>: ';
1257  print str_replace('{s1}', $fullurl, $langs->trans("DownloadPackageFromWebSite", '{s1}')).'<br>';
1258  print '<b>'.$langs->trans("StepNb", 3).'</b>: ';
1259  }
1260 
1261  if ($allowfromweb == 1) {
1262  print '<form enctype="multipart/form-data" method="POST" class="noborder" action="'.$_SERVER["PHP_SELF"].'" name="forminstall">';
1263  print '<input type="hidden" name="token" value="'.newToken().'">';
1264  print '<input type="hidden" name="action" value="install">';
1265  print '<input type="hidden" name="mode" value="deploy">';
1266 
1267  print $langs->trans("YouCanSubmitFile").'<br><br>';
1268 
1269  $max = getDolGlobalString('MAIN_UPLOAD_DOC'); // In Kb
1270  $maxphp = @ini_get('upload_max_filesize'); // In unknown
1271  if (preg_match('/k$/i', $maxphp)) {
1272  $maxphp = preg_replace('/k$/i', '', $maxphp);
1273  $maxphp *= 1;
1274  }
1275  if (preg_match('/m$/i', $maxphp)) {
1276  $maxphp = preg_replace('/m$/i', '', $maxphp);
1277  $maxphp *= 1024;
1278  }
1279  if (preg_match('/g$/i', $maxphp)) {
1280  $maxphp = preg_replace('/g$/i', '', $maxphp);
1281  $maxphp *= 1024 * 1024;
1282  }
1283  if (preg_match('/t$/i', $maxphp)) {
1284  $maxphp = preg_replace('/t$/i', '', $maxphp);
1285  $maxphp *= 1024 * 1024 * 1024;
1286  }
1287  $maxphp2 = @ini_get('post_max_size'); // In unknown
1288  if (preg_match('/k$/i', $maxphp2)) {
1289  $maxphp2 = preg_replace('/k$/i', '', $maxphp2);
1290  $maxphp2 *= 1;
1291  }
1292  if (preg_match('/m$/i', $maxphp2)) {
1293  $maxphp2 = preg_replace('/m$/i', '', $maxphp2);
1294  $maxphp2 *= 1024;
1295  }
1296  if (preg_match('/g$/i', $maxphp2)) {
1297  $maxphp2 = preg_replace('/g$/i', '', $maxphp2);
1298  $maxphp2 *= 1024 * 1024;
1299  }
1300  if (preg_match('/t$/i', $maxphp2)) {
1301  $maxphp2 = preg_replace('/t$/i', '', $maxphp2);
1302  $maxphp2 *= 1024 * 1024 * 1024;
1303  }
1304  // Now $max and $maxphp and $maxphp2 are in Kb
1305  $maxmin = $max;
1306  $maxphptoshow = $maxphptoshowparam = '';
1307  if ($maxphp > 0) {
1308  $maxmin = min($max, $maxphp);
1309  $maxphptoshow = $maxphp;
1310  $maxphptoshowparam = 'upload_max_filesize';
1311  }
1312  if ($maxphp2 > 0) {
1313  $maxmin = min($max, $maxphp2);
1314  if ($maxphp2 < $maxphp) {
1315  $maxphptoshow = $maxphp2;
1316  $maxphptoshowparam = 'post_max_size';
1317  }
1318  }
1319 
1320  if ($maxmin > 0) {
1321  print '<script type="text/javascript">
1322  $(document).ready(function() {
1323  jQuery("#fileinstall").on("change", function() {
1324  if(this.files[0].size > '.($maxmin * 1024).') {
1325  alert("'.dol_escape_js($langs->trans("ErrorFileSizeTooLarge")).'");
1326  this.value = "";
1327  }
1328  });
1329  });
1330  </script>'."\n";
1331  // MAX_FILE_SIZE doit précéder le champ input de type file
1332  print '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">';
1333  }
1334 
1335  print '<input class="flat minwidth400" type="file" name="fileinstall" id="fileinstall"> ';
1336 
1337  print '<input type="submit" name="send" value="'.dol_escape_htmltag($langs->trans("Upload")).'" class="button small">';
1338 
1339  if (getDolGlobalString('MAIN_UPLOAD_DOC')) {
1340  if ($user->admin) {
1341  $langs->load('other');
1342  print ' ';
1343  print info_admin($langs->trans("ThisLimitIsDefinedInSetup", $max, $maxphptoshow, $maxphptoshowparam), 1);
1344  }
1345  } else {
1346  print ' ('.$langs->trans("UploadDisabled").')';
1347  }
1348 
1349  print '</form>';
1350 
1351  print '<br>';
1352  print '<br>';
1353 
1354  print '<div class="center"><div class="logo_setup"></div></div>';
1355  } else {
1356  print $langs->trans("UnpackPackageInModulesRoot", $dirins).'<br>';
1357  print '<b>'.$langs->trans("StepNb", 4).'</b>: ';
1358  print $langs->trans("SetupIsReadyForUse", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentitiesnoconv("Home").' - '.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Modules")).'<br>';
1359  }
1360  }
1361 
1362  if (!empty($result['return'])) {
1363  print '<br>';
1364 
1365  foreach ($result['return'] as $value) {
1366  echo $value.'<br>';
1367  }
1368  }
1369 
1370  print dol_get_fiche_end();
1371 }
1372 
1373 if ($mode == 'develop') {
1374  print dol_get_fiche_head($head, $mode, '', -1);
1375 
1376  print $deschelp;
1377 
1378  print '<br>';
1379 
1380  // Marketplace
1381  print '<table summary="list_of_modules" class="noborder centpercent">'."\n";
1382  print '<tr class="liste_titre">'."\n";
1383  //print '<td>'.$langs->trans("Logo").'</td>';
1384  print '<td colspan="2">'.$langs->trans("DevelopYourModuleDesc").'</td>';
1385  print '<td>'.$langs->trans("URL").'</td>';
1386  print '</tr>';
1387 
1388  print '<tr class="oddeven" height="80">'."\n";
1389  print '<td class="center">';
1390  print '<div class="imgmaxheight50 logo_setup"></div>';
1391  print '</td>';
1392  print '<td>'.$langs->trans("TryToUseTheModuleBuilder", $langs->transnoentitiesnoconv("ModuleBuilder")).'</td>';
1393  print '<td class="maxwidth300">';
1394  if (isModEnabled('modulebuilder')) {
1395  print $langs->trans("SeeTopRightMenu");
1396  } else {
1397  print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("ModuleBuilder")).'</span>';
1398  }
1399  print '</td>';
1400  print '</tr>';
1401 
1402  print '<tr class="oddeven" height="80">'."\n";
1403  $url = 'https://partners.dolibarr.org';
1404  print '<td class="center">';
1405  print'<a href="'.$url.'" target="_blank" rel="noopener noreferrer external"><img border="0" class="imgautosize imgmaxwidth180" src="'.DOL_URL_ROOT.'/theme/dolibarr_preferred_partner.png"></a>';
1406  print '</td>';
1407  print '<td>'.$langs->trans("DoliPartnersDesc").'</td>';
1408  print '<td><a href="'.$url.'" target="_blank" rel="noopener noreferrer external">';
1409  print img_picto('', 'url', 'class="pictofixedwidth"');
1410  print $url.'</a></td>';
1411  print '</tr>';
1412 
1413  print "</table>\n";
1414 
1415  print dol_get_fiche_end();
1416 }
1417 
1418 // End of page
1419 llxFooter();
1420 $db->close();
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition: card.php:58
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:656
unActivateModule($value, $requiredby=1)
Disable a module.
Definition: admin.lib.php:1268
activateModule($value, $withdeps=1, $noconfverification=0)
Enable a module.
Definition: admin.lib.php:1125
modules_prepare_head($nbofactivatedmodules, $nboftotalmodules, $nbmodulesnotautoenabled)
Prepare array with list of tabs.
Definition: admin.lib.php:728
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:55
Class Dolistore.
Class to manage generation of HTML components Only common components must be here.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
Definition: files.lib.php:1609
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles='addedfile', $upload_dir='')
Check validity of a file upload from an GUI page, and move it to its final destination.
Definition: files.lib.php:1320
dol_uncompress($inputfile, $outputdir)
Uncompress a file.
Definition: files.lib.php:2452
dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayreplacement=null, $excludesubdir=0, $excludefileext=null, $excludearchivefiles=0)
Copy a dir to another dir.
Definition: files.lib.php:896
dol_is_file($pathoffile)
Return if path is a file.
Definition: files.lib.php:519
dol_is_dir($folder)
Test if filename is a directory.
Definition: files.lib.php:489
dolGetModulesDirs($subdir='')
Return list of directories that contain modules.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0)
Set event message in dol_events session object.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information in HTML for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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...
treeview li table
No Email.
document_preview(file, type, title)
Function show document preview.
$formconfirm
if ($action == 'delbookkeepingyear') {
table tableforfield button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
Definition: style.css.php:887
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.