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