modules.php 58 KB

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