modules.php 57 KB

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