modules.php 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138
  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 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. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25. /**
  26. * \file htdocs/admin/modules.php
  27. * \brief Page to activate/disable all modules
  28. */
  29. require '../main.inc.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  34. require_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/dolistore.class.php';
  35. // Load translation files required by the page
  36. $langs->loadLangs(array("errors","admin","modulebuilder"));
  37. $mode=GETPOST('mode', 'alpha');
  38. if (empty($mode)) $mode='common';
  39. $action=GETPOST('action','alpha');
  40. //var_dump($_POST);exit;
  41. $value=GETPOST('value', 'alpha');
  42. $page_y=GETPOST('page_y','int');
  43. $search_keyword=GETPOST('search_keyword','alpha');
  44. $search_status=GETPOST('search_status','alpha');
  45. $search_nature=GETPOST('search_nature','alpha');
  46. $search_version=GETPOST('search_version','alpha');
  47. // For dolistore search
  48. $options = array();
  49. $options['per_page'] = 20;
  50. $options['categorie'] = ((GETPOST('categorie', 'int')?GETPOST('categorie', 'int'):0) + 0);
  51. $options['start'] = ((GETPOST('start', 'int')?GETPOST('start', 'int'):0) + 0);
  52. $options['end'] = ((GETPOST('end', 'int')?GETPOST('end', 'int'):0) + 0);
  53. $options['search'] = GETPOST('search_keyword', 'alpha');
  54. $dolistore = new Dolistore(false);
  55. if (! $user->admin)
  56. accessforbidden();
  57. $specialtostring=array(0=>'common', 1=>'interfaces', 2=>'other', 3=>'functional', 4=>'marketplace');
  58. $familyinfo=array(
  59. 'hr'=>array('position'=>'001', 'label'=>$langs->trans("ModuleFamilyHr")),
  60. 'crm'=>array('position'=>'006', 'label'=>$langs->trans("ModuleFamilyCrm")),
  61. 'srm'=>array('position'=>'007', 'label'=>$langs->trans("ModuleFamilySrm")),
  62. 'financial'=>array('position'=>'009', 'label'=>$langs->trans("ModuleFamilyFinancial")),
  63. 'products'=>array('position'=>'012', 'label'=>$langs->trans("ModuleFamilyProducts")),
  64. 'projects'=>array('position'=>'015', 'label'=>$langs->trans("ModuleFamilyProjects")),
  65. 'ecm'=>array('position'=>'018', 'label'=>$langs->trans("ModuleFamilyECM")),
  66. 'technic'=>array('position'=>'021', 'label'=>$langs->trans("ModuleFamilyTechnic")),
  67. 'portal'=>array('position'=>'040', 'label'=>$langs->trans("ModuleFamilyPortal")),
  68. 'interface'=>array('position'=>'050', 'label'=>$langs->trans("ModuleFamilyInterface")),
  69. 'base'=>array('position'=>'060', 'label'=>$langs->trans("ModuleFamilyBase")),
  70. 'other'=>array('position'=>'100', 'label'=>$langs->trans("ModuleFamilyOther")),
  71. );
  72. $param='';
  73. if (! GETPOST('buttonreset','alpha'))
  74. {
  75. if ($search_keyword) $param.='&search_keyword='.urlencode($search_keyword);
  76. if ($search_status && $search_status != '-1') $param.='&search_status='.urlencode($search_status);
  77. if ($search_nature && $search_nature != '-1') $param.='&search_nature='.urlencode($search_nature);
  78. if ($search_version && $search_version != '-1') $param.='&search_version='.urlencode($search_version);
  79. }
  80. $dirins=DOL_DOCUMENT_ROOT.'/custom';
  81. $urldolibarrmodules='https://www.dolistore.com/';
  82. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  83. $hookmanager->initHooks(array('adminmodules','globaladmin'));
  84. /*
  85. * Actions
  86. */
  87. $formconfirm = '';
  88. $parameters=array();
  89. $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  90. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  91. if (GETPOST('buttonreset','alpha'))
  92. {
  93. $search_keyword='';
  94. $search_status='';
  95. $search_nature='';
  96. $search_version='';
  97. }
  98. if ($action=='install')
  99. {
  100. $error=0;
  101. // $original_file should match format module_modulename-x.y[.z].zip
  102. $original_file=basename($_FILES["fileinstall"]["name"]);
  103. $newfile=$conf->admin->dir_temp.'/'.$original_file.'/'.$original_file;
  104. if (! $original_file)
  105. {
  106. $langs->load("Error");
  107. setEventMessages($langs->trans("ErrorModuleFileRequired"), null, 'warnings');
  108. $error++;
  109. }
  110. else
  111. {
  112. if (! preg_match('/\.zip$/i',$original_file))
  113. {
  114. $langs->load("errors");
  115. setEventMessages($langs->trans("ErrorFileMustBeADolibarrPackage",$original_file), null, 'errors');
  116. $error++;
  117. }
  118. if (! preg_match('/module_.*\-[\d]+\.[\d]+.*$/i',$original_file))
  119. {
  120. $langs->load("errors");
  121. setEventMessages($langs->trans("ErrorFilenameDosNotMatchDolibarrPackageRules",$original_file, 'module_*-x.y*.zip'), null, 'errors');
  122. $error++;
  123. }
  124. if (empty($_FILES['fileinstall']['tmp_name']))
  125. {
  126. $langs->load("errors");
  127. setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors');
  128. $error++;
  129. }
  130. }
  131. if (! $error)
  132. {
  133. if ($original_file)
  134. {
  135. @dol_delete_dir_recursive($conf->admin->dir_temp.'/'.$original_file);
  136. dol_mkdir($conf->admin->dir_temp.'/'.$original_file);
  137. }
  138. $tmpdir=preg_replace('/\.zip$/i','',$original_file).'.dir';
  139. if ($tmpdir)
  140. {
  141. @dol_delete_dir_recursive($conf->admin->dir_temp.'/'.$tmpdir);
  142. dol_mkdir($conf->admin->dir_temp.'/'.$tmpdir);
  143. }
  144. $result=dol_move_uploaded_file($_FILES['fileinstall']['tmp_name'], $newfile, 1, 0, $_FILES['fileinstall']['error']);
  145. if ($result > 0)
  146. {
  147. $result=dol_uncompress($newfile,$conf->admin->dir_temp.'/'.$tmpdir);
  148. if (! empty($result['error']))
  149. {
  150. $langs->load("errors");
  151. setEventMessages($langs->trans($result['error'],$original_file), null, 'errors');
  152. $error++;
  153. }
  154. else
  155. {
  156. // Now we move the dir of the module
  157. $modulename=preg_replace('/module_/', '', $original_file);
  158. $modulename=preg_replace('/\-[\d]+\.[\d]+.*$/', '', $modulename);
  159. // Search dir $modulename
  160. $modulenamedir=$conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulename;
  161. //var_dump($modulenamedir);
  162. if (! dol_is_dir($modulenamedir))
  163. {
  164. $modulenamedir=$conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulename;
  165. //var_dump($modulenamedir);
  166. if (! dol_is_dir($modulenamedir))
  167. {
  168. setEventMessages($langs->trans("ErrorModuleFileSeemsToHaveAWrongFormat").'<br>Dir not found: '.$conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulename.'<br>'.$conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulename, null, 'errors');
  169. $error++;
  170. }
  171. }
  172. if (! $error)
  173. {
  174. //var_dump($dirins);
  175. @dol_delete_dir_recursive($dirins.'/'.$modulename);
  176. dol_syslog("Uncompress of module file is a success. We copy it from ".$modulenamedir." into target dir ".$dirins.'/'.$modulename);
  177. $result=dolCopyDir($modulenamedir, $dirins.'/'.$modulename, '0444', 1);
  178. if ($result <= 0)
  179. {
  180. dol_syslog('Failed to call dolCopyDir result='.$result." with param ".$modulenamedir." and ".$dirins.'/'.$modulename, LOG_WARNING);
  181. $langs->load("errors");
  182. setEventMessages($langs->trans("ErrorFailToCopyDir", $modulenamedir, $dirins.'/'.$modulename), null, 'errors');
  183. $error++;
  184. }
  185. }
  186. }
  187. }
  188. else
  189. {
  190. setEventMessages($langs->trans("ErrorFailToRenameFile", $_FILES['fileinstall']['tmp_name'], $newfile), null, 'errors');
  191. $error++;
  192. }
  193. }
  194. if (! $error)
  195. {
  196. setEventMessages($langs->trans("SetupIsReadyForUse", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentitiesnoconv("Home").' - '.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Modules")), null, 'warnings');
  197. }
  198. }
  199. if ($action == 'set' && $user->admin)
  200. {
  201. $resarray = activateModule($value);
  202. if (! empty($resarray['errors'])) setEventMessages('', $resarray['errors'], 'errors');
  203. else
  204. {
  205. //var_dump($resarray);exit;
  206. if ($resarray['nbperms'] > 0)
  207. {
  208. $tmpsql="SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."user WHERE admin <> 1";
  209. $resqltmp=$db->query($tmpsql);
  210. if ($resqltmp)
  211. {
  212. $obj=$db->fetch_object($resqltmp);
  213. //var_dump($obj->nb);exit;
  214. if ($obj && $obj->nb > 1)
  215. {
  216. $msg = $langs->trans('ModuleEnabledAdminMustCheckRights');
  217. setEventMessages($msg, null, 'warnings');
  218. }
  219. }
  220. else dol_print_error($db);
  221. }
  222. }
  223. header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y?'&page_y='.$page_y:''));
  224. exit;
  225. }
  226. else if ($action == 'reset' && $user->admin && GETPOST('confirm') == 'yes')
  227. {
  228. $result=unActivateModule($value);
  229. if ($result) setEventMessages($result, null, 'errors');
  230. header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y?'&page_y='.$page_y:''));
  231. exit;
  232. }
  233. /*
  234. * View
  235. */
  236. $form = new Form($db);
  237. //$morejs = array("/admin/dolistore/js/dolistore.js.php");
  238. $morecss = array("/admin/dolistore/css/dolistore.css");
  239. // Set dir where external modules are installed
  240. if (! dol_is_dir($dirins))
  241. {
  242. dol_mkdir($dirins);
  243. }
  244. $dirins_ok=(dol_is_dir($dirins));
  245. $help_url='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
  246. llxHeader('',$langs->trans("Setup"),$help_url, '', '', '', $morejs, $morecss, 0, 0);
  247. // Search modules dirs
  248. $modulesdir = dolGetModulesDirs();
  249. $arrayofnatures=array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - ['.$langs->trans("AllPublishers").']');
  250. $arrayofwarnings=array(); // Array of warning each module want to show when activated
  251. $arrayofwarningsext=array(); // Array of warning each module want to show when we activate an external module
  252. $filename = array();
  253. $modules = array();
  254. $orders = array();
  255. $categ = array();
  256. $dirmod = array();
  257. $i = 0; // is a sequencer of modules found
  258. $j = 0; // j is module number. Automatically affected if module number not defined.
  259. $modNameLoaded=array();
  260. foreach ($modulesdir as $dir)
  261. {
  262. // Load modules attributes in arrays (name, numero, orders) from dir directory
  263. //print $dir."\n<br>";
  264. dol_syslog("Scan directory ".$dir." for module descriptor files (modXXX.class.php)");
  265. $handle=@opendir($dir);
  266. if (is_resource($handle))
  267. {
  268. while (($file = readdir($handle))!==false)
  269. {
  270. //print "$i ".$file."\n<br>";
  271. if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
  272. {
  273. $modName = substr($file, 0, dol_strlen($file) - 10);
  274. if ($modName)
  275. {
  276. if (! empty($modNameLoaded[$modName])) // In cache of already loaded modules ?
  277. {
  278. $mesg="Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.<br>";
  279. setEventMessages($mesg, null, 'warnings');
  280. dol_syslog($mesg, LOG_ERR);
  281. continue;
  282. }
  283. try
  284. {
  285. $res=include_once $dir.$file; // A class already exists in a different file will send a non catchable fatal error.
  286. if (class_exists($modName))
  287. {
  288. try {
  289. $objMod = new $modName($db);
  290. $modNameLoaded[$modName]=$dir;
  291. if (! $objMod->numero > 0 && $modName != 'modUser')
  292. {
  293. dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR);
  294. }
  295. $j = $objMod->numero;
  296. $modulequalified=1;
  297. // We discard modules according to features level (PS: if module is activated we always show it)
  298. $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod)));
  299. if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified=0;
  300. if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified=0;
  301. if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified=0;
  302. // We discard modules according to property ->hidden
  303. if (! empty($objMod->hidden)) $modulequalified=0;
  304. if ($modulequalified > 0)
  305. {
  306. $publisher=dol_escape_htmltag($objMod->getPublisher());
  307. $external=($objMod->isCoreOrExternalModule() == 'external');
  308. if ($external)
  309. {
  310. if ($publisher)
  311. {
  312. $arrayofnatures['external_'.$publisher]=$langs->trans("External").' - '.$publisher;
  313. }
  314. else
  315. {
  316. $arrayofnatures['external_']=$langs->trans("External").' - '.$langs->trans("UnknownPublishers");
  317. }
  318. }
  319. ksort($arrayofnatures);
  320. }
  321. // Define array $categ with categ with at least one qualified module
  322. if ($modulequalified > 0)
  323. {
  324. $filename[$i]= $modName;
  325. $modules[$modName] = $objMod;
  326. // Gives the possibility to the module, to provide his own family info and position of this family
  327. if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) {
  328. $familyinfo = array_merge($familyinfo, $objMod->familyinfo);
  329. $familykey = key($objMod->familyinfo);
  330. } else {
  331. $familykey = $objMod->family;
  332. }
  333. $moduleposition = ($objMod->module_position?$objMod->module_position:'50');
  334. if ($moduleposition == '50' && ($objMod->isCoreOrExternalModule() == 'external'))
  335. {
  336. $moduleposition = '80'; // External modules at end by default
  337. }
  338. // Add list of warnings to show into arrayofwarnings and arrayofwarningsext
  339. if (! empty($objMod->warnings_activation))
  340. {
  341. $arrayofwarnings[$modName]=$objMod->warnings_activation;
  342. }
  343. if (! empty($objMod->warnings_activation_ext))
  344. {
  345. $arrayofwarningsext[$modName]=$objMod->warnings_activation_ext;
  346. }
  347. $orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number
  348. $dirmod[$i] = $dir;
  349. //print $i.'-'.$dirmod[$i].'<br>';
  350. // Set categ[$i]
  351. $specialstring = 'unknown';
  352. if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring='expdev';
  353. if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories
  354. else $categ[$specialstring]=1;
  355. $j++;
  356. $i++;
  357. }
  358. else dol_syslog("Module ".get_class($objMod)." not qualified");
  359. }
  360. catch(Exception $e)
  361. {
  362. dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
  363. }
  364. }
  365. else
  366. {
  367. print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)<br>";
  368. }
  369. }
  370. catch(Exception $e)
  371. {
  372. dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
  373. }
  374. }
  375. }
  376. }
  377. closedir($handle);
  378. }
  379. else
  380. {
  381. dol_syslog("htdocs/admin/modules.php: Failed to open directory ".$dir.". See permission and open_basedir option.", LOG_WARNING);
  382. }
  383. }
  384. if ($action == 'reset_confirm' && $user->admin)
  385. {
  386. if(!empty($modules[$value])) {
  387. $objMod = $modules[$value];
  388. if(!empty($objMod->langfiles)) $langs->loadLangs($objMod->langfiles);
  389. $form = new Form($db);
  390. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?value='.$value.'&mode='.$mode.$param, $langs->trans('ConfirmUnactivation'), $langs->trans(GETPOST('confirm_message_code')), 'reset', '', 'no', 1);
  391. }
  392. }
  393. print $formconfirm;
  394. asort($orders);
  395. //var_dump($orders);
  396. //var_dump($categ);
  397. //var_dump($modules);
  398. $nbofactivatedmodules=count($conf->modules);
  399. $moreinfo=$langs->trans("TotalNumberOfActivatedModules",($nbofactivatedmodules-1), count($modules));
  400. if ($nbofactivatedmodules <= 1) $moreinfo .= ' '.img_warning($langs->trans("YouMustEnableOneModule"));
  401. print load_fiche_titre($langs->trans("ModulesSetup"),$moreinfo,'title_setup');
  402. // Start to show page
  403. if ($mode=='common') print '<span class="opacitymedium">'.$langs->trans("ModulesDesc")."</span><br>\n";
  404. if ($mode=='marketplace') print '<span class="opacitymedium">'.$langs->trans("ModulesMarketPlaceDesc")."</span><br>\n";
  405. if ($mode=='deploy') print '<span class="opacitymedium">'.$langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."</span><br>\n";
  406. if ($mode=='develop') print '<span class="opacitymedium">'.$langs->trans("ModulesDevelopDesc")."</span><br>\n";
  407. $head = modules_prepare_head();
  408. print "<br>\n";
  409. if ($mode == 'common')
  410. {
  411. dol_set_focus('#search_keyword');
  412. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  413. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  414. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  415. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  416. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  417. print '<input type="hidden" name="page" value="'.$page.'">';
  418. dol_fiche_head($head, $mode, '', -1);
  419. $moreforfilter = '';
  420. $moreforfilter.='<div class="divsearchfield">';
  421. $moreforfilter.= $langs->trans('Keyword') . ': <input type="text" id="search_keyword" name="search_keyword" value="'.dol_escape_htmltag($search_keyword).'">';
  422. $moreforfilter.= '</div>';
  423. $moreforfilter.='<div class="divsearchfield">';
  424. $moreforfilter.= $langs->trans('Origin') . ': '.$form->selectarray('search_nature', $arrayofnatures, dol_escape_htmltag($search_nature), 1);
  425. $moreforfilter.= '</div>';
  426. if (! empty($conf->global->MAIN_FEATURES_LEVEL))
  427. {
  428. $array_version = array('stable'=>$langs->transnoentitiesnoconv("Stable"));
  429. if ($conf->global->MAIN_FEATURES_LEVEL < 0) $array_version['deprecated']=$langs->trans("Deprecated");
  430. if ($conf->global->MAIN_FEATURES_LEVEL > 0) $array_version['experimental']=$langs->trans("Experimental");
  431. if ($conf->global->MAIN_FEATURES_LEVEL > 1) $array_version['development']=$langs->trans("Development");
  432. $moreforfilter.='<div class="divsearchfield">';
  433. $moreforfilter.= $langs->trans('Version') . ': '.$form->selectarray('search_version', $array_version, $search_version, 1);
  434. $moreforfilter.= '</div>';
  435. }
  436. $moreforfilter.='<div class="divsearchfield">';
  437. $moreforfilter.= $langs->trans('Status') . ': '.$form->selectarray('search_status', array('active'=>$langs->transnoentitiesnoconv("Enabled"), 'disabled'=>$langs->transnoentitiesnoconv("Disabled")), $search_status, 1);
  438. $moreforfilter.= '</div>';
  439. $moreforfilter.=' ';
  440. $moreforfilter.='<div class="divsearchfield">';
  441. $moreforfilter.='<input type="submit" name="buttonsubmit" class="button" value="'.dol_escape_htmltag($langs->trans("Refresh")).'">';
  442. $moreforfilter.=' ';
  443. $moreforfilter.='<input type="submit" name="buttonreset" class="button" value="'.dol_escape_htmltag($langs->trans("Reset")).'">';
  444. $moreforfilter.= '</div>';
  445. if (! empty($moreforfilter))
  446. {
  447. print $moreforfilter;
  448. $parameters=array();
  449. $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
  450. print $hookmanager->resPrint;
  451. }
  452. $moreforfilter='';
  453. print '<div class="clearboth"></div><br>';
  454. $parameters=array();
  455. $reshook=$hookmanager->executeHooks('insertExtraHeader',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  456. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  457. // Show list of modules
  458. $oldfamily='';
  459. foreach ($orders as $key => $value)
  460. {
  461. $tab=explode('_',$value);
  462. $familyposition=$tab[0]; $familykey=$tab[1]; $module_position=$tab[2]; $numero=$tab[3];
  463. $modName = $filename[$key];
  464. $objMod = $modules[$modName];
  465. $dirofmodule = $dirmod[$key];
  466. //print $objMod->name." - ".$key." - ".$objMod->version."<br>";
  467. //if (($mode != (isset($specialtostring[$special])?$specialtostring[$special]:'unknown') && $mode != 'expdev')
  468. if ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental') continue; // Discard if not for current tab
  469. if (! $objMod->getName())
  470. {
  471. dol_syslog("Error for module ".$key." - Property name of module looks empty", LOG_WARNING);
  472. continue;
  473. }
  474. $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod)));
  475. // Check filters
  476. $modulename=$objMod->getName();
  477. $moduletechnicalname=$objMod->name;
  478. $moduledesc=$objMod->getDesc();
  479. $moduledesclong=$objMod->getDescLong();
  480. $moduleauthor=$objMod->getPublisher();
  481. // We discard showing according to filters
  482. if ($search_keyword)
  483. {
  484. $qualified=0;
  485. if (preg_match('/'.preg_quote($search_keyword).'/i', $modulename)
  486. || preg_match('/'.preg_quote($search_keyword).'/i', $moduletechnicalname)
  487. || preg_match('/'.preg_quote($search_keyword).'/i', $moduledesc)
  488. || preg_match('/'.preg_quote($search_keyword).'/i', $moduledesclong)
  489. || preg_match('/'.preg_quote($search_keyword).'/i', $moduleauthor)
  490. ) $qualified=1;
  491. if (! $qualified) continue;
  492. }
  493. if ($search_status)
  494. {
  495. if ($search_status == 'active' && empty($conf->global->$const_name)) continue;
  496. if ($search_status == 'disabled' && ! empty($conf->global->$const_name)) continue;
  497. }
  498. if ($search_nature)
  499. {
  500. if (preg_match('/^external/',$search_nature) && $objMod->isCoreOrExternalModule() != 'external') continue;
  501. if (preg_match('/^external_(.*)$/',$search_nature, $reg))
  502. {
  503. //print $reg[1].'-'.dol_escape_htmltag($objMod->getPublisher());
  504. $publisher=dol_escape_htmltag($objMod->getPublisher());
  505. if ($reg[1] && dol_escape_htmltag($reg[1]) != $publisher) continue;
  506. if (! $reg[1] && ! empty($publisher)) continue;
  507. }
  508. if ($search_nature == 'core' && $objMod->isCoreOrExternalModule() == 'external') continue;
  509. }
  510. if ($search_version)
  511. {
  512. if (($objMod->version == 'development' || $objMod->version == 'experimental' || preg_match('/deprecated/', $objMod->version)) && $search_version == 'stable') continue;
  513. if ($objMod->version != 'development' && ($search_version == 'development')) continue;
  514. if ($objMod->version != 'experimental' && ($search_version == 'experimental')) continue;
  515. if (! preg_match('/deprecated/', $objMod->version) && ($search_version == 'deprecated')) continue;
  516. }
  517. // Load all lang files of module
  518. if (isset($objMod->langfiles) && is_array($objMod->langfiles))
  519. {
  520. foreach($objMod->langfiles as $domain)
  521. {
  522. $langs->load($domain);
  523. }
  524. }
  525. // Print a separator if we change family
  526. if ($familykey != $oldfamily) {
  527. if ($oldfamily) {
  528. print '</table></div><br>';
  529. }
  530. $familytext = empty($familyinfo[$familykey]['label'])?$familykey:$familyinfo[$familykey]['label'];
  531. print load_fiche_titre($familytext, '', '');
  532. print '<div class="div-table-responsive">';
  533. print '<table class="tagtable liste" summary="list_of_modules">'."\n";
  534. $atleastoneforfamily=0;
  535. }
  536. $atleastoneforfamily++;
  537. if ($familykey!=$oldfamily)
  538. {
  539. $familytext=empty($familyinfo[$familykey]['label'])?$familykey:$familyinfo[$familykey]['label'];
  540. $oldfamily=$familykey;
  541. }
  542. // Version (with picto warning or not)
  543. $version=$objMod->getVersion(0);
  544. $versiontrans='';
  545. if (preg_match('/development/i', $version)) $versiontrans.=img_warning($langs->trans("Development"), 'style="float: left"');
  546. if (preg_match('/experimental/i', $version)) $versiontrans.=img_warning($langs->trans("Experimental"), 'style="float: left"');
  547. if (preg_match('/deprecated/i', $version)) $versiontrans.=img_warning($langs->trans("Deprecated"), 'style="float: left"');
  548. $versiontrans.=$objMod->getVersion(1);
  549. // Define imginfo
  550. $imginfo="info";
  551. if ($objMod->isCoreOrExternalModule() == 'external')
  552. {
  553. $imginfo="info_black";
  554. }
  555. print '<tr class="oddeven">'."\n";
  556. if (!empty($conf->global->MAIN_MODULES_SHOW_LINENUMBERS)) print '<td width="20px">'.++$linenum.'</td>';
  557. // Picto + Name of module
  558. print ' <td width="200px">';
  559. $alttext='';
  560. //if (is_array($objMod->need_dolibarr_version)) $alttext.=($alttext?' - ':'').'Dolibarr >= '.join('.',$objMod->need_dolibarr_version);
  561. //if (is_array($objMod->phpmin)) $alttext.=($alttext?' - ':'').'PHP >= '.join('.',$objMod->phpmin);
  562. if (! empty($objMod->picto))
  563. {
  564. if (preg_match('/^\//i',$objMod->picto)) print img_picto($alttext,$objMod->picto,' width="14px"',1);
  565. else print img_object($alttext, $objMod->picto, 'class="valignmiddle" width="14px"');
  566. }
  567. else
  568. {
  569. print img_object($alttext, 'generic', 'class="valignmiddle"');
  570. }
  571. print ' <span class="valignmiddle">'.$objMod->getName().'</span>';
  572. print "</td>\n";
  573. // Desc
  574. print '<td class="valignmiddle tdoverflowmax300">';
  575. print nl2br($objMod->getDesc());
  576. print "</td>\n";
  577. // Help
  578. print '<td class="center nowrap" style="width: 82px;">';
  579. //print $form->textwithpicto('', $text, 1, $imginfo, 'minheight20', 0, 2, 1);
  580. print '<a href="javascript:document_preview(\''.DOL_URL_ROOT.'/admin/modulehelp.php?id='.$objMod->numero.'\',\'text/html\',\''.dol_escape_js($langs->trans("Module")).'\')">'.img_picto($langs->trans("ClickToShowDescription"), $imginfo).'</a>';
  581. print '</td>';
  582. // Version
  583. print '<td class="center nowrap" width="120px">';
  584. print $versiontrans;
  585. if(!empty($conf->global->CHECKLASTVERSION_EXTERNALMODULE)){
  586. require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
  587. if (!empty($objMod->url_last_version)) {
  588. $newversion = getURLContent($objMod->url_last_version);
  589. if(isset($newversion['content'])){
  590. if (version_compare($newversion['content'], $versiontrans) > 0) {
  591. print "&nbsp;<span class='butAction' title='" . $langs->trans('LastStableVersion') . "'>".$newversion['content']."</span>";
  592. }
  593. }
  594. }
  595. }
  596. print "</td>\n";
  597. // Activate/Disable and Setup (2 columns)
  598. if (! empty($conf->global->$const_name)) // If module is already activated
  599. {
  600. $disableSetup = 0;
  601. // Link enable/disabme
  602. print '<td class="center valignmiddle" width="60px">';
  603. if (! empty($arrayofwarnings[$modName]))
  604. {
  605. print '<!-- This module has a warning to show when we activate it (note: your country is '.$mysoc->country_code.') -->'."\n";
  606. }
  607. if (! empty($objMod->disabled))
  608. {
  609. print $langs->trans("Disabled");
  610. }
  611. else if (! empty($objMod->always_enabled) || ((! empty($conf->multicompany->enabled) && $objMod->core_enabled) && ($user->entity || $conf->entity!=1)))
  612. {
  613. if (method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) print $langs->trans("Used");
  614. else {
  615. print img_picto($langs->trans("Required"),'switch_on');
  616. print $langs->trans("Required");
  617. }
  618. if (! empty($conf->multicompany->enabled) && $user->entity) $disableSetup++;
  619. }
  620. else
  621. {
  622. if(!empty($objMod->warnings_unactivation[$mysoc->country_code]) && method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) {
  623. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$objMod->numero.'&amp;module_position='.$module_position.'&amp;action=reset_confirm&amp;confirm_message_code='.$objMod->warnings_unactivation[$mysoc->country_code].'&amp;value=' . $modName . '&amp;mode=' . $mode . $param . '">';
  624. print img_picto($langs->trans("Activated"),'switch_on');
  625. print '</a>';
  626. }
  627. else {
  628. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$objMod->numero.'&amp;module_position='.$module_position.'&amp;action=reset&amp;value=' . $modName . '&amp;mode=' . $mode .'&amp;confirm=yes' . $param . '">';
  629. print img_picto($langs->trans("Activated"),'switch_on');
  630. print '</a>';
  631. }
  632. }
  633. print '</td>'."\n";
  634. // Link config
  635. if (! empty($objMod->config_page_url) && !$disableSetup)
  636. {
  637. $backtourlparam='';
  638. if ($search_keyword != '') $backtourlparam.=($backtourlparam?'&':'?').'search_keyword='.$search_keyword; // No urlencode here, done later
  639. if ($search_nature > -1) $backtourlparam.=($backtourlparam?'&':'?').'search_nature='.$search_nature;
  640. if ($search_version > -1) $backtourlparam.=($backtourlparam?'&':'?').'search_version='.$search_version;
  641. if ($search_status > -1) $backtourlparam.=($backtourlparam?'&':'?').'search_status='.$search_status;
  642. $backtourl=$_SERVER["PHP_SELF"].$backtourlparam;
  643. if (is_array($objMod->config_page_url))
  644. {
  645. print '<td class="tdsetuppicto right" width="60px">';
  646. $i=0;
  647. foreach ($objMod->config_page_url as $page)
  648. {
  649. $urlpage=$page;
  650. if ($i++)
  651. {
  652. print '<a href="'.$urlpage.'" title="'.$langs->trans($page).'">'.img_picto(ucfirst($page),"setup").'</a>';
  653. // print '<a href="'.$page.'">'.ucfirst($page).'</a>&nbsp;';
  654. }
  655. else
  656. {
  657. if (preg_match('/^([^@]+)@([^@]+)$/i',$urlpage,$regs))
  658. {
  659. $urltouse=dol_buildpath('/'.$regs[2].'/admin/'.$regs[1],1);
  660. print '<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"').'</a>';
  661. }
  662. else
  663. {
  664. $urltouse=$urlpage;
  665. print '<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"').'</a>';
  666. }
  667. }
  668. }
  669. print "</td>\n";
  670. }
  671. else if (preg_match('/^([^@]+)@([^@]+)$/i',$objMod->config_page_url,$regs))
  672. {
  673. print '<td class="tdsetuppicto right valignmiddle" width="60px"><a 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"').'</a></td>';
  674. }
  675. else
  676. {
  677. print '<td class="tdsetuppicto right valignmiddle" width="60px"><a href="'.$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"').'</a></td>';
  678. }
  679. }
  680. else
  681. {
  682. print '<td class="tdsetuppicto right valignmiddle" width="60px">'.img_picto($langs->trans("NothingToSetup"),"setup",'class="opacitytransp" style="padding-right: 6px"').'</td>';
  683. }
  684. }
  685. else // Module not yet activated
  686. {
  687. // Link enable/disable
  688. print '<td class="center valignmiddle" width="60px">';
  689. if (! empty($objMod->always_enabled))
  690. {
  691. // Should never happened
  692. }
  693. else if (! empty($objMod->disabled))
  694. {
  695. print $langs->trans("Disabled");
  696. }
  697. else
  698. {
  699. // Module qualified for activation
  700. $warningmessage='';
  701. if (! empty($arrayofwarnings[$modName]))
  702. {
  703. print '<!-- This module has a warning to show when we activate it (note: your country is '.$mysoc->country_code.') -->'."\n";
  704. foreach ($arrayofwarnings[$modName] as $keycountry => $cursorwarningmessage)
  705. {
  706. $warningmessage .= ($warningmessage?"\n":"").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code);
  707. }
  708. }
  709. if ($objMod->isCoreOrExternalModule() == 'external' && ! empty($arrayofwarningsext))
  710. {
  711. print '<!-- This module is an external module and it may have a warning to show (note: your country is '.$mysoc->country_code.') -->'."\n";
  712. foreach ($arrayofwarningsext as $keymodule => $arrayofwarningsextbycountry)
  713. {
  714. $keymodulelowercase=strtolower(preg_replace('/^mod/','',$keymodule));
  715. if (in_array($keymodulelowercase, $conf->modules)) // If module that request warning is on
  716. {
  717. foreach ($arrayofwarningsextbycountry as $keycountry => $cursorwarningmessage)
  718. {
  719. if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^'.$mysoc->country_code.'/', $keycountry)))
  720. {
  721. $warningmessage .= ($warningmessage?"\n":"").$langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code, $modules[$keymodule]->getName());
  722. $warningmessage .= ($warningmessage?"\n":"").($warningmessage?"\n":"").$langs->trans("Module").' : '.$objMod->getName();
  723. if (! empty($objMod->editor_name)) $warningmessage .= ($warningmessage?"\n":"").$langs->trans("Publisher").' : '.$objMod->editor_name;
  724. if (! empty($objMod->editor_name)) $warningmessage .= ($warningmessage?"\n":"").$langs->trans("ModuleTriggeringThisWarning").' : '.$modules[$keymodule]->getName();
  725. }
  726. }
  727. }
  728. }
  729. }
  730. print '<!-- Message to show: '.$warningmessage.' -->'."\n";
  731. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$objMod->numero.'&amp;module_position='.$module_position.'&amp;action=set&amp;value=' . $modName . '&amp;mode=' . $mode . $param . '"';
  732. if ($warningmessage) print ' onclick="return confirm(\''.dol_escape_js($warningmessage).'\');"';
  733. print '>';
  734. print img_picto($langs->trans("Disabled"),'switch_off');
  735. print "</a>\n";
  736. }
  737. print "</td>\n";
  738. // Link config
  739. print '<td class="tdsetuppicto right valignmiddle" width="60px">'.img_picto($langs->trans("NothingToSetup"),"setup",'class="opacitytransp" style="padding-right: 6px"').'</td>';
  740. }
  741. print "</tr>\n";
  742. }
  743. if ($oldfamily)
  744. {
  745. print "</table>\n";
  746. print '</div>';
  747. }
  748. dol_fiche_end();
  749. print '<br>';
  750. // Show warning about external users
  751. print info_admin(showModulesExludedForExternal($modules))."\n";
  752. print '</form>';
  753. }
  754. if ($mode == 'marketplace')
  755. {
  756. dol_fiche_head($head, $mode, '', -1);
  757. // Marketplace
  758. print "<table summary=\"list_of_modules\" class=\"noborder\" width=\"100%\">\n";
  759. print "<tr class=\"liste_titre\">\n";
  760. //print '<td>'.$langs->trans("Logo").'</td>';
  761. print '<td colspan="2">'.$langs->trans("WebSiteDesc").'</td>';
  762. print '<td>'.$langs->trans("URL").'</td>';
  763. print '</tr>';
  764. print "<tr class=\"oddeven\">\n";
  765. $url='https://www.dolistore.com';
  766. print '<td align="left"><a href="'.$url.'" target="_blank" rel="external"><img border="0" class="imgautosize imgmaxwidth180" src="'.DOL_URL_ROOT.'/theme/dolistore_logo.png"></a></td>';
  767. print '<td>'.$langs->trans("DoliStoreDesc").'</td>';
  768. print '<td><a href="'.$url.'" target="_blank" rel="external">'.$url.'</a></td>';
  769. print '</tr>';
  770. print "</table>\n";
  771. dol_fiche_end();
  772. print '<br>';
  773. if (empty($conf->global->MAIN_DISABLE_DOLISTORE_SEARCH) && $conf->global->MAIN_FEATURES_LEVEL >= 1)
  774. {
  775. // $options is array with filter criterias
  776. //var_dump($options);
  777. $dolistore->getRemoteData($options);
  778. print '<span class="opacitymedium">'.$langs->trans('DOLISTOREdescriptionLong').'</span><br><br>';
  779. $previouslink = $dolistore->get_previous_link();
  780. $nextlink = $dolistore->get_next_link();
  781. print '<div class="liste_titre liste_titre_bydiv centpercent"><div class="divsearchfield">'
  782. ?>
  783. <form method="POST" class="centpercent" id="searchFormList" action="<?php echo $dolistore->url ?>">
  784. <input type="hidden" name="mode" value="marketplace" />
  785. <div class="divsearchfield"><?php echo $langs->trans('Keyword') ?>:
  786. <input name="search_keyword" placeholder="<?php echo $langs->trans('Chercher un module') ?>" id="search_keyword" type="text" size="50" value="<?php echo $options['search'] ?>"><br>
  787. </div>
  788. <div class="divsearchfield">
  789. <input class="button" value="<?php echo $langs->trans('Rechercher') ?>" type="submit">
  790. <a class="button" href="<?php echo $dolistore->url ?>"><?php echo $langs->trans('Reset') ?></a>
  791. &nbsp;
  792. </div>
  793. <div class="divsearchfield right">
  794. <?php
  795. print $previouslink;
  796. print $nextlink;
  797. ?>
  798. </div>
  799. </form>
  800. <?php
  801. print '</div></div>';
  802. print '<div class="clearboth"></div>';
  803. ?>
  804. <div id="category-tree-left">
  805. <ul class="tree">
  806. <?php echo $dolistore->get_categories(); ?>
  807. </ul>
  808. </div>
  809. <div id="listing-content">
  810. <table summary="list_of_modules" id="list_of_modules" class="productlist centpercent">
  811. <tbody id="listOfModules">
  812. <?php echo $dolistore->get_products($categorie); ?>
  813. </tbody>
  814. </table>
  815. </div>
  816. <?php
  817. }
  818. }
  819. // Install external module
  820. if ($mode == 'deploy')
  821. {
  822. dol_fiche_head($head, $mode, '', -1);
  823. $dolibarrdataroot=preg_replace('/([\\/]+)$/i','',DOL_DATA_ROOT);
  824. $allowonlineinstall=true;
  825. $allowfromweb=1;
  826. if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) $allowonlineinstall=false;
  827. $fullurl='<a href="'.$urldolibarrmodules.'" target="_blank">'.$urldolibarrmodules.'</a>';
  828. $message='';
  829. if (! empty($allowonlineinstall))
  830. {
  831. if (! in_array('/custom',explode(',',$dolibarr_main_url_root_alt)))
  832. {
  833. $message=info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT));
  834. $allowfromweb=-1;
  835. }
  836. else
  837. {
  838. if ($dirins_ok)
  839. {
  840. if (! is_writable(dol_osencode($dirins)))
  841. {
  842. $langs->load("errors");
  843. $message=info_admin($langs->trans("ErrorFailedToWriteInDir",$dirins));
  844. $allowfromweb=0;
  845. }
  846. }
  847. else
  848. {
  849. $message=info_admin($langs->trans("NotExistsDirect",$dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample"));
  850. $allowfromweb=0;
  851. }
  852. }
  853. }
  854. else
  855. {
  856. $message=info_admin($langs->trans("InstallModuleFromWebHasBeenDisabledByFile",$dolibarrdataroot.'/installmodules.lock'));
  857. $allowfromweb=0;
  858. }
  859. if ($allowfromweb < 1)
  860. {
  861. print $langs->trans("SomethingMakeInstallFromWebNotPossible");
  862. print $message;
  863. //print $langs->trans("SomethingMakeInstallFromWebNotPossible2");
  864. print '<br>';
  865. }
  866. print '<br>';
  867. if ($allowfromweb >= 0)
  868. {
  869. if ($allowfromweb == 1)
  870. {
  871. //print $langs->trans("ThisIsProcessToFollow").'<br>';
  872. }
  873. else
  874. {
  875. print $langs->trans("ThisIsAlternativeProcessToFollow").'<br>';
  876. print '<b>'.$langs->trans("StepNb",1).'</b>: ';
  877. print $langs->trans("FindPackageFromWebSite",$fullurl).'<br>';
  878. print '<b>'.$langs->trans("StepNb",2).'</b>: ';
  879. print $langs->trans("DownloadPackageFromWebSite",$fullurl).'<br>';
  880. print '<b>'.$langs->trans("StepNb",3).'</b>: ';
  881. }
  882. if ($allowfromweb == 1)
  883. {
  884. print $langs->trans("UnpackPackageInModulesRoot",$dirins).'<br>';
  885. print '<br>';
  886. print '<form enctype="multipart/form-data" method="POST" class="noborder" action="'.$_SERVER["PHP_SELF"].'" name="forminstall">';
  887. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  888. print '<input type="hidden" name="action" value="install">';
  889. print '<input type="hidden" name="mode" value="deploy">';
  890. print $langs->trans("YouCanSubmitFile");
  891. $max=$conf->global->MAIN_UPLOAD_DOC; // En Kb
  892. $maxphp=@ini_get('upload_max_filesize'); // En inconnu
  893. if (preg_match('/k$/i',$maxphp)) $maxphp=$maxphp*1;
  894. if (preg_match('/m$/i',$maxphp)) $maxphp=$maxphp*1024;
  895. if (preg_match('/g$/i',$maxphp)) $maxphp=$maxphp*1024*1024;
  896. if (preg_match('/t$/i',$maxphp)) $maxphp=$maxphp*1024*1024*1024;
  897. // Now $max and $maxphp are in Kb
  898. $maxmin = $max;
  899. if ($maxphp > 0) $maxmin=min($max,$maxphp);
  900. if ($maxmin > 0)
  901. {
  902. print '<script type="text/javascript">
  903. $(document).ready(function() {
  904. jQuery("#fileinstall").on("change", function() {
  905. if(this.files[0].size > '.($maxmin*1024).'){
  906. alert("'.dol_escape_js($langs->trans("ErrorFileSizeTooLarge")).'");
  907. this.value = "";
  908. };
  909. });
  910. });
  911. </script>'."\n";
  912. // MAX_FILE_SIZE doit précéder le champ input de type file
  913. print '<input type="hidden" name="max_file_size" value="'.($maxmin*1024).'">';
  914. }
  915. print '<input class="flat minwidth400" type="file" name="fileinstall" id="fileinstall"> ';
  916. print '<input type="submit" name="send" value="'.dol_escape_htmltag($langs->trans("Send")).'" class="button">';
  917. if (! empty($conf->global->MAIN_UPLOAD_DOC))
  918. {
  919. if ($user->admin)
  920. {
  921. $langs->load('other');
  922. print ' ';
  923. print info_admin($langs->trans("ThisLimitIsDefinedInSetup",$max,$maxphp),1);
  924. }
  925. }
  926. else
  927. {
  928. print ' ('.$langs->trans("UploadDisabled").')';
  929. }
  930. print '</form>';
  931. print '<br>';
  932. print '<br>';
  933. print '<div class="center"><div class="logo_setup"></div></div>';
  934. }
  935. else
  936. {
  937. print $langs->trans("UnpackPackageInModulesRoot",$dirins).'<br>';
  938. print '<b>'.$langs->trans("StepNb",4).'</b>: ';
  939. print $langs->trans("SetupIsReadyForUse").'<br>';
  940. }
  941. }
  942. if (! empty($result['return']))
  943. {
  944. print '<br>';
  945. foreach($result['return'] as $value)
  946. {
  947. echo $value.'<br>';
  948. }
  949. }
  950. dol_fiche_end();
  951. }
  952. if ($mode == 'develop')
  953. {
  954. dol_fiche_head($head, $mode, '', -1);
  955. // Marketplace
  956. print "<table summary=\"list_of_modules\" class=\"noborder\" width=\"100%\">\n";
  957. print "<tr class=\"liste_titre\">\n";
  958. //print '<td>'.$langs->trans("Logo").'</td>';
  959. print '<td colspan="2">'.$langs->trans("DevelopYourModuleDesc").'</td>';
  960. print '<td>'.$langs->trans("URL").'</td>';
  961. print '</tr>';
  962. print '<tr class="oddeven" height="80">'."\n";
  963. print '<td align="left">';
  964. //span class="fa fa-bug"></span>
  965. //print '<img border="0" class="imgautosize imgmaxwidth180" src="'.DOL_URL_ROOT.'/theme/dolibarr_preferred_partner_int.png">';
  966. print '<div class="imgmaxheight50 logo_setup"></div>';
  967. print '</td>';
  968. print '<td>'.$langs->trans("TryToUseTheModuleBuilder", $langs->transnoentitiesnoconv("ModuleBuilder")).'</td>';
  969. print '<td>'.$langs->trans("SeeTopRightMenu").'</td>';
  970. print '</tr>';
  971. print '<tr class="oddeven" height="80">'."\n";
  972. $url='https://partners.dolibarr.org';
  973. print '<td align="left">';
  974. print'<a href="'.$url.'" target="_blank" rel="external"><img border="0" class="imgautosize imgmaxwidth180" src="'.DOL_URL_ROOT.'/theme/dolibarr_preferred_partner_int.png"></a>';
  975. print '</td>';
  976. print '<td>'.$langs->trans("DoliPartnersDesc").'</td>';
  977. print '<td><a href="'.$url.'" target="_blank" rel="external">'.$url.'</a></td>';
  978. print '</tr>';
  979. print "</table>\n";
  980. dol_fiche_end();
  981. }
  982. // End of page
  983. llxFooter();
  984. $db->close();