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