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