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