modules.php 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401
  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 (getDolGlobalString($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. // A 'always_enabled' module should not never be disabled. If this happen, we keep a link to reenable it.
  827. $codeenabledisable .= '<!-- Message to show: an always_enabled module has been disabled -->'."\n";
  828. $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.'"';
  829. $codeenabledisable .= '>';
  830. $codeenabledisable .= img_picto($langs->trans("Disabled"), 'switch_off');
  831. $codeenabledisable .= "</a>\n";
  832. } elseif (!empty($objMod->disabled)) {
  833. $codeenabledisable .= $langs->trans("Disabled");
  834. } else {
  835. // Module qualified for activation
  836. $warningmessage = '';
  837. if (!empty($arrayofwarnings[$modName])) {
  838. $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";
  839. foreach ($arrayofwarnings[$modName] as $keycountry => $cursorwarningmessage) {
  840. if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry))) {
  841. $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code);
  842. }
  843. }
  844. }
  845. if ($objMod->isCoreOrExternalModule() == 'external' && !empty($arrayofwarningsext)) {
  846. $codeenabledisable .= '<!-- This module is an external module and it may have a warning to show (note: your country is '.$mysoc->country_code.') -->'."\n";
  847. foreach ($arrayofwarningsext as $keymodule => $arrayofwarningsextbycountry) {
  848. $keymodulelowercase = strtolower(preg_replace('/^mod/', '', $keymodule));
  849. if (in_array($keymodulelowercase, $conf->modules)) { // If module that request warning is on
  850. foreach ($arrayofwarningsextbycountry as $keycountry => $cursorwarningmessage) {
  851. if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry))) {
  852. $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code, $modules[$keymodule]->getName());
  853. $warningmessage .= ($warningmessage ? "\n" : "").($warningmessage ? "\n" : "").$langs->trans("Module").' : '.$objMod->getName();
  854. if (!empty($objMod->editor_name)) {
  855. $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans("Publisher").' : '.$objMod->editor_name;
  856. }
  857. if (!empty($objMod->editor_name)) {
  858. $warningmessage .= ($warningmessage ? "\n" : "").$langs->trans("ModuleTriggeringThisWarning").' : '.$modules[$keymodule]->getName();
  859. }
  860. }
  861. }
  862. }
  863. }
  864. }
  865. $codeenabledisable .= '<!-- Message to show: '.$warningmessage.' -->'."\n";
  866. $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.'"';
  867. if ($warningmessage) {
  868. $codeenabledisable .= ' onclick="return confirm(\''.dol_escape_js($warningmessage).'\');"';
  869. }
  870. $codeenabledisable .= '>';
  871. $codeenabledisable .= img_picto($langs->trans("Disabled"), 'switch_off');
  872. $codeenabledisable .= "</a>\n";
  873. }
  874. // Set $codetoconfig
  875. $codetoconfig .= img_picto($langs->trans("NothingToSetup"), "setup", 'class="opacitytransp" style="padding-right: 6px"');
  876. }
  877. if ($mode == 'commonkanban') {
  878. // Output Kanban
  879. print $objMod->getKanbanView($codeenabledisable, $codetoconfig);
  880. } else {
  881. print '<tr class="oddeven'.($warningstring ? ' info-box-content-warning' : '').'">'."\n";
  882. if (getDolGlobalString('MAIN_MODULES_SHOW_LINENUMBERS')) {
  883. print '<td class="width50">'.$linenum.'</td>';
  884. }
  885. // Picto + Name of module
  886. print ' <td class="tdoverflowmax200 minwidth200imp" title="'.dol_escape_htmltag($objMod->getName()).'">';
  887. $alttext = '';
  888. //if (is_array($objMod->need_dolibarr_version)) $alttext.=($alttext?' - ':'').'Dolibarr >= '.join('.',$objMod->need_dolibarr_version);
  889. //if (is_array($objMod->phpmin)) $alttext.=($alttext?' - ':'').'PHP >= '.join('.',$objMod->phpmin);
  890. if (!empty($objMod->picto)) {
  891. if (preg_match('/^\//i', $objMod->picto)) {
  892. print img_picto($alttext, $objMod->picto, 'class="valignmiddle pictomodule paddingrightonly"', 1);
  893. } else {
  894. print img_object($alttext, $objMod->picto, 'class="valignmiddle pictomodule paddingrightonly"');
  895. }
  896. } else {
  897. print img_object($alttext, 'generic', 'class="valignmiddle paddingrightonly"');
  898. }
  899. print ' <span class="valignmiddle">'.$objMod->getName().'</span>';
  900. print "</td>\n";
  901. // Desc
  902. print '<td class="valignmiddle tdoverflowmax300 minwidth200imp">';
  903. print nl2br($objMod->getDesc());
  904. print "</td>\n";
  905. // Help
  906. print '<td class="center nowrap" style="width: 82px;">';
  907. //print $form->textwithpicto('', $text, 1, $imginfo, 'minheight20', 0, 2, 1);
  908. 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>';
  909. print '</td>';
  910. // Version
  911. print '<td class="center nowrap width150" title="'.dol_escape_htmltag(dol_string_nohtmltag($versiontrans)).'">';
  912. if ($objMod->needUpdate) {
  913. $versionTitle = $langs->trans('ModuleUpdateAvailable').' : '.$objMod->lastVersion;
  914. print '<span class="badge badge-warning classfortooltip" title="'.dol_escape_htmltag($versionTitle).'">'.$versiontrans.'</span>';
  915. } else {
  916. print $versiontrans;
  917. }
  918. print "</td>\n";
  919. // Link enable/disable
  920. print '<td class="center valignmiddle left nowraponall" width="60px">';
  921. print $codeenabledisable;
  922. print "</td>\n";
  923. // Link config
  924. print '<td class="tdsetuppicto right valignmiddle" width="60px">';
  925. print $codetoconfig;
  926. print '</td>';
  927. print "</tr>\n";
  928. }
  929. if ($objMod->needUpdate) {
  930. $foundoneexternalmodulewithupdate++;
  931. }
  932. }
  933. if ($action == 'checklastversion') {
  934. if ($foundoneexternalmodulewithupdate) {
  935. setEventMessages($langs->trans("ModuleUpdateAvailable"), null, 'mesgs');
  936. } else {
  937. setEventMessages($langs->trans("NoExternalModuleWithUpdate"), null, 'mesgs');
  938. }
  939. }
  940. if ($oldfamily) {
  941. if ($mode == 'commonkanban') {
  942. print '</div>';
  943. } else {
  944. print "</table>\n";
  945. print '</div>';
  946. }
  947. }
  948. if (!$atleastonequalified) {
  949. print '<br><span class="opacitymedium">'.$langs->trans("NoDeployedModulesFoundWithThisSearchCriteria").'</span><br><br>';
  950. }
  951. print dol_get_fiche_end();
  952. print '<br>';
  953. // Show warning about external users
  954. print info_admin(showModulesExludedForExternal($modules))."\n";
  955. print '</form>';
  956. }
  957. if ($mode == 'marketplace') {
  958. print dol_get_fiche_head($head, $mode, '', -1);
  959. print $deschelp;
  960. print '<br>';
  961. // Marketplace
  962. print '<div class="div-table-responsive-no-min">';
  963. print '<table summary="list_of_modules" class="noborder centpercent">'."\n";
  964. print '<tr class="liste_titre">'."\n";
  965. print '<td class="hideonsmartphone">'.$form->textwithpicto($langs->trans("Provider"), $langs->trans("WebSiteDesc")).'</td>';
  966. print '<td></td>';
  967. print '<td>'.$langs->trans("URL").'</td>';
  968. print '</tr>';
  969. print '<tr class="oddeven">'."\n";
  970. $url = 'https://www.dolistore.com';
  971. 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>';
  972. print '<td><span class="opacitymedium">'.$langs->trans("DoliStoreDesc").'</span></td>';
  973. print '<td><a href="'.$url.'" target="_blank" rel="noopener noreferrer external">'.$url.'</a></td>';
  974. print '</tr>';
  975. print "</table>\n";
  976. print '</div>';
  977. print dol_get_fiche_end();
  978. print '<br>';
  979. if (!getDolGlobalString('MAIN_DISABLE_DOLISTORE_SEARCH') && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1) {
  980. // $options is array with filter criterias
  981. //var_dump($options);
  982. $dolistore->getRemoteCategories();
  983. $dolistore->getRemoteProducts($options);
  984. print '<span class="opacitymedium">'.$langs->trans('DOLISTOREdescriptionLong').'</span><br><br>';
  985. $previouslink = $dolistore->get_previous_link();
  986. $nextlink = $dolistore->get_next_link();
  987. print '<div class="liste_titre liste_titre_bydiv centpercent"><div class="divsearchfield">';
  988. print '<form method="POST" class="centpercent" id="searchFormList" action="'.$dolistore->url.'">'; ?>
  989. <input type="hidden" name="token" value="<?php echo newToken(); ?>">
  990. <input type="hidden" name="mode" value="marketplace">
  991. <div class="divsearchfield">
  992. <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>
  993. </div>
  994. <div class="divsearchfield">
  995. <input class="button buttongen" value="<?php echo $langs->trans('Rechercher') ?>" type="submit">
  996. <a class="buttonreset" href="<?php echo urlencode($dolistore->url) ?>"><?php echo $langs->trans('Reset') ?></a>
  997. &nbsp;
  998. </div>
  999. <?php
  1000. print $previouslink;
  1001. print $nextlink;
  1002. print '</form>';
  1003. print '</div></div>';
  1004. print '<div class="clearboth"></div>'; ?>
  1005. <div id="category-tree-left">
  1006. <ul class="tree">
  1007. <?php
  1008. echo $dolistore->get_categories(); // Do not use dol_escape_htmltag here, it is already a structured content?>
  1009. </ul>
  1010. </div>
  1011. <div id="listing-content">
  1012. <table summary="list_of_modules" id="list_of_modules" class="productlist centpercent">
  1013. <tbody id="listOfModules">
  1014. <?php echo $dolistore->get_products(); ?>
  1015. </tbody>
  1016. </table>
  1017. </div>
  1018. <?php
  1019. }
  1020. }
  1021. // Install external module
  1022. if ($mode == 'deploy') {
  1023. print dol_get_fiche_head($head, $mode, '', -1);
  1024. $dolibarrdataroot = preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT);
  1025. $allowonlineinstall = true;
  1026. $allowfromweb = 1;
  1027. if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) {
  1028. $allowonlineinstall = false;
  1029. }
  1030. $fullurl = '<a href="'.$urldolibarrmodules.'" target="_blank" rel="noopener noreferrer">'.$urldolibarrmodules.'</a>';
  1031. $message = '';
  1032. if ($allowonlineinstall) {
  1033. if (!in_array('/custom', explode(',', $dolibarr_main_url_root_alt))) {
  1034. $message = info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT));
  1035. $allowfromweb = -1;
  1036. } else {
  1037. if ($dirins_ok) {
  1038. if (!is_writable(dol_osencode($dirins))) {
  1039. $langs->load("errors");
  1040. $message = info_admin($langs->trans("ErrorFailedToWriteInDir", $dirins), 0, 0, '1', 'warning');
  1041. $allowfromweb = 0;
  1042. }
  1043. } else {
  1044. $message = info_admin($langs->trans("NotExistsDirect", $dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample"));
  1045. $allowfromweb = 0;
  1046. }
  1047. }
  1048. } else {
  1049. if (getDolGlobalString('MAIN_MESSAGE_INSTALL_MODULES_DISABLED_CONTACT_US')) {
  1050. // Show clean message
  1051. if (!is_numeric(getDolGlobalString('MAIN_MESSAGE_INSTALL_MODULES_DISABLED_CONTACT_US'))) {
  1052. $message = info_admin($langs->trans(getDolGlobalString('MAIN_MESSAGE_INSTALL_MODULES_DISABLED_CONTACT_US')));
  1053. } else {
  1054. $message = info_admin($langs->trans('InstallModuleFromWebHasBeenDisabledContactUs'));
  1055. }
  1056. } else {
  1057. // Show technical message
  1058. $message = info_admin($langs->trans("InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.'/installmodules.lock'));
  1059. }
  1060. $allowfromweb = 0;
  1061. }
  1062. print $deschelp;
  1063. if ($allowfromweb < 1) {
  1064. print $langs->trans("SomethingMakeInstallFromWebNotPossible");
  1065. print $message;
  1066. //print $langs->trans("SomethingMakeInstallFromWebNotPossible2");
  1067. print '<br>';
  1068. }
  1069. print '<br>';
  1070. // $allowfromweb = -1 if installation or setup not correct, 0 if not allowed, 1 if allowed
  1071. if ($allowfromweb >= 0) {
  1072. if ($allowfromweb == 1) {
  1073. //print $langs->trans("ThisIsProcessToFollow").'<br>';
  1074. } else {
  1075. print $langs->trans("ThisIsAlternativeProcessToFollow").'<br>';
  1076. print '<b>'.$langs->trans("StepNb", 1).'</b>: ';
  1077. print str_replace('{s1}', $fullurl, $langs->trans("FindPackageFromWebSite", '{s1}')).'<br>';
  1078. print '<b>'.$langs->trans("StepNb", 2).'</b>: ';
  1079. print str_replace('{s1}', $fullurl, $langs->trans("DownloadPackageFromWebSite", '{s1}')).'<br>';
  1080. print '<b>'.$langs->trans("StepNb", 3).'</b>: ';
  1081. }
  1082. if ($allowfromweb == 1) {
  1083. print '<form enctype="multipart/form-data" method="POST" class="noborder" action="'.$_SERVER["PHP_SELF"].'" name="forminstall">';
  1084. print '<input type="hidden" name="token" value="'.newToken().'">';
  1085. print '<input type="hidden" name="action" value="install">';
  1086. print '<input type="hidden" name="mode" value="deploy">';
  1087. print $langs->trans("YouCanSubmitFile").'<br><br>';
  1088. $max = $conf->global->MAIN_UPLOAD_DOC; // In Kb
  1089. $maxphp = @ini_get('upload_max_filesize'); // In unknown
  1090. if (preg_match('/k$/i', $maxphp)) {
  1091. $maxphp = preg_replace('/k$/i', '', $maxphp);
  1092. $maxphp = $maxphp * 1;
  1093. }
  1094. if (preg_match('/m$/i', $maxphp)) {
  1095. $maxphp = preg_replace('/m$/i', '', $maxphp);
  1096. $maxphp = $maxphp * 1024;
  1097. }
  1098. if (preg_match('/g$/i', $maxphp)) {
  1099. $maxphp = preg_replace('/g$/i', '', $maxphp);
  1100. $maxphp = $maxphp * 1024 * 1024;
  1101. }
  1102. if (preg_match('/t$/i', $maxphp)) {
  1103. $maxphp = preg_replace('/t$/i', '', $maxphp);
  1104. $maxphp = $maxphp * 1024 * 1024 * 1024;
  1105. }
  1106. $maxphp2 = @ini_get('post_max_size'); // In unknown
  1107. if (preg_match('/k$/i', $maxphp2)) {
  1108. $maxphp2 = preg_replace('/k$/i', '', $maxphp2);
  1109. $maxphp2 = $maxphp2 * 1;
  1110. }
  1111. if (preg_match('/m$/i', $maxphp2)) {
  1112. $maxphp2 = preg_replace('/m$/i', '', $maxphp2);
  1113. $maxphp2 = $maxphp2 * 1024;
  1114. }
  1115. if (preg_match('/g$/i', $maxphp2)) {
  1116. $maxphp2 = preg_replace('/g$/i', '', $maxphp2);
  1117. $maxphp2 = $maxphp2 * 1024 * 1024;
  1118. }
  1119. if (preg_match('/t$/i', $maxphp2)) {
  1120. $maxphp2 = preg_replace('/t$/i', '', $maxphp2);
  1121. $maxphp2 = $maxphp2 * 1024 * 1024 * 1024;
  1122. }
  1123. // Now $max and $maxphp and $maxphp2 are in Kb
  1124. $maxmin = $max;
  1125. $maxphptoshow = $maxphptoshowparam = '';
  1126. if ($maxphp > 0) {
  1127. $maxmin = min($max, $maxphp);
  1128. $maxphptoshow = $maxphp;
  1129. $maxphptoshowparam = 'upload_max_filesize';
  1130. }
  1131. if ($maxphp2 > 0) {
  1132. $maxmin = min($max, $maxphp2);
  1133. if ($maxphp2 < $maxphp) {
  1134. $maxphptoshow = $maxphp2;
  1135. $maxphptoshowparam = 'post_max_size';
  1136. }
  1137. }
  1138. if ($maxmin > 0) {
  1139. print '<script type="text/javascript">
  1140. $(document).ready(function() {
  1141. jQuery("#fileinstall").on("change", function() {
  1142. if(this.files[0].size > '.($maxmin * 1024).') {
  1143. alert("'.dol_escape_js($langs->trans("ErrorFileSizeTooLarge")).'");
  1144. this.value = "";
  1145. }
  1146. });
  1147. });
  1148. </script>'."\n";
  1149. // MAX_FILE_SIZE doit précéder le champ input de type file
  1150. print '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">';
  1151. }
  1152. print '<input class="flat minwidth400" type="file" name="fileinstall" id="fileinstall"> ';
  1153. print '<input type="submit" name="send" value="'.dol_escape_htmltag($langs->trans("Upload")).'" class="button">';
  1154. if (getDolGlobalString('MAIN_UPLOAD_DOC')) {
  1155. if ($user->admin) {
  1156. $langs->load('other');
  1157. print ' ';
  1158. print info_admin($langs->trans("ThisLimitIsDefinedInSetup", $max, $maxphptoshow, $maxphptoshowparam), 1);
  1159. }
  1160. } else {
  1161. print ' ('.$langs->trans("UploadDisabled").')';
  1162. }
  1163. print '</form>';
  1164. print '<br>';
  1165. print '<br>';
  1166. print '<div class="center"><div class="logo_setup"></div></div>';
  1167. } else {
  1168. print $langs->trans("UnpackPackageInModulesRoot", $dirins).'<br>';
  1169. print '<b>'.$langs->trans("StepNb", 4).'</b>: ';
  1170. print $langs->trans("SetupIsReadyForUse").'<br>';
  1171. }
  1172. }
  1173. if (!empty($result['return'])) {
  1174. print '<br>';
  1175. foreach ($result['return'] as $value) {
  1176. echo $value.'<br>';
  1177. }
  1178. }
  1179. print dol_get_fiche_end();
  1180. }
  1181. if ($mode == 'develop') {
  1182. print dol_get_fiche_head($head, $mode, '', -1);
  1183. print $deschelp;
  1184. print '<br>';
  1185. // Marketplace
  1186. print '<table summary="list_of_modules" class="noborder centpercent">'."\n";
  1187. print '<tr class="liste_titre">'."\n";
  1188. //print '<td>'.$langs->trans("Logo").'</td>';
  1189. print '<td colspan="2">'.$langs->trans("DevelopYourModuleDesc").'</td>';
  1190. print '<td>'.$langs->trans("URL").'</td>';
  1191. print '</tr>';
  1192. print '<tr class="oddeven" height="80">'."\n";
  1193. print '<td class="center">';
  1194. print '<div class="imgmaxheight50 logo_setup"></div>';
  1195. print '</td>';
  1196. print '<td>'.$langs->trans("TryToUseTheModuleBuilder", $langs->transnoentitiesnoconv("ModuleBuilder")).'</td>';
  1197. print '<td class="maxwidth300">';
  1198. if (isModEnabled('modulebuilder')) {
  1199. print $langs->trans("SeeTopRightMenu");
  1200. } else {
  1201. print '<span class="opacitymedium">'.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("ModuleBuilder")).'</span>';
  1202. }
  1203. print '</td>';
  1204. print '</tr>';
  1205. print '<tr class="oddeven" height="80">'."\n";
  1206. $url = 'https://partners.dolibarr.org';
  1207. print '<td class="center">';
  1208. 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>';
  1209. print '</td>';
  1210. print '<td>'.$langs->trans("DoliPartnersDesc").'</td>';
  1211. print '<td><a href="'.$url.'" target="_blank" rel="noopener noreferrer external">';
  1212. print img_picto('', 'url', 'class="pictofixedwidth"');
  1213. print $url.'</a></td>';
  1214. print '</tr>';
  1215. print "</table>\n";
  1216. print dol_get_fiche_end();
  1217. }
  1218. // End of page
  1219. llxFooter();
  1220. $db->close();