dolibarr 25.0.0-alpha
modules.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
4 * Copyright (C) 2004-2024 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
6 * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
7 * Copyright (C) 2011-2023 Juanjo Menent <jmenent@2byte.es>
8 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
9 * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
10 * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
11 * Copyright (C) 2021-2026 Frédéric France <frederic.france@free.fr>
12 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
13 * Copyright (C) 2026 Charlene Benke <charlene@patas-monkey.com>
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <https://www.gnu.org/licenses/>.
27 */
28
34if (!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
35 define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
36}
37
38// The modules list is a setup hub: force the menu context to "home" when the
39// caller did not provide one, so the previously visited module's menu does not
40// stick when the user comes back to this page (issue 38058).
41if (!isset($_GET['mainmenu']) && !isset($_POST['mainmenu'])) {
42 $_GET['mainmenu'] = 'home';
43}
44
45// Load Dolibarr environment
46require '../main.inc.php';
57'
58@phan-var-force string $dolibarr_main_url_root_alt
59';
60require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
61require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
62require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
63require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
64require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
65require_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
66require_once DOL_DOCUMENT_ROOT.'/admin/remotestore/class/externalModules.class.php';
67
68
69// Load translation files required by the page
70$langs->loadLangs(array("admin", "modulebuilder"));
71
72$action = GETPOST('action', 'aZ09');
73$page = GETPOSTINT('page');
74$page_y = GETPOSTINT('page_y');
75$optioncss = GETPOST('optioncss', 'aZ09');
76$sortfield = GETPOST('sortfield', 'aZ09');
77$sortorder = GETPOST('sortorder', 'aZ09');
78
79$mode = GETPOST('mode', 'alpha');
80$value = GETPOST('value', 'alpha');
81$search_keyword = GETPOST('search_keyword', 'alpha');
82$search_status = GETPOST('search_status', 'alpha');
83$search_nature = GETPOST('search_nature', 'alpha');
84$search_version = GETPOST('search_version', 'alpha');
85
86
87// For remotestore search
88$options = array();
89$options['per_page'] = 11;
90$options['no_page'] = (GETPOSTINT('no_page') ? GETPOSTINT('no_page') : 1);
91$options['categorie'] = (GETPOSTINT('categorie') ? GETPOSTINT('categorie') : 0);
92$options['search'] = GETPOST('search_keyword', 'alpha');
93
94// If it is a new search, we reset page to 1
95if (GETPOST('buttonsubmit', 'alphanohtml', 2)) {
96 $options['no_page'] = 1;
97}
98
99// MAIN_ENABLE_EXTERNALMODULES_DOLISTORE is 1 if we enabled the dolistore modules
100$options['search_source_dolistore'] = getDolGlobalInt('MAIN_ENABLE_EXTERNALMODULES_DOLISTORE');
101// MAIN_ENABLE_EXTERNALMODULES_COMMUNITY is 1 if we enabled the community modules
102$options['search_source_github'] = getDolGlobalInt('MAIN_ENABLE_EXTERNALMODULES_COMMUNITY');
103
104if (!$user->admin) {
106}
107
108$familyinfo = array(
109 'hr' => array('position' => '001', 'label' => $langs->trans("ModuleFamilyHr")),
110 'crm' => array('position' => '006', 'label' => $langs->trans("ModuleFamilyCrm")),
111 'srm' => array('position' => '007', 'label' => $langs->trans("ModuleFamilySrm")),
112 'financial' => array('position' => '009', 'label' => $langs->trans("ModuleFamilyFinancial")),
113 'products' => array('position' => '012', 'label' => $langs->trans("ModuleFamilyProducts")),
114 'projects' => array('position' => '015', 'label' => $langs->trans("ModuleFamilyProjects")),
115 'ecm' => array('position' => '018', 'label' => $langs->trans("ModuleFamilyECM")),
116 'technic' => array('position' => '021', 'label' => $langs->trans("ModuleFamilyTechnic")),
117 'portal' => array('position' => '040', 'label' => $langs->trans("ModuleFamilyPortal")),
118 'interface' => array('position' => '050', 'label' => $langs->trans("ModuleFamilyInterface")),
119 'base' => array('position' => '060', 'label' => $langs->trans("ModuleFamilyBase")),
120 'other' => array('position' => '100', 'label' => $langs->trans("ModuleFamilyOther")),
121);
122
123$param = '';
124if (!GETPOST('buttonreset', 'alpha') && !GETPOST('button_removefilter', 'alpha')) {
125 if ($search_keyword) {
126 $param .= '&search_keyword='.urlencode($search_keyword);
127 }
128 if ($search_status && $search_status != '-1') {
129 $param .= '&search_status='.urlencode($search_status);
130 }
131 if ($search_nature && $search_nature != '-1') {
132 $param .= '&search_nature='.urlencode($search_nature);
133 }
134 if ($search_version && $search_version != '-1') {
135 $param .= '&search_version='.urlencode($search_version);
136 }
137}
138
139$dirins = DOL_DOCUMENT_ROOT.'/custom';
140$urldolibarrmodules = 'https://www.dolistore.com/';
141
142// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
143$hookmanager->initHooks(array('adminmodules', 'globaladmin'));
144
145// Increase limit of time. Works only if we are not in safe mode
146$max_execution_time_for_deploy = getDolGlobalInt('MODULE_UPLOAD_MAX_EXECUTION_TIME', 300); // 5mn if not defined
147if (!empty($max_execution_time_for_deploy)) {
148 $err = error_reporting();
149 error_reporting(0); // Disable all errors
150 //error_reporting(E_ALL);
151 @set_time_limit($max_execution_time_for_deploy);
152 error_reporting($err);
153}
154// Other method - TODO is this required ?
155$max_time = @ini_get("max_execution_time");
156if ($max_time && $max_time < $max_execution_time_for_deploy) {
157 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.");
158 @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
159}
160
161
162$dolibarrdataroot = preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT);
163$allowonlineinstall = true;
164$allowfromweb = 1;
165if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) {
166 $allowonlineinstall = false;
167}
168
169$debug = false;
170$remotestore = new ExternalModules($debug);
171
172if ($mode == 'marketplace') {
173 // Make remote calls
174 if (GETPOSTINT('dol_resetcache')) {
175 dol_delete_file($remotestore->cache_file);
176 foreach ($remotestore->custom_sources as $customsource) {
177 dol_delete_file($customsource['cache_file']);
178 }
179 }
180 $remotestore->loadRemoteSources(false);
181}
182
183$object = new stdClass();
184
185$now = dol_now();
186
187
188/*
189 * Actions
190 */
191
192$formconfirm = '';
193
194$parameters = array();
195$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
196if ($reshook < 0) {
197 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
198}
199
200// if we set another view list mode, we keep it (till we change one more time)
201if (GETPOSTISSET('mode')) {
202 $mode = GETPOST('mode', 'alpha');
203 if ($mode == 'common' && !getDolGlobalString('MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT')) {
204 dolibarr_set_const($db, "MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT", $mode, 'chaine', 0, '', $conf->entity);
205 }
206} else {
207 $mode = getDolGlobalString('MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT', 'commonkanban');
208}
209
210if (GETPOST('buttonreset', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
211 $search_keyword = '';
212 $search_status = '';
213 $search_nature = '';
214 $search_version = '';
215}
216
217if ($action == 'install' && $allowonlineinstall) {
218 $error = 0;
219 $modulenameval = '';
220
221 $isExternalDownload = 0;
222 $producttoinstall = GETPOST('producttoinstall', 'array');
223
224 // $original_file should match format module_modulename-x.y[.z].zip
225 if ($producttoinstall) {
226 $isExternalDownload = 1;
227 $tmpExternalModuleZipFile = $remotestore->getModuleZIP($producttoinstall); // Return the zip file path.
228 if ($tmpExternalModuleZipFile) {
229 // We fill $_FILES with the zip file we just created to reuse the same code as if file was uploaded by user
230 $_FILES['fileinstall'] = array(
231 'name' => basename($tmpExternalModuleZipFile),
232 'type' => 'application/zip',
233 'tmp_name' => $tmpExternalModuleZipFile,
234 'error' => 0,
235 'size' => filesize($tmpExternalModuleZipFile)
236 );
237 }
238 }
239
240 $tmpfile = (string) $_FILES['fileinstall']['tmp_name'];
241 $original_file = basename($_FILES["fileinstall"]["name"]);
242 $original_file = preg_replace('/\s*\‍(\d+\‍)\.zip$/i', '.zip', $original_file);
243 $newfile = dol_sanitizePathName($conf->admin->dir_temp.'/'.$original_file.'/'.$original_file);
244
245 if (empty($tmpfile)) {
246 $langs->load("errors");
247 setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors');
248 $error++;
249 }
250
251 if (!$original_file) {
252 $langs->load("errors");
253 if ($isExternalDownload) {
254 setEventMessages($langs->trans("ErrorFailToDownloadModuleFromSource", $producttoinstall['name']), null, 'warnings');
255 } else {
256 setEventMessages($langs->trans("ErrorModuleFileRequired"), null, 'warnings');
257 }
258 $error++;
259 } else {
260 if (!$error && !preg_match('/\.zip$/i', $original_file)) {
261 $langs->load("errors");
262 setEventMessages($langs->trans("ErrorFileMustBeADolibarrPackage", $original_file), null, 'errors');
263 $error++;
264 }
265 if (!$error && !preg_match('/^(module[a-zA-Z0-9]*_|theme_|).*\-([0-9][0-9\.]*)(\s\‍(\d+\‍)\s)?\.zip$/i', $original_file)) {
266 $langs->load("errors");
267 setEventMessages($langs->trans("ErrorFilenameDosNotMatchDolibarrPackageRules", $original_file, 'modulename-x[.y.z].zip'), null, 'errors');
268 $error++;
269 }
270 }
271
272 if (!$error) {
273 if ($original_file) {
274 @dol_delete_dir_recursive($conf->admin->dir_temp.'/'.$original_file);
275 dol_mkdir($conf->admin->dir_temp.'/'.$original_file);
276 }
277
278 $tmpdir = preg_replace('/\.zip$/i', '', $original_file).'.dir';
279 if ($tmpdir) {
280 @dol_delete_dir_recursive($conf->admin->dir_temp.'/'.$tmpdir);
281 dol_mkdir($conf->admin->dir_temp.'/'.$tmpdir);
282 }
283
284 $result = dol_move_uploaded_file($tmpfile, $newfile, 1, 0, $_FILES['fileinstall']['error'], 0, 'addedfile', '', $isExternalDownload ? 1 : 0);
285 if ((int) $result > 0) {
286 $resultuncompress = dol_uncompress($newfile, $conf->admin->dir_temp.'/'.$tmpdir);
287
288 if (!empty($resultuncompress['error'])) {
289 $langs->load("errors");
290 setEventMessages($langs->trans($resultuncompress['error'], $original_file), null, 'errors');
291 $error++;
292 } else {
293 // Now we move the dir of the module
294 $modulename = preg_replace('/module_/', '', $original_file);
295 $modulename = preg_replace('/\-([0-9][0-9\.]*)\.zip$/i', '', $modulename);
296 // Search dir $modulename
297 $modulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulename; // Example ./mymodule
298
299 if (!dol_is_dir($modulenamedir)) {
300 $modulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulename; // Example ./htdocs/mymodule
301 //var_dump($modulenamedir);
302 if (!dol_is_dir($modulenamedir)) {
303 $langs->load("errors");
304 setEventMessages($langs->trans("ErrorModuleFileSeemsToHaveAWrongFormat").'<br>'.$langs->trans("ErrorModuleFileSeemsToHaveAWrongFormat2", $modulename, 'htdocs/'.$modulename), null, 'errors');
305 $error++;
306 }
307 }
308
309 dol_syslog("Uncompress of module file is a success.");
310
311 // Load module into $objMod
312 /*
313 $modulesdir = array($modulenamedir.'/core/modules/');
314 foreach ($modulesdir as $dir) {
315 // Load modules attributes in arrays (name, numero, orders) from dir directory
316 //print $dir."\n<br>";
317 dol_syslog("Scan directory ".$dir." for module descriptor files (modXXX.class.php)");
318 $handle = @opendir($dir);
319 if (is_resource($handle)) {
320 while (($file = readdir($handle)) !== false) {
321 print $dir." ".$file."\n<br>";
322 if (is_readable($dir.$file) && dol_substr($file, 0, 3) == 'mod' && dol_substr($file, dol_strlen($file) - 10) == '.class.php') {
323 $modName = dol_substr($file, 0, dol_strlen($file) - 10);
324 if ($modName) {
325 try {
326 $res = include_once $dir.$file; // A class already exists in a different file will send a non catchable fatal error.
327 $modName = dol_substr($file, 0, dol_strlen($file) - 10);
328 if ($modName) {
329 if (class_exists($modName)) {
330 $objMod = new $modName($db);
331 '@phan-var-force DolibarrModules $objMod';
332
333 //var_dump($objMod);
334 }
335 }
336 } catch(Exception $e) {
337 // Nothing done
338 }
339 }
340 }
341 }
342 }
343 }
344 */
345
346 // Check if module is in the remote malware blacklist (at URL DolibarrModules::URL_FOR_BLACKLISTED_MODULES)
347 if (!$error) {
348 if (GETPOST('checkforcompliance') == 'on') {
349 try {
350 $res = include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
351 $dolibarrmodule = new DolibarrModules($db);
352 $checkRes = $dolibarrmodule->checkForcompliance($modulename);
353
354 if (!is_numeric($checkRes) && $checkRes != '') {
355 $langs->load("errors");
356 setEventMessages($modulename.' : '.$langs->trans($checkRes), null, 'errors');
357 $error++;
358 }
359 } catch (Exception $e) {
360 // Nothing done
361 }
362 }
363 }
364
365 if (!$error) {
366 // TODO Make more test ???
367 // Call validateZipFile() in functions2.lib.php ?
368 }
369
370 // We check if this is a metapackage (and wecomplete with child packages)
371 $modulenamearrays = array();
372 if (dol_is_file($modulenamedir.'/metapackage.conf')) {
373 // This is a meta package
374 $metafile = file_get_contents($modulenamedir.'/metapackage.conf');
375 $modulenamearrays = explode("\n", $metafile);
376 }
377 $modulenamearrays[$modulename] = $modulename;
378 //var_dump($modulenamearrays);exit;
379
380 // Lop on each packages (can have several if package is a metapackage)
381 if (! $error) {
382 foreach ($modulenamearrays as $modulenameval) {
383 if (strpos($modulenameval, '#') === 0) {
384 continue; // Discard comments
385 }
386 if (strpos($modulenameval, '//') === 0) {
387 continue; // Discard comments
388 }
389 if (!trim($modulenameval)) {
390 continue;
391 }
392
393 // Now we install the module
394 if (!$error) {
395 @dol_delete_dir_recursive($dirins.'/'.$modulenameval); // delete the target directory
396 $submodulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulenameval;
397 if (!dol_is_dir($submodulenamedir)) {
398 $submodulenamedir = $conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulenameval;
399 }
400 dol_syslog("We copy now directory ".$submodulenamedir." into target dir ".$dirins.'/'.$modulenameval);
401 $resultcopy = dolCopyDir($submodulenamedir, $dirins.'/'.$modulenameval, '0444', 1);
402 if ($resultcopy <= 0) {
403 dol_syslog('Failed to call dolCopyDir result='.$resultcopy." with param ".$submodulenamedir." and ".$dirins.'/'.$modulenameval, LOG_WARNING);
404 $langs->load("errors");
405 setEventMessages($langs->trans("ErrorFailToCopyDir", $submodulenamedir, $dirins.'/'.$modulenameval), null, 'errors');
406 $error++;
407 }
408 }
409 }
410 }
411 }
412 } else {
413 $langs->load("errors");
414 setEventMessages($langs->trans("ErrorFailToRenameFile", $tmpfile, $newfile).' - code = '.$result, null, 'errors');
415 $error++;
416 }
417 }
418
419 // Add event purge
420 $securityevent = new Events($db);
421 if ($error) {
422 $text = $langs->trans("SecurityModuleDeploymentError", dol_sanitizePathName($_FILES["fileinstall"]["name"]));
423 $securityevent->type = 'MODULE_DEPLOYMENT_ERROR';
424 } else {
425 $text = $langs->trans("SecurityModuleDeploymentSuccess", dol_sanitizePathName($_FILES["fileinstall"]["name"]));
426 $securityevent->type = 'MODULE_DEPLOYMENT_SUCCESS';
427 }
428 $securityevent->dateevent = $now;
429 $securityevent->description = $text;
430
431 $resultcreateevent = $securityevent->create($user);
432
433 if (!$error) {
434 $searchParams = array(
435 'search_keyword' => $modulenameval,
436 'search_status' => '-1',
437 'search_nature' => '-1',
438 'search_version' => '-1'
439 );
440 $redirectUrl = dolBuildUrl(DOL_URL_ROOT . '/admin/modules.php', $searchParams);
441
442 $message = $langs->trans("SetupIsReadyForUse", $redirectUrl, $langs->transnoentitiesnoconv("Home").' - '.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Modules"));
443
444 setEventMessages($message, null, 'warnings');
445 }
446} elseif ($action == 'install' && !$allowonlineinstall) {
447 httponly_accessforbidden("You try to bypass the protection to disallow deployment of an external module. Hack attempt ?");
448}
449
450if ($action == 'set' && $user->admin) {
451 // We made some check against evil eternal modules that try to low security options.
452 $checkOldValue = getDolGlobalInt('CHECKLASTVERSION_EXTERNALMODULE');
453 $csrfCheckOldValue = getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN');
454
455 $resarray = activateModule($value, 1, 0, 'acceptredirect');
456
457 if ($checkOldValue != getDolGlobalInt('CHECKLASTVERSION_EXTERNALMODULE')) {
458 setEventMessage($langs->trans('WarningModuleHasChangedLastVersionCheckParameter', $value), 'warnings');
459 }
460 if ($csrfCheckOldValue != getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN')) {
461 setEventMessage($langs->trans('WarningModuleHasChangedSecurityCsrfParameter', $value), 'warnings');
462 }
463
464 dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity);
465 if (!empty($resarray['errors'])) {
466 setEventMessages('', $resarray['errors'], 'errors');
467 } else {
468 //var_dump($resarray);exit;
469 if ($resarray['nbperms'] > 0) {
470 $tmpsql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."user WHERE admin <> 1";
471 $resqltmp = $db->query($tmpsql);
472 if ($resqltmp) {
473 $obj = $db->fetch_object($resqltmp);
474 //var_dump($obj->nb);exit;
475 if ($obj && $obj->nb > 1) {
476 $msg = $langs->trans('ModuleEnabledAdminMustCheckRights');
477 setEventMessages($msg, null, 'warnings');
478 }
479 } else {
480 dol_print_error($db);
481 }
482 }
483 }
484 header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : ''));
485 exit;
486} elseif ($action == 'reset' && $user->admin && GETPOST('confirm') == 'yes') {
487 $result = unActivateModule($value);
488 dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity);
489 if ($result) {
490 setEventMessages($result, null, 'errors');
491 }
492 header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : ''));
493 exit;
494} elseif (getDolGlobalInt("MAIN_FEATURES_LEVEL") > 1 && $action == 'reload' && $user->admin && GETPOST('confirm') == 'yes') {
495 $result = unActivateModule($value, 0, 'newboxdefonly'); // unactivate all module features but for widget, we reload only definition and we do not change position or setup
496 dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity);
497 if ($result) {
498 setEventMessages($result, null, 'errors');
499 header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : ''));
500 exit;
501 }
502
503 $resarray = activateModule($value, 0, 1, 'acceptredirect');
504
505 dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1), 'chaine', 0, '', $conf->entity);
506 if (!empty($resarray['errors'])) {
507 setEventMessages('', $resarray['errors'], 'errors');
508 } else {
509 if ($resarray['nbperms'] > 0) {
510 $tmpsql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."user WHERE admin <> 1";
511 $resqltmp = $db->query($tmpsql);
512 if ($resqltmp) {
513 $obj = $db->fetch_object($resqltmp);
514 if ($obj && $obj->nb > 1) {
515 $msg = $langs->trans('ModuleEnabledAdminMustCheckRights');
516 setEventMessages($msg, null, 'warnings');
517 }
518 } else {
519 dol_print_error($db);
520 }
521 }
522 }
523 header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : ''));
524 exit;
525}
526
527
528/*
529 * View
530 */
531
532$form = new Form($db);
533
534$morejs = array();
535$morecss = array("/admin/remotestore/css/store.css");
536
537// Set dir where external modules are installed
538if (!dol_is_dir($dirins)) {
539 dol_mkdir($dirins);
540}
541$dirins_ok = (dol_is_dir($dirins));
542
543$help_url = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
544llxHeader('', $langs->trans("Setup"), $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-admin page-modules');
545
546
547// Search modules dirs
548$modulesdir = dolGetModulesDirs();
549
550$arrayofnatures = array(
551 'core' => array('label' => $langs->transnoentitiesnoconv("NativeModules")),
552 'external' => array('label' => $langs->transnoentitiesnoconv("External").' - ['.$langs->trans("AllPublishers").']')
553);
554$arrayofwarnings = array(); // Array of warning each module want to show when activated
555$arrayofwarningsext = array(); // Array of warning each module want to show when we activate an external module
556$filename = array();
557$modules = array();
558$orders = array();
559$categ = array();
560$timestoinit = [];
561//$publisherlogoarray = array();
562
563$i = 0; // is a sequencer of modules found
564$j = 0; // j is module number. Automatically affected if module number not defined.
565$modNameLoaded = array();
566
567// Load $modules (required for the badge count)
568foreach ($modulesdir as $dir) {
569 // Load modules attributes in arrays (name, numero, orders) from dir directory
570 //print $dir."\n<br>";
571 dol_syslog("Scan directory ".$dir." for module descriptor files (modXXX.class.php)");
572 $handle = @opendir($dir);
573 $timestart = microtime(true);
574 if (is_resource($handle)) {
575 while (($file = readdir($handle)) !== false) {
576 //print "$i ".$file."\n<br>";
577 if (is_readable($dir.$file) && dol_substr($file, 0, 3) == 'mod' && dol_substr($file, dol_strlen($file) - 10) == '.class.php') {
578 $modName = dol_substr($file, 0, dol_strlen($file) - 10);
579
580 if ($modName) {
581 if (!empty($modNameLoaded[$modName])) { // In cache of already loaded modules ?
582 $mesg = "Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.<br>";
583 setEventMessages($mesg, null, 'warnings');
584 dol_syslog($mesg, LOG_ERR);
585 continue;
586 }
587
588 try {
589 $res = include_once $dir.$file; // A class already exists in a different file will send a non catchable fatal error.
590 if (class_exists($modName)) {
591 $objMod = new $modName($db);
592 '@phan-var-force DolibarrModules $objMod';
594 $modNameLoaded[$modName] = $dir;
595 if (!$objMod->numero > 0 && $modName != 'modUser') {
596 dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR);
597 }
598 $j = $objMod->numero;
599
600 $modulequalified = 1;
601
602 // We discard modules according to features level (PS: if module is activated we always show it)
603 $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod)));
604 if ($objMod->version == 'development' && (!getDolGlobalString($const_name) && (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2))) {
605 $modulequalified = 0;
606 }
607 if ($objMod->version == 'experimental' && (!getDolGlobalString($const_name) && (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1))) {
608 $modulequalified = 0;
609 }
610 if (preg_match('/deprecated/', $objMod->version) && (!getDolGlobalString($const_name) && (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 0))) {
611 $modulequalified = 0;
612 }
613
614 // We discard modules according to property ->hidden
615 if (!empty($objMod->hidden)) {
616 $modulequalified = 0;
617 }
618
619 if ($modulequalified > 0) {
620 $publisher = dol_escape_htmltag($objMod->getPublisher());
621 $external = ($objMod->isCoreOrExternalModule() == 'external');
622 if ($external) {
623 if ($publisher) {
624 // Check if there is a logo forpublisher
625 /* Do not show the company logo in combo. Make combo list dirty.
626 if (!empty($objMod->editor_squarred_logo)) {
627 $publisherlogoarray['external_'.$publisher] = img_picto('', $objMod->editor_squarred_logo, 'class="publisherlogoinline"');
628 }
629 $publisherlogo = empty($publisherlogoarray['external_'.$publisher]) ? '' : $publisherlogoarray['external_'.$publisher];
630 */
631 $arrayofnatures['external_'.$publisher] = array('label' => $langs->trans("External").' - '.$publisher, 'data-html' => $langs->trans("External").' - <span class="opacitymedium inine-block valignmiddle">'.$publisher.'</span>');
632 } else {
633 $arrayofnatures['external_'] = array('label' => $langs->trans("External").' - ['.$langs->trans("UnknownPublishers").']');
634 }
635 }
636 ksort($arrayofnatures);
637
638 // Define an array $categ with categ with at least one qualified module
639 $filename[$i] = $modName;
640 $modules[$modName] = $objMod;
641 $timestoinit[$modName] = round((microtime(true) - $timestart) * 1000, 3);
642
643 // Gives the possibility to the module, to provide his own family info and position of this family
644 if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) {
645 $familyinfo = array_merge($familyinfo, $objMod->familyinfo);
646 $familykey = key($objMod->familyinfo);
647 } else {
648 $familykey = $objMod->family;
649 }
650 '@phan-var-force string $familykey'; // if not, phan considers $familykey may be null
651
652 $moduleposition = ($objMod->module_position ? $objMod->module_position : '50');
653 if ($objMod->isCoreOrExternalModule() == 'external' && $moduleposition < 100000) {
654 // an external module should never return a value lower than '80'.
655 $moduleposition = '80'; // External modules at end by default
656 }
657
658 // Add list of warnings to show into arrayofwarnings and arrayofwarningsext
659 if (!empty($objMod->warnings_activation)) {
660 $arrayofwarnings[$modName] = $objMod->warnings_activation;
661 }
662 if (!empty($objMod->warnings_activation_ext)) {
663 $arrayofwarningsext[$modName] = $objMod->warnings_activation_ext;
664 }
665
666 $familyposition = (empty($familyinfo[$familykey]['position']) ? '0' : $familyinfo[$familykey]['position']);
667 if ($external && !in_array($familykey, array_keys($familyinfo))) {
668 // 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).
669 if (is_numeric($familyposition)) {
670 $familyposition = sprintf("%03d", (int) $familyposition + 100);
671 }
672 }
673
674 $orders[$i] = $familyposition."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number
675
676 // Set categ[$i]
677 $specialstring = 'unknown';
678 if ($objMod->version == 'development' || $objMod->version == 'experimental') {
679 $specialstring = 'expdev';
680 }
681 if (isset($categ[$specialstring])) {
682 $categ[$specialstring]++; // Array of all different modules categories
683 } else {
684 $categ[$specialstring] = 1;
685 }
686 $j++;
687 $i++;
688 } else {
689 dol_syslog("Module ".get_class($objMod)." not qualified");
690 }
691 } else {
692 // Skip warning for modules being refactored (class split in progress)
693 $silentModules = array('modSupplierOrder', 'modSupplierInvoice', 'modFournisseur');
694 if (!in_array($modName, $silentModules)) {
695 print info_admin("admin/modules.php Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)", 0, 0, '1', 'warning');
696 }
697 }
698 } catch (Exception $e) {
699 dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
700 }
701 }
702 }
703 }
704 closedir($handle);
705 } else {
706 dol_syslog("htdocs/admin/modules.php: Failed to open directory ".$dir.". See permission and open_basedir option.", LOG_WARNING);
707 }
708}
709
710'@phan-var-force array<string,DolibarrModules> $modules';
713if ($action == 'reset_confirm' && $user->admin) {
714 if (!empty($modules[$value])) {
715 $objMod = $modules[$value];
716
717 if (!empty($objMod->langfiles)) {
718 $langs->loadLangs($objMod->langfiles);
719 }
720
721 $form = new Form($db);
722 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?value='.$value.'&mode='.$mode.$param, $langs->trans('ConfirmUnactivation'), $langs->trans(GETPOST('confirm_message_code')), 'reset', '', 'no', 1, 300, 550);
723 }
724}
725
726if ($action == 'reload_confirm' && $user->admin) {
727 if (!empty($modules[$value])) {
728 $objMod = $modules[$value];
729
730 if (!empty($objMod->langfiles)) {
731 $langs->loadLangs($objMod->langfiles);
732 }
733
734 $form = new Form($db);
735 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?value='.$value.'&mode='.$mode.$param, $langs->trans('ConfirmReload'), $langs->trans(GETPOST('confirm_message_code')), 'reload', '', 'no', 1);
736 }
737}
738
739print $formconfirm;
740
741asort($orders);
742//var_dump($orders);
743//var_dump($categ);
744//var_dump($modules);
745
746$nbofactivatedmodules = count($conf->modules);
747
748// Define $nbmodulesnotautoenabled - TODO This code is at different places
749$nbmodulesnotautoenabled = count($conf->modules);
750$listofmodulesautoenabled = array('user', 'agenda', 'fckeditor', 'export', 'import');
751foreach ($listofmodulesautoenabled as $moduleautoenable) {
752 if (in_array($moduleautoenable, $conf->modules)) {
753 $nbmodulesnotautoenabled--;
754 }
755}
756
757print load_fiche_titre($langs->trans("ModulesSetup"), '', 'title_setup');
758
759// Start to show page
760$deschelp = '';
761if ($mode == 'common' || $mode == 'commonkanban') {
762 $desc = $langs->trans("ModulesDesc", '{picto}');
763 $desc .= ' '.$langs->trans("ModulesDesc2", '{picto2}');
764 $desc = str_replace('{picto}', img_picto('', 'switch_off', 'class="size15x"'), $desc);
765 $desc = str_replace('{picto2}', img_picto('', 'setup', 'class="size15x"'), $desc);
766 if (getDolGlobalInt('MAIN_SETUP_MODULES_DESC') || $nbmodulesnotautoenabled < getDolGlobalInt('MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) { // If only minimal initial modules enabled
767 $deschelp .= '<div class="info hideonsmartphone">'.$desc."<br></div>\n";
768 }
769 if (getDolGlobalString('MAIN_SETUP_MODULES_INFO')) { // Add a custom info message. A good usage for SaaS in combination with option MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING.
770 $deschelp .= '<div class="info">'.$langs->trans(getDolGlobalString('MAIN_SETUP_MODULES_INFO'))."<br></div>\n";
771 }
772 if ($deschelp) {
773 $deschelp .= '<br>';
774 }
775}
776if ($mode == 'deploy') {
777 $deschelp = '<div class="info hideonsmartphone">'.$langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."<br></div><br>\n";
778}
779if ($mode == 'develop') {
780 $deschelp = '<div class="info hideonsmartphone">'.$langs->trans("ModulesDevelopDesc")."<br></div><br>\n";
781}
782
783$head = modules_prepare_head($nbofactivatedmodules, count($modules), $nbmodulesnotautoenabled);
784
785
786if ($mode == 'common' || $mode == 'commonkanban') {
787 dol_set_focus('#search_keyword');
788
789 print '<form method="POST" id="searchFormList" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'" spellcheck="false">';
790 print '<input type="hidden" name="token" value="'.newToken().'">';
791 if (isset($optioncss) && $optioncss != '') {
792 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
793 }
794 if (isset($sortfield) && $sortfield != '') {
795 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
796 }
797 if (isset($sortorder) && $sortorder != '') {
798 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
799 }
800 if (isset($page) && $page != '') {
801 print '<input type="hidden" name="page" value="'.$page.'">';
802 }
803 print '<input type="hidden" name="mode" value="'.$mode.'">';
804
805 print dol_get_fiche_head($head, 'modules', '', -1);
806
807 print $deschelp;
808
809 $moreforfilter = '<div class="valignmiddle">';
810
811 $moreforfilter .= '<div class="floatright right pagination paddingtop --module-list"><ul><li>';
812 $moreforfilter .= dolGetButtonTitle(
813 $langs->trans('CheckForModuleUpdate'),
814 $langs->trans('CheckForModuleUpdate').'<br><br>'.img_warning('', '', 'paddingright').$langs->trans('CheckForModuleUpdateHelp').' '.$langs->trans('CheckForModuleUpdateHelp2', DolibarrModules::URL_FOR_BLACKLISTED_MODULES).'<br>'.$langs->trans("YourIPWillBeRevealedToThisExternalProviders"),
815 'fa fa-sync',
816 $_SERVER["PHP_SELF"].'?action=checklastversion&token='.newToken().'&mode='.$mode.$param,
817 '',
818 1,
819 array('morecss' => 'reposition')
820 );
821 $moreforfilter .= dolGetButtonTitleSeparator();
822 $moreforfilter .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.$param, '', ($mode == 'common' ? 2 : 1), array('morecss' => 'reposition'));
823 $moreforfilter .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=commonkanban'.$param, '', ($mode == 'commonkanban' ? 2 : 1), array('morecss' => 'reposition'));
824 $moreforfilter .= '</li></ul></div>';
825
826 $moreforfilter .= '<div class="divfilteralone colorbacktimesheet float valignmiddle nopaddingtopimp nopaddingbottomimp">';
827 $moreforfilter .= '<div class="divsearchfield paddingtop paddingbottom valignmiddle inline-block">';
828 $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')).'">';
829 $moreforfilter .= '</div>';
830 $moreforfilter .= '<div class="divsearchfield paddingtop paddingbottom valignmiddle inline-block">';
831 $moreforfilter .= $form->selectarray('search_nature', $arrayofnatures, dol_escape_htmltag($search_nature), $langs->trans('Origin'), 0, 0, '', 0, 0, 0, '', 'maxwidth250', 1);
832 $moreforfilter .= '</div>';
833
834 if (getDolGlobalInt('MAIN_FEATURES_LEVEL')) {
835 $array_version = array('stable' => $langs->transnoentitiesnoconv("Stable"));
836 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 0) {
837 $array_version['deprecated'] = $langs->trans("Deprecated");
838 }
839 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') > 0) {
840 $array_version['experimental'] = $langs->trans("Experimental");
841 }
842 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') > 1) {
843 $array_version['development'] = $langs->trans("Development");
844 }
845 $moreforfilter .= '<div class="divsearchfield paddingtop paddingbottom valignmiddle inline-block">';
846 $moreforfilter .= $form->selectarray('search_version', $array_version, $search_version, $langs->transnoentitiesnoconv('Version'), 0, 0, '', 0, 0, 0, '', 'maxwidth150', 1);
847 $moreforfilter .= '</div>';
848 }
849 $array_status = array('active' => $langs->transnoentitiesnoconv("Enabled"), 'disabled' => $langs->transnoentitiesnoconv("Disabled"));
850 $moreforfilter .= '<div class="divsearchfield paddingtop paddingbottom valignmiddle inline-block">';
851 $moreforfilter .= $form->selectarray('search_status', $array_status, $search_status, $langs->transnoentitiesnoconv('Status'), 0, 0, '', 0, 0, 0, '', 'maxwidth150', 1);
852 $moreforfilter .= '</div>';
853 $moreforfilter .= ' ';
854 $moreforfilter .= '<div class="divsearchfield valignmiddle inline-block">';
855 $moreforfilter .= '<input type="submit" name="buttonsubmit" class="button small nomarginleft" value="'.dolPrintHTMLForAttribute($langs->trans("Refresh")).'">';
856 if ($search_keyword || ($search_nature && $search_nature != '-1') || ($search_version && $search_version != '-1') || ($search_status && $search_status != '-1')) {
857 $moreforfilter .= ' ';
858 $moreforfilter .= '<input type="submit" name="button_removefilter" class="buttonreset noborderall nomargintop nomarginbottom" value="'.dolPrintHTMLForAttribute($langs->trans("Reset")).'">';
859 }
860 $moreforfilter .= '</div>';
861 $moreforfilter .= '</div>';
862
863 $moreforfilter .= '</div>';
864
865 print $moreforfilter;
866 $parameters = array();
867 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
868 print $hookmanager->resPrint;
869
870 $moreforfilter = '';
871
872 print '<div class="clearboth"></div><br><br>';
873
874 $object = new stdClass();
875 $parameters = array();
876 $reshook = $hookmanager->executeHooks('insertExtraHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
877 if ($reshook < 0) {
878 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
879 }
880
881 $disabled_modules = array();
882 if (!empty($_SESSION["disablemodules"])) {
883 $disabled_modules = explode(',', $_SESSION["disablemodules"]);
884 }
885
886 // Show list of modules
887 $oldfamily = '';
888 $foundoneexternalmodulewithupdate = 0;
889 $linenum = 0;
890 $atleastonequalified = 0;
891 $atleastoneforfamily = 0;
892
893 print '<script type="text/javascript">
894 jQuery(document).ready(function() {
895 jQuery(".modulefamilygroup").each(function() {
896 var $group = jQuery(this);
897 var $title = $group.find(".titre.inline-block").first();
898 var $nextContainer = $group.nextAll(".div-table-responsive, .box-flex-container").first();
899 if ($title.length && !$title.children(".modulefamilytoggleicon").length) {
900 $title.prepend("<i class=\"fa modulefamilytoggleicon paddingleft paddingleftright\"></i> ");
901 }
902 var $icon = $title.children(".modulefamilytoggleicon").first();
903 var isVisible = $nextContainer.is(":visible");
904 if ($icon.length && $nextContainer.length) {
905 $icon.toggleClass("fa-folder-open", isVisible);
906 $icon.toggleClass("fa-folder", !isVisible);
907 }
908 });
909
910 jQuery(document).on("click", ".modulefamilygroup", function() {
911 var $group = jQuery(this);
912 var $nextContainer = $group.nextAll(".div-table-responsive, .box-flex-container").first();
913 if ($nextContainer.length) {
914 var $icon = $group.find(".modulefamilytoggleicon").first();
915 var isVisible = $nextContainer.is(":visible");
916 $nextContainer.stop(true, true).slideToggle(150);
917 if ($icon.length) {
918 $icon.toggleClass("fa-folder-open", !isVisible);
919 $icon.toggleClass("fa-folder", isVisible);
920 }
921 }
922 });
923 });
924 </script>';
925
926 foreach ($orders as $key => $value) {
927 $linenum++;
928 $tab = explode('_', $value);
929 $familykey = $tab[1];
930 $module_position = $tab[2];
931
932 $modName = $filename[$key];
933
935 $objMod = $modules[$modName];
936
937 if (!is_object($objMod)) {
938 continue;
939 }
940
941 //print $objMod->name." - ".$key." - ".$objMod->version."<br>";
942 if ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental') {
943 continue; // Discard if not for current tab
944 }
945
946 if (!$objMod->getName()) {
947 dol_syslog("Error for module ".$key." - Property name of module looks empty", LOG_WARNING);
948 continue;
949 }
950
951 $modulenameshort = strtolower(preg_replace('/^mod/i', '', get_class($objMod)));
952 $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod)));
953
954 // Check filters
955 $modulename = $objMod->getName();
956 $moduletechnicalname = $objMod->name;
957 $moduledesc = $objMod->getDesc();
958 $moduledesclong = $objMod->getDescLong();
959 $moduleauthor = $objMod->getPublisher();
960
961 // We discard showing according to filters
962 if ($search_keyword) {
963 $qualified = 0;
964 $search_keyword_array = explode(' ', $search_keyword);
965 $foundkeyword = 1;
966 foreach ($search_keyword_array as $word) {
967 if (!preg_match('/'.preg_quote($word, '/').'/i', $modulename)
968 && !preg_match('/'.preg_quote($word, '/').'/i', $moduletechnicalname)
969 && !($moduledesc && preg_match('/'.preg_quote($word, '/').'/i', $moduledesc))
970 && !($moduledesclong && preg_match('/'.preg_quote($word, '/').'/i', $moduledesclong))
971 && !($moduleauthor && preg_match('/'.preg_quote($word, '/').'/i', $moduleauthor))
972 ) {
973 $foundkeyword = 0;
974 }
975 }
976 if ($foundkeyword) {
977 $qualified = 1;
978 }
979 if (!$qualified) {
980 continue;
981 }
982 }
983 if ($search_status) {
984 if ($search_status == 'active' && !getDolGlobalString($const_name)) {
985 continue;
986 }
987 if ($search_status == 'disabled' && getDolGlobalString($const_name)) {
988 continue;
989 }
990 }
991 if ($search_nature) {
992 if (preg_match('/^external/', $search_nature) && $objMod->isCoreOrExternalModule() != 'external') {
993 continue;
994 }
995 $reg = array();
996 if (preg_match('/^external_(.*)$/', $search_nature, $reg)) {
997 //print $reg[1].'-'.dol_escape_htmltag($objMod->getPublisher());
998 $publisher = dol_escape_htmltag($objMod->getPublisher());
999 if ($reg[1] && dol_escape_htmltag($reg[1]) != $publisher) {
1000 continue;
1001 }
1002 if (!$reg[1] && !empty($publisher)) {
1003 continue;
1004 }
1005 }
1006 if ($search_nature == 'core' && $objMod->isCoreOrExternalModule() == 'external') {
1007 continue;
1008 }
1009 }
1010 if ($search_version) {
1011 if (($objMod->version == 'development' || $objMod->version == 'experimental' || preg_match('/deprecated/', $objMod->version)) && $search_version == 'stable') {
1012 continue;
1013 }
1014 if ($objMod->version != 'development' && ($search_version == 'development')) {
1015 continue;
1016 }
1017 if ($objMod->version != 'experimental' && ($search_version == 'experimental')) {
1018 continue;
1019 }
1020 if (!preg_match('/deprecated/', $objMod->version) && ($search_version == 'deprecated')) {
1021 continue;
1022 }
1023 }
1024
1025 $atleastonequalified++;
1026
1027 // Load all language files of the qualified module
1028 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1029 foreach ($objMod->langfiles as $domain) {
1030 $langs->load($domain);
1031 }
1032 }
1033
1034 // Print a separator if we change family
1035 if ($familykey != $oldfamily) {
1036 if ($oldfamily) {
1037 print '</table></div><br>';
1038 }
1039
1040 $familytext = empty($familyinfo[$familykey]['label']) ? $familykey : $familyinfo[$familykey]['label'];
1041
1042 print load_fiche_titre($familytext, '', '', 0, '', 'modulefamilygroup');
1043
1044 if ($mode == 'commonkanban') {
1045 print '<div class="box-flex-container kanban">';
1046 } else {
1047 print '<div class="div-table-responsive">';
1048 print '<table class="tagtable liste" summary="list_of_modules">'."\n";
1049 }
1050
1051 $atleastoneforfamily = 0;
1052 }
1053
1054 $atleastoneforfamily++;
1055
1056 if ($familykey != $oldfamily) {
1057 $familytext = empty($familyinfo[$familykey]['label']) ? $familykey : $familyinfo[$familykey]['label'];
1058 $oldfamily = $familykey;
1059 }
1060
1061 // Version (with picto warning or not)
1062 $version = $objMod->getVersion(0);
1063 $versiontrans = '';
1064 $warningstring = '';
1065 if (preg_match('/development/i', $version)) {
1066 $warningstring = $langs->trans("Development");
1067 }
1068 if (preg_match('/experimental/i', $version)) {
1069 $warningstring = $langs->trans("Experimental");
1070 }
1071 if (preg_match('/deprecated/i', $version)) {
1072 $warningstring = $langs->trans("Deprecated");
1073 }
1074
1075 if ($objMod->isCoreOrExternalModule() == 'external' || preg_match('/development|experimental|deprecated/i', $version)) {
1076 $versiontrans .= $objMod->getVersion(1);
1077 }
1078
1079 if ($objMod->isCoreOrExternalModule() == 'external' && getDolGlobalString($const_name) && ($action == 'checklastversion' || getDolGlobalString('CHECKLASTVERSION_EXTERNALMODULE'))) {
1080 // Check is done only for activated modules.
1081 // Setting CHECKLASTVERSION_EXTERNALMODULE to on is a bad practice to activate a check on an external access during the building of the admin page.
1082 // 1 external module can hang the application.
1083 // Adding a cron job could be a good idea: see DolibarrModules::checkForUpdate()
1084 $checkRes = $objMod->checkForUpdate();
1085 if ($checkRes > 0) {
1086 setEventMessages($objMod->getName().' : '.preg_replace('/[^a-z0-9_\.\-\s]/i', '', $versiontrans).' -> '.preg_replace('/[^a-z0-9_\.\-\s]/i', '', $objMod->lastVersion), null, 'warnings');
1087 } elseif ($checkRes < 0) {
1088 $langs->load("errors");
1089 setEventMessages($objMod->getName().' '.$langs->trans('CheckVersionFail'), null, 'errors');
1090 }
1091 }
1092
1093 if ($objMod->isCoreOrExternalModule() == 'external' && getDolGlobalString($const_name) && $action == 'checklastversion' && !getDolGlobalString('DISABLE_CHECK_ON_MALWARE_MODULES')) {
1094 $checkRes = $objMod->checkForCompliance(); // Check if module is reported as non compliant with Dolibarr rules and law
1095 if (!is_numeric($checkRes) && $checkRes != '') {
1096 $langs->load("errors");
1097 setEventMessages($objMod->getName().' : '.$langs->trans($checkRes), null, 'errors');
1098 }
1099 }
1100
1101 // Define imginfo
1102 $imginfo = "info";
1103 if ($objMod->isCoreOrExternalModule() == 'external') {
1104 $imginfo = "info_black";
1105 }
1106
1107 $codeenabledisable = '';
1108 $codetoconfig = '';
1109
1110 // Force disable of module disabled into session (for demo for example)
1111 if (in_array($modulenameshort, $disabled_modules)) {
1112 $objMod->disabled = true;
1113 }
1114
1115 // Activate/Disable and Setup (2 columns)
1116 if (getDolGlobalString($const_name)) { // If module is already activated
1117 // Set $codeenabledisable
1118 $disableSetup = 0;
1119 if (!empty($arrayofwarnings[$modName])) {
1120 $codeenabledisable .= '<!-- This module has a warning to show when we activate it (note: your country is '.$mysoc->country_code.') -->'."\n";
1121 }
1122
1123 if (!empty($objMod->disabled)) {
1124 $codeenabledisable .= $langs->trans("Disabled");
1125 } elseif (is_object($objMod)
1126 && (!empty($objMod->always_enabled) || ((isModEnabled('multicompany') && $objMod->core_enabled) && ($user->entity || $conf->entity != 1)))) {
1127 // @phan-suppress-next-line PhanUndeclaredMethod
1128 if (method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) {
1129 $codeenabledisable .= $langs->trans("Used");
1130 } else {
1131 $codeenabledisable .= img_picto($langs->trans("Required"), 'switch_on', '', 0, 0, 0, '', 'opacitymedium valignmiddle');
1132 //print $langs->trans("Required");
1133 }
1134 if (isModEnabled('multicompany') && $user->entity) {
1135 $disableSetup++;
1136 }
1137 } else {
1138 // @phan-suppress-next-line PhanUndeclaredMethod
1139 if (is_object($objMod) && !empty($objMod->warnings_unactivation[$mysoc->country_code]) && method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) {
1140 $codeenabledisable .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?id='.((int) $objMod->numero).'&token='.newToken().'&module_position='.$module_position.'&action=reset_confirm&confirm_message_code='.urlencode($objMod->warnings_unactivation[$mysoc->country_code]).'&value='.urlencode($modName).'&mode='.urlencode($mode).$param.'">';
1141 $codeenabledisable .= img_picto($langs->trans("Activated").($warningstring ? ' '.$warningstring : ''), 'switch_on');
1142 $codeenabledisable .= '</a>';
1143 if (getDolGlobalInt("MAIN_FEATURES_LEVEL") > 1) {
1144 $codeenabledisable .= '&nbsp;';
1145 $codeenabledisable .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.((int) $objMod->numero).'&token='.newToken().'&module_position='.$module_position.'&action=reload_confirm&value='.urlencode($modName).'&mode='.urlencode($mode).'&confirm=yes'.$param.'">';
1146 $codeenabledisable .= img_picto($langs->trans("Reload"), 'refresh', 'class="opacitymedium"');
1147 $codeenabledisable .= '</a>';
1148 }
1149 } else {
1150 // Check if some enabled modules depend on this one (requiredby). If yes, we show a confirmation popup before disabling.
1151 $warningmessagefordisable = '';
1152 if (is_array($objMod->requiredby) && count($objMod->requiredby) > 0) {
1153 $listofdependentmodules = array();
1154 foreach ($objMod->requiredby as $moduledisableclass) {
1155 if (empty($moduledisableclass)) {
1156 continue;
1157 }
1158 $moduleshortname = strtolower(preg_replace('/^mod/i', '', $moduledisableclass));
1159 if (in_array($moduleshortname, $conf->modules)) {
1160 $listofdependentmodules[] = isset($modules[$moduledisableclass]) ? $modules[$moduledisableclass]->getName() : $moduleshortname;
1161 }
1162 }
1163 if (count($listofdependentmodules) > 0) {
1164 $warningmessagefordisable = $langs->trans('ConfirmDisablingModuleWillDisableDependentModules', implode(', ', $listofdependentmodules));
1165 }
1166 }
1167
1168 $codeenabledisable .= '<a class="reposition valignmiddle" id="iddisable'.$objMod->numero.'" data-alreadyclicked="0" href="'.$_SERVER["PHP_SELF"].'?id='.((int) $objMod->numero).'&token='.newToken().'&module_position='.$module_position.'&action=reset&value='.urlencode($modName).'&mode='.urlencode($mode).'&confirm=yes'.$param.'"';
1169 if ($warningmessagefordisable) {
1170 $codeenabledisable .= ' onclick="return confirmDolibarr(\''.dol_escape_js($warningmessagefordisable).'\', \'iddisable'.$objMod->numero.'\', 600, 300, 0);"';
1171 }
1172 $codeenabledisable .= '>';
1173 $codeenabledisable .= img_picto($langs->trans("Activated").($warningstring ? ' '.$warningstring : ''), 'switch_on');
1174 $codeenabledisable .= '</a>';
1175 if (getDolGlobalInt("MAIN_FEATURES_LEVEL") > 1) {
1176 $codeenabledisable .= '&nbsp;';
1177 $codeenabledisable .= '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.((int) $objMod->numero).'&token='.newToken().'&module_position='.$module_position.'&action=reload&value='.urlencode($modName).'&mode='.urlencode($mode).'&confirm=yes'.$param.'">';
1178 $codeenabledisable .= img_picto($langs->trans("Reload"), 'refresh', 'class="opacitymedium"');
1179 $codeenabledisable .= '</a>';
1180 }
1181 }
1182 }
1183
1184 // Set $codetoconfig
1185 if (!empty($objMod->config_page_url) && !$disableSetup) {
1186 $backtourlquery = [];
1187 if ($search_keyword != '') {
1188 $backtourlquery += ['search_keyword' => $search_keyword]; // No urlencode here, done later
1189 }
1190 if ($search_nature > -1) {
1191 $backtourlquery += ['search_nature' => $search_nature]; // No urlencode here, done later
1192 }
1193 if ($search_version > -1) {
1194 $backtourlquery += ['search_version' => $search_version]; // No urlencode here, done later
1195 }
1196 if ($search_status > -1) {
1197 $backtourlquery += ['search_status' => $search_status]; // No urlencode here, done later
1198 }
1199 $backtourl = dolBuildUrl($_SERVER["PHP_SELF"], $backtourlquery);
1200
1201 $regs = array();
1202 $query = [
1203 'save_lastsearch_values' => 1,
1204 'backtopage' => $backtourl,
1205 ];
1206 if (is_array($objMod->config_page_url)) {
1207 $i = 0;
1208 foreach ($objMod->config_page_url as $page) {
1209 $urlpage = $page;
1210 if ($i++) {
1211 $codetoconfig .= '<a href="'.$urlpage.'" title="'.$langs->trans($page).'">'.img_picto(ucfirst($page), "setup").'</a>';
1212 // print '<a href="'.$page.'">'.ucfirst($page).'</a>&nbsp;';
1213 } else {
1214 if (preg_match('/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) {
1215 $urltouse = dol_buildpath('/'.$regs[2].'/admin/'.$regs[1], 1);
1216 $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>';
1217 } else {
1218 $urltouse = $urlpage;
1219 $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>';
1220 }
1221 }
1222 }
1223 } elseif (preg_match('/^([^@]+)@([^@]+)$/i', (string) $objMod->config_page_url, $regs)) {
1224 $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>';
1225 } else {
1226 $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>';
1227 }
1228 } else {
1229 $codetoconfig .= img_picto($langs->trans("NothingToSetup"), "setup", 'class="opacitytransp" style="padding-right: 6px"', 0, 0, 0, '', 'fa-15');
1230 }
1231 } else { // Module not yet activated
1232 // Set $codeenabledisable
1233 if (!empty($objMod->always_enabled)) {
1234 // A 'always_enabled' module should not never be disabled. If this happen, we keep a link to re-enable it.
1235 $codeenabledisable .= '<!-- Message to show: an always_enabled module has been disabled -->'."\n";
1236 $codeenabledisable .= '<a class="reposition" id="idalways'.$objMod->numero.'" data-alreadyclicked="0" href="'.$_SERVER["PHP_SELF"].'?id='.$objMod->numero.'&token='.newToken().'&module_position='.$module_position.'&action=set&token='.newToken().'&value='.$modName.'&mode='.$mode.$param.'"';
1237 $codeenabledisable .= '>';
1238 $codeenabledisable .= img_picto($langs->trans("Disabled"), 'switch_off');
1239 $codeenabledisable .= "</a>\n";
1240 } elseif (!empty($objMod->disabled)) {
1241 $codeenabledisable .= $langs->trans("Disabled");
1242 } else {
1243 // Module qualified for activation
1244 $warningmessage = '';
1245 $disableCancel = 0;
1246
1247 if (!empty($arrayofwarnings[$modName])) {
1248 $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";
1249 foreach ($arrayofwarnings[$modName] as $keycountry => $cursorwarningmessage) {
1250 if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry))) {
1251 if (!is_array($cursorwarningmessage)) {
1252 $cursorwarningmessage = array($cursorwarningmessage);
1253 }
1254 foreach ($cursorwarningmessage as $messagetoshow) {
1255 if (preg_match('/:1$/', $messagetoshow)) {
1256 $disableCancel = 1;
1257 }
1258 $messagetoshow = preg_replace('/:1$/', '', $messagetoshow);
1259
1260 // TODO Use a replacement instead of always adding the module name and the country code to the string message ?
1261 $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($messagetoshow, $objMod->getName(), $mysoc->country_code);
1262 }
1263 }
1264 }
1265 }
1266 if ($objMod->isCoreOrExternalModule() == 'external' && !empty($arrayofwarningsext)) {
1267 $codeenabledisable .= '<!-- This module is an external module and it may have a warning to show (note: your country is '.$mysoc->country_code.') -->'."\n";
1268 foreach ($arrayofwarningsext as $keymodule => $arrayofwarningsextbycountry) {
1269 $keymodulelowercase = strtolower(preg_replace('/^mod/', '', $keymodule));
1270 if (preg_match('/^always/', $keymodulelowercase) || in_array($keymodulelowercase, $conf->modules)) { // If module that trigger the warning is on
1271 foreach ($arrayofwarningsextbycountry as $keycountry => $cursorwarningmessage) {
1272 if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry))) {
1273 if (!is_array($cursorwarningmessage)) {
1274 $cursorwarningmessage = array($cursorwarningmessage);
1275 }
1276 foreach ($cursorwarningmessage as $messagetoshow) {
1277 // TODO Use replacement instead of always adding param module name to enable and country code to the string message and triggering module
1278 $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($messagetoshow, $objMod->getName(), $mysoc->country_code, $modules[$keymodule]->getName());
1279 }
1280 $warningmessage .= ($warningmessage ? "\n" : "").($warningmessage ? "\n" : "").$langs->trans("Module").' : '.$objMod->getName();
1281 if (!empty($objMod->editor_name)) {
1282 $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans("Publisher").' : '.$objMod->editor_name;
1283 }
1284 if ($keymodulelowercase != 'always') {
1285 $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans("ModuleTriggeringThisWarning").' : '.$modules[$keymodule]->getName();
1286 }
1287 }
1288 }
1289 }
1290 }
1291 }
1292
1293 $urltogo = $_SERVER["PHP_SELF"].'?id='.$objMod->numero.'&token='.newToken().'&module_position='.$module_position.'&action=set&token='.newToken().'&value='.$modName.'&mode='.$mode.$param;
1294 $popupWidth = 600;
1295 $popupHeight = 300;
1296 $codeenabledisable .= '<!-- Message to show: '.$warningmessage.' -->'."\n";
1297 $codeenabledisable .= '<a class="reposition" id="idqualified'.$objMod->numero.'" data-alreadyclicked="0" href="'.$urltogo.'"';
1298 if ($warningmessage) {
1299 $codeenabledisable .= ' onclick="return confirmDolibarr(\''.dol_escape_js($warningmessage).'\', \'idqualified'.$objMod->numero.'\', '.$popupWidth.', '.$popupHeight.','.$disableCancel.');"';
1300 }
1301 $codeenabledisable .= '>';
1302 $codeenabledisable .= img_picto($langs->trans("Disabled"), 'switch_off');
1303 $codeenabledisable .= "</a>\n";
1304 }
1305
1306 // Set $codetoconfig
1307 $codetoconfig .= img_picto($langs->trans("NothingToSetup"), "setup", 'class="opacitytransp" style="padding-right: 6px"');
1308 }
1309
1310 if ($mode == 'commonkanban') {
1311 // Output Kanban
1312 print $objMod->getKanbanView($codeenabledisable, $codetoconfig);
1313 } else {
1314 print '<tr class="oddeven'.($warningstring ? ' info-box-content-warning' : '').'">'."\n";
1315 if (getDolGlobalString('MAIN_MODULES_SHOW_LINENUMBERS')) {
1316 print '<td class="width50">'.$linenum.'</td>';
1317 }
1318
1319 // Picto + Name of module
1320 print ' <td class="tdoverflowmax200 minwidth200imp" title="'.dol_escape_htmltag($objMod->getName()).'">';
1321 $alttext = '';
1322 //if (is_array($objMod->need_dolibarr_version)) $alttext.=($alttext?' - ':'').'Dolibarr >= '.join('.',$objMod->need_dolibarr_version);
1323 //if (is_array($objMod->phpmin)) $alttext.=($alttext?' - ':'').'PHP >= '.join('.',$objMod->phpmin);
1324 if (!empty($objMod->picto)) {
1325 if (preg_match('/^\//i', $objMod->picto)) {
1326 print img_picto($alttext, $objMod->picto, 'class="valignmiddle pictomodule paddingrightonly"', 1);
1327 } else {
1328 print img_object($alttext, $objMod->picto, 'class="valignmiddle pictomodule paddingrightonly"');
1329 }
1330 } else {
1331 print img_object($alttext, 'generic', 'class="valignmiddle paddingrightonly"');
1332 }
1333 print ' <span class="valignmiddle">'.$objMod->getName().'</span>';
1334 print "</td>\n";
1335
1336 // Desc
1337 print '<td class="valignmiddle tdoverflowmax300 minwidth200imp opacitylow">';
1338 print nl2br($objMod->getDesc());
1339 print "</td>\n";
1340
1341 // Help
1342 print '<td class="center nowrap" style="width: 82px;">';
1343 print '<a href="javascript:document_preview(\''.DOL_URL_ROOT.'/admin/modulehelp.php?id='.((int) $objMod->numero).'\',\'text/html\',\''.dol_escape_js($langs->trans("Module")).'\')">';
1344 print img_picto(($objMod->isCoreOrExternalModule() == 'external' ? $langs->trans("ExternalModule").' - ' : '').$langs->trans("ClickToShowDescription"), $imginfo, '', 0, 0, 0, '', 'purple');
1345 print '</a>';
1346 print($timestoinit[$modName] > 500 ? img_picto($langs->trans('InitModuleIsSlow'), 'fa-exclamation-circle') : '');
1347 print '</td>';
1348
1349 // Version
1350 print '<td class="center nowrap width150" title="'.dol_escape_htmltag(dol_string_nohtmltag($versiontrans)).'">';
1351 if ($objMod->needUpdate) {
1352 $versionTitle = $langs->trans('ModuleUpdateAvailable').' : '.$objMod->lastVersion;
1353 print '<span class="badge badge-warning classfortooltip" title="'.dol_escape_htmltag($versionTitle).'">'.$versiontrans.'</span>';
1354 } else {
1355 print $versiontrans;
1356 }
1357 print "</td>\n";
1358
1359 // Link enable/disable
1360 print '<td class="center valignmiddle left nowraponall" width="60px">';
1361 print $codeenabledisable;
1362 print "</td>\n";
1363
1364 // Link config
1365 print '<td class="tdsetuppicto right valignmiddle" width="60px">';
1366 print $codetoconfig;
1367 print '</td>';
1368
1369 print "</tr>\n";
1370 }
1371 if ($objMod->needUpdate) {
1372 $foundoneexternalmodulewithupdate++;
1373 }
1374 }
1375
1376 if ($action == 'checklastversion') {
1377 if ($foundoneexternalmodulewithupdate) {
1378 setEventMessages($langs->trans("ModuleUpdateAvailable"), null, 'warnings', '', 0, 1);
1379 } else {
1380 setEventMessages($langs->trans("NoExternalModuleWithUpdate"), null, 'mesgs');
1381 }
1382 }
1383
1384 if ($oldfamily) {
1385 if ($mode == 'commonkanban') {
1386 print '</div>';
1387 } else {
1388 print "</table>\n";
1389 print '</div>';
1390 }
1391 }
1392
1393 if (!$atleastonequalified) {
1394 print '<br><span class="opacitymedium">'.$langs->trans("NoDeployedModulesFoundWithThisSearchCriteria").'</span><br><br>';
1395 }
1396
1397 print dol_get_fiche_end();
1398
1399 print '<br>';
1400
1401 // Show warning about external users
1402 print info_admin(showModulesExludedForExternal($modules))."\n";
1403
1404 print '</form>';
1405}
1406
1407if ($mode == 'marketplace') {
1408 print dol_get_fiche_head($head, $mode, '', -1);
1409
1410 print $deschelp;
1411
1412 print '<br>';
1413
1414 print '<!-- summary of sources -->';
1415
1416 // Marketplace and community modules
1417 print '<div class="div-table-responsive-no-min">';
1418 print '<table summary="list_of_modules" class="noborder centpercent">'."\n";
1419 print '<tr class="liste_titre">'."\n";
1420 print '<td colspan="2">'.$form->textwithpicto($langs->trans("ModuleProviderSites"), $langs->trans("WebSiteDesc")).'</td>';
1421 print '<td class="hideonsmartphone">';
1422 print '</td>';
1423 print '<td></td>';
1424 print '</tr>';
1425
1426
1427 // Source Community github
1428 $url = 'https://github.com/Dolibarr/dolibarr-community-modules';
1429
1430 print '<tr class="oddeven nohover" height="100">'."\n";
1431 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>';
1432 print '<td class="minwidth500imp smallonsmartphone"><span class="opacitymedium">'.$langs->trans("CommunityModulesDesc").'</span><br>';
1433 print img_picto('', 'url', 'class="pictofixedwidth"').'<a href="'.$url.'" target="_blank" rel="noopener noreferrer external">'.$url.'</a></td>';
1434 print '<td>';
1435 print ajax_constantonoff('MAIN_ENABLE_EXTERNALMODULES_COMMUNITY', array(), null, 0, 0, 1);
1436 print '</td>';
1437 print '<td class="center">';
1438 if (!getDolGlobalString('MAIN_DISABLE_EXTERNALMODULES_COMMUNITY') && getDolGlobalInt('MAIN_ENABLE_EXTERNALMODULES_COMMUNITY')) {
1439 $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;
1440 $messagetoadd .= ' (Date: '.dol_print_date(dol_filemtime($remotestore->cache_file), 'dayhour', 'tzuserrel').')</span>';
1441 if ($remotestore->githubFileError) {
1442 $messagetoadd .= '<br><span class="error small">'.$remotestore->githubFileError.'</span>';
1443 }
1444 print $remotestore->libStatus($remotestore->githubFileStatus, 2, $messagetoadd);
1445 }
1446 print '</td>';
1447 print '</tr>';
1448
1449
1450 // Sources additional github repositories (defined by MAIN_ADD_EXTERNAL_MODULES_SOURCE)
1451 foreach ($remotestore->custom_sources as $customsource) {
1452 $url = $customsource['url'];
1453
1454 print '<tr class="oddeven nohover" height="100">'."\n";
1455 print '<td class="hideonsmartphone center width150 nopaddingleftimp nopaddingrightimp"><a href="'.dol_escape_htmltag($url).'" target="_blank" rel="noopener noreferrer external">'.img_picto('', 'fa-code-branch', 'class="size2x"').'</a></td>';
1456 print '<td class="minwidth500imp smallonsmartphone"><span class="opacitymedium">'.$langs->trans("AdditionalModulesSourceDesc").'</span><br>';
1457 print img_picto('', 'url', 'class="pictofixedwidth"').'<a href="'.dol_escape_htmltag($url).'" target="_blank" rel="noopener noreferrer external">'.dol_escape_htmltag($url).'</a>';
1458 if ($customsource['branch']) {
1459 print '<!-- &nbsp; '.img_picto($langs->trans("Branch"), 'fa-code-branch', 'class="pictofixedwidth"').dol_escape_htmltag($customsource['branch']).' -->';
1460 }
1461 print '</td>';
1462 print '<td>';
1463 print ajax_constantonoff($customsource['const_enable'], array(), null, 0, 0, 1);
1464 print '</td>';
1465 print '<td class="center">';
1466 if (getDolGlobalInt($customsource['const_enable'])) {
1467 $messagetoadd = '';
1468 if ($customsource['file_source_url']) {
1469 $messagetoadd = '<br><br><span class="small">Content of the repository index file '.dol_escape_htmltag($customsource['file_source_url']).' should be in the local cache file '.$customsource['cache_file'];
1470 $messagetoadd .= ' (Date: '.dol_print_date(dol_filemtime($customsource['cache_file']), 'dayhour', 'tzuserrel').')</span>';
1471 }
1472 if ($customsource['error']) {
1473 $messagetoadd .= '<br><span class="error small">'.dol_escape_htmltag($customsource['error']).'</span>';
1474 }
1475 print $remotestore->libStatus($customsource['status'], 2, $messagetoadd);
1476 }
1477 print '</td>';
1478 print '</tr>';
1479 }
1480
1481
1482 // Source Marketplace DoliStore
1483 $url = 'https://www.dolistore.com';
1484
1485 print '<tr class="oddeven nohover" height="100">'."\n";
1486 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>';
1487 print '<td class="minwidth500imp smallonsmartphone"><span class="opacitymedium">'.$langs->trans("DoliStoreDesc").'</span><br>';
1488 print img_picto('', 'url', 'class="pictofixedwidth"').'<a href="'.$url.'" target="_blank" rel="noopener noreferrer external">'.$url.'</a></td>';
1489 print '<td>';
1490 print ajax_constantonoff('MAIN_ENABLE_EXTERNALMODULES_DOLISTORE', array(), null, 0, 0, 1);
1491 print '</td>';
1492 print '<td class="center">';
1493 if (!getDolGlobalString('MAIN_DISABLE_EXTERNALMODULES_DOLISTORE') && getDolGlobalInt('MAIN_ENABLE_EXTERNALMODULES_DOLISTORE')) {
1494 $messagetoadd = '<br><span class="small">';
1495 if ($remotestore->dolistoreApiStatus <= 0) {
1496 $messagetoadd = '<br>'.$remotestore->dolistoreApiError.'<br>Failed to get answer of remote API server<br>';
1497 }
1498
1499 $messagetoadd .= '<br>Using Shop address MAIN_MODULE_DOLISTORE_SHOP_URL = '.$remotestore->shop_url;
1500 $messagetoadd .= '<br>Using Remote API address MAIN_MODULE_DOLISTORE_API_URL = '.$remotestore->dolistore_api_url;
1501 $messagetoadd .= '<br>Using API public key MAIN_MODULE_DOLISTORE_API_KEY = '.$remotestore->dolistore_api_key;
1502 // Add basic auth if needed
1503 $basicAuthLogin = getDolGlobalString('MAIN_MODULE_DOLISTORE_BASIC_LOGIN');
1504 $basicAuthPassword = getDolGlobalString('MAIN_MODULE_DOLISTORE_BASIC_PASSWORD');
1505 if ($basicAuthLogin) {
1506 $messagetoadd .= '<br>Using basic auth login: base64('.$basicAuthLogin.':'.$basicAuthPassword.')';
1507 }
1508 $messagetoadd .= '</span>';
1509
1510 print $remotestore->libStatus($remotestore->dolistoreApiStatus, 2, $messagetoadd);
1511 }
1512 print '</td>';
1513 print '</tr>';
1514
1515 print "</table>\n";
1516 print '</div>';
1517
1518 print dol_get_fiche_end();
1519
1520 print '<br>';
1521
1522 if ($remotestore->numberOfProviders > 0) {
1523 // $options is array with filter criteria
1524 $nbmaxtoshow = $options['per_page'];
1525 $options['per_page']++;
1526
1527 //$remotestore->getRemoteCategories();
1528 //$remotestore->getRemoteProducts($options);
1529
1530 //print '<span class="opacitymedium hideonsmartphone">'.$langs->trans('DOLISTOREdescriptionLong').'</span><br><br>';
1531
1532 $categories_tree = $remotestore->getCategories($options['categorie']); // Call API to get the categories
1533
1534 $products_list = $remotestore->getProducts($options, $modules); // Get list of product from all sources
1535
1536 $previouslink = $remotestore->get_previous_link();
1537
1538 $nextlink = $remotestore->get_next_link();
1539
1540
1541 print '<div class="liste_titre liste_titre_bydiv centpercent"><div class="">';
1542
1543 print '<form method="POST" class="centpercent" id="searchFormList" action="'.$remotestore->url.'" spellcheck="false">'; ?>
1544 <input type="hidden" name="token" value="<?php echo newToken(); ?>">
1545 <input type="hidden" name="mode" value="marketplace">
1546 <input type="hidden" name="page_y" value="">
1547 <div class="divsearchfield">
1548 <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">
1549 </div>
1550 <div class="divsearchfield">
1551 <input name="buttonsubmit" class="button buttongen reposition" value="<?php echo $langs->trans('Search') ?>" type="submit">
1552 <?php
1553 if ($search_keyword !== '') {
1554 print '<a class="buttonreset reposition" href="'.$_SERVER["PHP_SELF"].'?mode=marketplace">'.$langs->trans('Reset').'</a>';
1555 } else {
1556 print $form->textwithpicto('', $langs->trans('DOLISTOREdescriptionLong'));
1557 }
1558 ?>
1559 &nbsp;
1560 </div>
1561 <?php
1562 $totalnboflines = '<span class="product-count opacitymedium paddingleft">';
1563 $totalnboflines .= $langs->trans("itemFound", $remotestore->numberTotalOfProducts);
1564 $totalnboflines .= '</span>';
1565
1566 print $totalnboflines;
1567 print $remotestore->getPagination();
1568 print '</form>';
1569
1570 print '</div>';
1571 print '<div class="clearboth"></div>';
1572 print '</div>';
1573 ?>
1574 <?php if (!empty($categories_tree)) { ?>
1575 <div id="category-tree-left" class="paddingtop">
1576 <ul class="tree">
1577 <?php
1578 print $categories_tree; ?>
1579 </ul>
1580 </div>
1581 <?php } ?>
1582
1583 <div id="listing-content" class="div-table-responsive" <?php if (empty($categories_tree)) { ?>style="width:100%;"<?php } ?>>
1584 <table summary="list_of_modules" id="list_of_modules" class="productlist centpercent">
1585 <tbody id="listOfModules">
1586 <!-- $product_list is $remotestore->getProducts($options) done previously -->
1587 <?php print $products_list; ?>
1588 </tbody>
1589 </table>
1590 </div>
1591 <div style="clear: both;"></div>
1592 <div><?php print $remotestore->getPagination(); ?></div>
1593 <?php
1594 }
1595}
1596
1597
1598// Form to install an external module
1599
1600if ($mode == 'deploy') {
1601 print dol_get_fiche_head($head, $mode, '', -1);
1602
1603 $fullurl = '<a href="'.$urldolibarrmodules.'" target="_blank" rel="noopener noreferrer">'.$urldolibarrmodules.'</a>';
1604 $message = '';
1605 if ($allowonlineinstall) {
1606 if (!in_array('/custom', explode(',', $dolibarr_main_url_root_alt))) {
1607 $message = info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT));
1608 $allowfromweb = -1;
1609 } else {
1610 if ($dirins_ok) {
1611 if (!is_writable(dol_osencode($dirins))) {
1612 $langs->load("errors");
1613 $message = info_admin($langs->trans("ErrorFailedToWriteInDir", $dirins), 0, 0, '1', 'warning');
1614 $allowfromweb = 0;
1615 }
1616 } else {
1617 $message = info_admin($langs->trans("NotExistsDirect", $dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample"));
1618 $allowfromweb = 0;
1619 }
1620 }
1621 } else {
1622 if (getDolGlobalString('MAIN_MESSAGE_INSTALL_MODULES_DISABLED_CONTACT_US')) {
1623 // Show clean message
1624 if (!is_numeric(getDolGlobalString('MAIN_MESSAGE_INSTALL_MODULES_DISABLED_CONTACT_US'))) {
1625 $message = info_admin($langs->trans(getDolGlobalString('MAIN_MESSAGE_INSTALL_MODULES_DISABLED_CONTACT_US')), 0, 0, 'warning');
1626 } else {
1627 $message = info_admin($langs->trans('InstallModuleFromWebHasBeenDisabledContactUs'), 0, 0, 'warning');
1628 }
1629 } else {
1630 // Show technical message
1631 $message = info_admin($langs->trans("InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.'/installmodules.lock'), 0, 0, 'warning');
1632 }
1633 $allowfromweb = 0;
1634 }
1635
1636 print $deschelp;
1637
1638 if ($allowfromweb < 1) {
1639 print $langs->trans("SomethingMakeInstallFromWebNotPossible");
1640 print $message;
1641 //print $langs->trans("SomethingMakeInstallFromWebNotPossible2");
1642 print '<br>';
1643 }
1644
1645 // $allowfromweb = -1 if installation or setup not correct, 0 if not allowed, 1 if allowed
1646 if ($allowfromweb >= 0) {
1647 if ($allowfromweb == 1) {
1648 //print $langs->trans("ThisIsProcessToFollow").'<br>';
1649 } else {
1650 print '<br>';
1651
1652 print $langs->trans("ThisIsAlternativeProcessToFollow").'<br>';
1653 print '<b>'.$langs->trans("StepNb", 1).'</b>: ';
1654 print str_replace('{s1}', $fullurl, $langs->trans("FindPackageFromWebSite", '{s1}')).'<br>';
1655 print '<b>'.$langs->trans("StepNb", 2).'</b>: ';
1656 print str_replace('{s1}', $fullurl, $langs->trans("DownloadPackageFromWebSite", '{s1}')).'<br>';
1657 print '<b>'.$langs->trans("StepNb", 3).'</b>: ';
1658 }
1659
1660 if ($allowfromweb == 1) {
1661 print '<form enctype="multipart/form-data" method="POST" class="noborder" action="'.$_SERVER["PHP_SELF"].'" name="forminstall" spellcheck="false">';
1662 print '<input type="hidden" name="token" value="'.newToken().'">';
1663 print '<input type="hidden" name="action" value="install">';
1664 print '<input type="hidden" name="mode" value="deploy">';
1665
1666 print $langs->trans("YouCanSubmitFile").'<br><br><br>';
1667
1668 print '<span class="opacitymedium"><input class="paddingright" type="checkbox" name="checkforcompliance" id="checkforcompliance"'.(getDolGlobalString('DISABLE_CHECK_ON_MALWARE_MODULES') ? ' disabled="disabled"' : 'checked="checked"').'>';
1669 print '<label for="checkforcompliance">'.$form->textwithpicto($langs->trans("CheckIfModuleIsNotBlackListed"), $langs->trans("CheckIfModuleIsNotBlackListedHelp").'<br><br>'.DolibarrModules::URL_FOR_BLACKLISTED_MODULES).'</label>';
1670 print '</span><br><br>';
1671
1672 $max = getDolGlobalString('MAIN_UPLOAD_DOC'); // In Kb
1673 $maxphp = @ini_get('upload_max_filesize'); // In unknown
1674 if (preg_match('/k$/i', $maxphp)) {
1675 $maxphp = preg_replace('/k$/i', '', $maxphp);
1676 $maxphp *= 1;
1677 }
1678 if (preg_match('/m$/i', $maxphp)) {
1679 $maxphp = preg_replace('/m$/i', '', $maxphp);
1680 $maxphp *= 1024;
1681 }
1682 if (preg_match('/g$/i', $maxphp)) {
1683 $maxphp = preg_replace('/g$/i', '', $maxphp);
1684 $maxphp *= 1024 * 1024;
1685 }
1686 if (preg_match('/t$/i', $maxphp)) {
1687 $maxphp = preg_replace('/t$/i', '', $maxphp);
1688 $maxphp *= 1024 * 1024 * 1024;
1689 }
1690 $maxphp2 = @ini_get('post_max_size'); // In unknown
1691 if (preg_match('/k$/i', $maxphp2)) {
1692 $maxphp2 = preg_replace('/k$/i', '', $maxphp2);
1693 $maxphp2 *= 1;
1694 }
1695 if (preg_match('/m$/i', $maxphp2)) {
1696 $maxphp2 = preg_replace('/m$/i', '', $maxphp2);
1697 $maxphp2 *= 1024;
1698 }
1699 if (preg_match('/g$/i', $maxphp2)) {
1700 $maxphp2 = preg_replace('/g$/i', '', $maxphp2);
1701 $maxphp2 *= 1024 * 1024;
1702 }
1703 if (preg_match('/t$/i', $maxphp2)) {
1704 $maxphp2 = preg_replace('/t$/i', '', $maxphp2);
1705 $maxphp2 *= 1024 * 1024 * 1024;
1706 }
1707 // Now $max and $maxphp and $maxphp2 are in Kb
1708 $maxmin = $max;
1709 $maxphptoshow = $maxphptoshowparam = '';
1710 if ($maxphp > 0) {
1711 $maxmin = min($max, $maxphp);
1712 $maxphptoshow = $maxphp;
1713 $maxphptoshowparam = 'upload_max_filesize';
1714 }
1715 if ($maxphp2 > 0) {
1716 $maxmin = min($max, $maxphp2);
1717 if ($maxphp2 < $maxphp) {
1718 $maxphptoshow = $maxphp2;
1719 $maxphptoshowparam = 'post_max_size';
1720 }
1721 }
1722
1723 if ($maxmin > 0) {
1724 $langs->load("errors");
1725 print '<script type="text/javascript">
1726 $(document).ready(function() {
1727 jQuery("#fileinstall").on("change", function() {
1728 if(this.files[0].size > '.($maxmin * 1024).') {
1729 alert(\''.dol_escape_js($langs->transnoentitiesnoconv("ErrorFileSizeTooLarge")).'\');
1730 this.value = "";
1731 }
1732 });
1733 });
1734 </script>'."\n";
1735 // MAX_FILE_SIZE must come before the file input field
1736 print '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">';
1737 }
1738
1739 print '<input class="flat minwidth400" type="file" name="fileinstall" id="fileinstall">';
1740
1741 print '<input type="submit" name="send" value="'.dol_escape_htmltag($langs->trans("Upload")).'" class="button small">';
1742
1743 if (getDolGlobalString('MAIN_UPLOAD_DOC')) {
1744 if ($user->admin) {
1745 $langs->load('other');
1746 print ' ';
1747 print info_admin($langs->trans("ThisLimitIsDefinedInSetup", $max, $maxphptoshow, $maxphptoshowparam), 1);
1748 }
1749 } else {
1750 print ' ('.$langs->trans("UploadDisabled").')';
1751 }
1752
1753 print '</form>';
1754
1755 print '<br>';
1756 print '<br>';
1757
1758 print '<div class="center"><div class="logo_setup"></div></div>';
1759 } else {
1760 print $langs->trans("UnpackPackageInModulesRoot", $dirins).'<br>';
1761 print '<b>'.$langs->trans("StepNb", 4).'</b>: ';
1762 print $langs->trans("SetupIsReadyForUse", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentitiesnoconv("Home").' - '.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Modules")).'<br>';
1763 }
1764 }
1765
1766 print dol_get_fiche_end();
1767}
1768
1769if ($mode == 'develop') {
1770 print dol_get_fiche_head($head, $mode, '', -1);
1771
1772 print $deschelp;
1773
1774 print '<br>';
1775
1776 // Marketplace
1777 print '<div class="div-table-responsive-no-min">';
1778 print '<table summary="list_of_modules" class="noborder centpercent">'."\n";
1779 print '<tr class="liste_titre">'."\n";
1780 print '<td colspan="3">'.$langs->trans("DevelopYourModuleDesc").'</td>';
1781 print '</tr>';
1782
1783 print '<tr class="oddeven nohover" height="100">'."\n";
1784 print '<td class="center hideonsmartphone">';
1785 print '<div class="imgmaxheight50 logo_setup"></div>';
1786 print '</td>';
1787 print '<td class="minwidth500imp smallonsmartphone">'.$langs->trans("TryToUseTheModuleBuilder", $langs->transnoentitiesnoconv("ModuleBuilder")).'</td>';
1788 print '<td class="maxwidth300">';
1789 if (isModEnabled('modulebuilder')) {
1790 print $langs->trans("SeeTopRightMenu");
1791 } else {
1792 print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("ModuleBuilder")).'</span>';
1793 }
1794 print '</td>';
1795 print '</tr>';
1796
1797 print '<tr class="oddeven nohover" height="100">'."\n";
1798 $url = 'https://partners.dolibarr.org';
1799 print '<td class="center hideonsmartphone">';
1800 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>';
1801 print '</td>';
1802 print '<td class="minwidth500imp smallonsmartphone">'.$langs->trans("DoliPartnersDesc").'</td>';
1803 print '<td><a href="'.$url.'" target="_blank" rel="noopener noreferrer external">';
1804 print img_picto('', 'url', 'class="pictofixedwidth"');
1805 print $url.'</a></td>';
1806 print '</tr>';
1807
1808 print "</table>\n";
1809 print '</div>';
1810
1811 print dol_get_fiche_end();
1812}
1813
1814// End of page
1815llxFooter();
1816$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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).
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
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class DolibarrModules.
Events class.
Class ExternalModules.
Class to manage generation of HTML components Only common components must be here.
global $mysoc
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
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.
dol_now($mode='gmt')
Return date for now.
dol_strlen($string, $stringencoding='UTF-8', $binarycount=0)
Make a strlen call.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_sanitizePathName($str, $newstr='_', $unaccent=0, $allowdash=0)
Clean a string to use it as a path name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_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.
Definition html.lib.php:542
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.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_set_focus($selector, $nooutput=0)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Definition html.lib.php:183
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.
multi select button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
treeview li table
No Email.
a disabled