modules.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794
  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-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
  6. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.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. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 3 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. */
  24. /**
  25. * \file htdocs/admin/modules.php
  26. * \brief Page to activate/disable all modules
  27. */
  28. require '../main.inc.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  30. require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
  31. $langs->load("errors");
  32. $langs->load("admin");
  33. $mode=GETPOST('mode', 'alpha')?GETPOST('mode', 'alpha'):0;
  34. $action=GETPOST('action','alpha');
  35. $value=GETPOST('value', 'alpha');
  36. $page_y=GETPOST('page_y','int');
  37. $search_keyword=GETPOST('search_keyword','alpha');
  38. $search_status=GETPOST('search_status','alpha');
  39. $search_nature=GETPOST('search_nature','alpha');
  40. $search_version=GETPOST('search_version','alpha');
  41. if (! $user->admin)
  42. accessforbidden();
  43. $specialtostring=array(0=>'common', 1=>'interfaces', 2=>'other', 3=>'functional', 4=>'marketplace');
  44. $familyinfo=array(
  45. 'hr'=>array('position'=>'001', 'label'=>$langs->trans("ModuleFamilyHr")),
  46. 'crm'=>array('position'=>'006', 'label'=>$langs->trans("ModuleFamilyCrm")),
  47. 'srm'=>array('position'=>'007', 'label'=>$langs->trans("ModuleFamilySrm")),
  48. 'financial'=>array('position'=>'009', 'label'=>$langs->trans("ModuleFamilyFinancial")),
  49. 'products'=>array('position'=>'012', 'label'=>$langs->trans("ModuleFamilyProducts")),
  50. 'projects'=>array('position'=>'015', 'label'=>$langs->trans("ModuleFamilyProjects")),
  51. 'ecm'=>array('position'=>'018', 'label'=>$langs->trans("ModuleFamilyECM")),
  52. 'technic'=>array('position'=>'021', 'label'=>$langs->trans("ModuleFamilyTechnic")),
  53. 'portal'=>array('position'=>'040', 'label'=>$langs->trans("ModuleFamilyPortal")),
  54. 'interface'=>array('position'=>'050', 'label'=>$langs->trans("ModuleFamilyInterface")),
  55. 'base'=>array('position'=>'060', 'label'=>$langs->trans("ModuleFamilyBase")),
  56. 'other'=>array('position'=>'100', 'label'=>$langs->trans("ModuleFamilyOther")),
  57. );
  58. $param='';
  59. if ($search_keyword) $param.='&search_keyword='.urlencode($search_keyword);
  60. if ($search_status) $param.='&search_status='.urlencode($search_status);
  61. if ($search_nature) $param.='&search_nature='.urlencode($search_nature);
  62. if ($search_version) $param.='&search_version='.urlencode($search_version);
  63. /*
  64. * Actions
  65. */
  66. if ($action == 'set' && $user->admin)
  67. {
  68. $result=activateModule($value);
  69. if ($result) setEventMessages($result, null, 'errors');
  70. header("Location: modules.php?mode=".$mode.$param.($page_y?'&page_y='.$page_y:''));
  71. exit;
  72. }
  73. if ($action == 'reset' && $user->admin)
  74. {
  75. $result=unActivateModule($value);
  76. if ($result) setEventMessages($result, null, 'errors');
  77. header("Location: modules.php?mode=".$mode.$param.($page_y?'&page_y='.$page_y:''));
  78. exit;
  79. }
  80. if (GETPOST('buttonreset'))
  81. {
  82. $search_keyword='';
  83. $search_status='';
  84. $search_nature='';
  85. $search_version='';
  86. }
  87. /*
  88. * View
  89. */
  90. $form = new Form($db);
  91. $help_url='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
  92. llxHeader('',$langs->trans("Setup"),$help_url);
  93. $arrayofnatures=array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - '.$langs->trans("AllPublishers"));
  94. // Search modules dirs
  95. $modulesdir = dolGetModulesDirs();
  96. $filename = array();
  97. $modules = array();
  98. $orders = array();
  99. $categ = array();
  100. $dirmod = array();
  101. $i = 0; // is a sequencer of modules found
  102. $j = 0; // j is module number. Automatically affected if module number not defined.
  103. $modNameLoaded=array();
  104. foreach ($modulesdir as $dir)
  105. {
  106. // Load modules attributes in arrays (name, numero, orders) from dir directory
  107. //print $dir."\n<br>";
  108. dol_syslog("Scan directory ".$dir." for module descriptor files (modXXX.class.php)");
  109. $handle=@opendir($dir);
  110. if (is_resource($handle))
  111. {
  112. while (($file = readdir($handle))!==false)
  113. {
  114. //print "$i ".$file."\n<br>";
  115. if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
  116. {
  117. $modName = substr($file, 0, dol_strlen($file) - 10);
  118. if ($modName)
  119. {
  120. if (! empty($modNameLoaded[$modName]))
  121. {
  122. $mesg="Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.<br>";
  123. setEventMessages($mesg, null, 'warnings');
  124. dol_syslog($mesg, LOG_ERR);
  125. continue;
  126. }
  127. try
  128. {
  129. $res=include_once $dir.$file;
  130. if (class_exists($modName))
  131. {
  132. try {
  133. $objMod = new $modName($db);
  134. $modNameLoaded[$modName]=$dir;
  135. if (! $objMod->numero > 0 && $modName != 'modUser')
  136. {
  137. dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR);
  138. }
  139. $j = $objMod->numero;
  140. $modulequalified=1;
  141. // We discard modules according to features level (PS: if module is activated we always show it)
  142. $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod)));
  143. if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified=0;
  144. if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified=0;
  145. if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified=0;
  146. // We discard modules according to property disabled
  147. if (! empty($objMod->hidden)) $modulequalified=0;
  148. if ($modulequalified > 0)
  149. {
  150. $publisher=dol_escape_htmltag($objMod->getPublisher());
  151. $external=($objMod->isCoreOrExternalModule() == 'external');
  152. if ($external)
  153. {
  154. if ($publisher)
  155. {
  156. $arrayofnatures['external_'.$publisher]=$langs->trans("External").' - '.$publisher;
  157. }
  158. else
  159. {
  160. $arrayofnatures['external_']=$langs->trans("External").' - '.$langs->trans("UnknownPublishers");
  161. }
  162. }
  163. ksort($arrayofnatures);
  164. }
  165. // Define array $categ with categ with at least one qualified module
  166. if ($modulequalified > 0)
  167. {
  168. $modules[$i] = $objMod;
  169. $filename[$i]= $modName;
  170. $special = $objMod->special;
  171. // Gives the possibility to the module, to provide his own family info and position of this family
  172. if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) {
  173. $familyinfo = array_merge($familyinfo, $objMod->familyinfo);
  174. $familykey = key($objMod->familyinfo);
  175. } else {
  176. $familykey = $objMod->family;
  177. }
  178. $moduleposition = ($objMod->module_position?$objMod->module_position:'500');
  179. if ($moduleposition == 500 && ($objMod->isCoreOrExternalModule() == 'external'))
  180. {
  181. $moduleposition = 800;
  182. }
  183. if ($special == 1) $familykey='interface';
  184. $orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number
  185. $dirmod[$i] = $dir;
  186. //print $i.'-'.$dirmod[$i].'<br>';
  187. // Set categ[$i]
  188. $specialstring = isset($specialtostring[$special])?$specialtostring[$special]:'unknown';
  189. if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring='expdev';
  190. if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories
  191. else $categ[$specialstring]=1;
  192. $j++;
  193. $i++;
  194. }
  195. else dol_syslog("Module ".get_class($objMod)." not qualified");
  196. }
  197. catch(Exception $e)
  198. {
  199. dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
  200. }
  201. }
  202. else
  203. {
  204. print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)<br>";
  205. }
  206. }
  207. catch(Exception $e)
  208. {
  209. dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
  210. }
  211. }
  212. }
  213. }
  214. closedir($handle);
  215. }
  216. else
  217. {
  218. dol_syslog("htdocs/admin/modules.php: Failed to open directory ".$dir.". See permission and open_basedir option.", LOG_WARNING);
  219. }
  220. }
  221. asort($orders);
  222. //var_dump($orders);
  223. //var_dump($categ);
  224. //var_dump($modules);
  225. $nbofactivatedmodules=count($conf->modules);
  226. $moreinfo=$langs->trans("TotalNumberOfActivatedModules",($nbofactivatedmodules-1), count($modules));
  227. if ($nbofactivatedmodules <= 1) $moreinfo .= ' '.img_warning($langs->trans("YouMustEnableOneModule"));
  228. print load_fiche_titre($langs->trans("ModulesSetup"),$moreinfo,'title_setup');
  229. // Start to show page
  230. if (empty($mode)) $mode='common';
  231. if ($mode==='common') print $langs->trans("ModulesDesc")."<br>\n";
  232. if ($mode==='marketplace') print $langs->trans("ModulesMarketPlaceDesc")."<br>\n";
  233. if ($mode==='expdev') print $langs->trans("ModuleFamilyExperimental")."<br>\n";
  234. $h = 0;
  235. $categidx='common'; // Main
  236. //if (! empty($categ[$categidx]))
  237. //{
  238. $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=".$categidx;
  239. $head[$h][1] = $langs->trans("AvailableModules");
  240. $head[$h][2] = 'common';
  241. $h++;
  242. //}
  243. /*$categidx='expdev';
  244. if (! empty($categ[$categidx]))
  245. {
  246. $categidx='expdev';
  247. $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=".$categidx;
  248. $head[$h][1] = $form->textwithpicto($langs->trans("ModuleFamilyExperimental"), $langs->trans('DoNotUseInProduction'), 1, 'warning', '', 0, 3);
  249. $head[$h][2] = 'expdev';
  250. $h++;
  251. }*/
  252. $categidx='marketplace';
  253. $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=".$categidx;
  254. $head[$h][1] = $langs->trans("ModulesMarketPlaces");
  255. $head[$h][2] = 'marketplace';
  256. $h++;
  257. print "<br>\n";
  258. dol_fiche_head($head, $mode, '');
  259. $var=true;
  260. if ($mode != 'marketplace')
  261. {
  262. print '<form method="GET" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  263. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  264. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  265. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  266. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  267. $moreforfilter = '';
  268. $moreforfilter.='<div class="divsearchfield">';
  269. $moreforfilter.= $langs->trans('Keyword') . ': <input type="text" name="search_keyword" value="'.dol_escape_htmltag($search_keyword).'">';
  270. $moreforfilter.= '</div>';
  271. $moreforfilter.='<div class="divsearchfield">';
  272. $moreforfilter.= $langs->trans('Origin') . ': '.$form->selectarray('search_nature', $arrayofnatures, $search_nature, 1);
  273. $moreforfilter.= '</div>';
  274. if (! empty($conf->global->MAIN_FEATURES_LEVEL))
  275. {
  276. $array_version = array('stable'=>$langs->transnoentitiesnoconv("Stable"));
  277. if ($conf->global->MAIN_FEATURES_LEVEL < 0) $array_version['deprecated']=$langs->trans("Deprecated");
  278. if ($conf->global->MAIN_FEATURES_LEVEL > 0) $array_version['experimental']=$langs->trans("Experimental");
  279. if ($conf->global->MAIN_FEATURES_LEVEL > 1) $array_version['development']=$langs->trans("Development");
  280. $moreforfilter.='<div class="divsearchfield">';
  281. $moreforfilter.= $langs->trans('Version') . ': '.$form->selectarray('search_version', $array_version, $search_version, 1);
  282. $moreforfilter.= '</div>';
  283. }
  284. $moreforfilter.='<div class="divsearchfield">';
  285. $moreforfilter.= $langs->trans('Status') . ': '.$form->selectarray('search_status', array('active'=>$langs->transnoentitiesnoconv("Enabled"), 'disabled'=>$langs->transnoentitiesnoconv("Disabled")), $search_status, 1);
  286. $moreforfilter.= '</div>';
  287. $moreforfilter.=' ';
  288. $moreforfilter.='<div class="divsearchfield">';
  289. $moreforfilter.='<input type="submit" name="buttonsubmit" class="button" value="'.dol_escape_htmltag($langs->trans("Refresh")).'">';
  290. $moreforfilter.=' ';
  291. $moreforfilter.='<input type="submit" name="buttonreset" class="button" value="'.dol_escape_htmltag($langs->trans("Reset")).'">';
  292. $moreforfilter.= '</div>';
  293. if (! empty($moreforfilter))
  294. {
  295. //print '<div class="liste_titre liste_titre_bydiv centpercent">';
  296. print $moreforfilter;
  297. $parameters=array();
  298. $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
  299. print $hookmanager->resPrint;
  300. //print '</div>';
  301. }
  302. print '<br><br><br>';
  303. // Show list of modules
  304. print '<table summary="list_of_modules" id="list_of_modules" class="liste" width="100%">'."\n";
  305. $oldfamily='';
  306. foreach ($orders as $key => $value)
  307. {
  308. $tab=explode('_',$value);
  309. $familyposition=$tab[0]; $familykey=$tab[1]; $module_position=$tab[2]; $numero=$tab[3];
  310. $modName = $filename[$key];
  311. $objMod = $modules[$key];
  312. $dirofmodule = $dirmod[$key];
  313. $special = $objMod->special;
  314. //print $objMod->name." - ".$key." - ".$objMod->special.' - '.$objMod->version."<br>";
  315. //if (($mode != (isset($specialtostring[$special])?$specialtostring[$special]:'unknown') && $mode != 'expdev')
  316. if (($special >= 4 && $mode != 'expdev')
  317. || ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental')) continue; // Discard if not for current tab
  318. if (! $objMod->getName())
  319. {
  320. dol_syslog("Error for module ".$key." - Property name of module looks empty", LOG_WARNING);
  321. continue;
  322. }
  323. $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod)));
  324. // Check filters
  325. $modulename=$objMod->getName();
  326. $moduledesc=$objMod->getDesc();
  327. $moduledesclong=$objMod->getDescLong();
  328. $moduleauthor=$objMod->getPublisher();
  329. // We discard showing according to filters
  330. if ($search_keyword)
  331. {
  332. $qualified=0;
  333. if (preg_match('/'.preg_quote($search_keyword).'/i', $modulename)
  334. || preg_match('/'.preg_quote($search_keyword).'/i', $moduledesc)
  335. || preg_match('/'.preg_quote($search_keyword).'/i', $moduledesclong)
  336. || preg_match('/'.preg_quote($search_keyword).'/i', $moduleauthor)
  337. ) $qualified=1;
  338. if (! $qualified) continue;
  339. }
  340. if ($search_status)
  341. {
  342. if ($search_status == 'active' && empty($conf->global->$const_name)) continue;
  343. if ($search_status == 'disabled' && ! empty($conf->global->$const_name)) continue;
  344. }
  345. if ($search_nature)
  346. {
  347. if (preg_match('/^external/',$search_nature) && $objMod->isCoreOrExternalModule() != 'external') continue;
  348. if (preg_match('/^external_(.*)$/',$search_nature, $reg))
  349. {
  350. //print $reg[1].'-'.dol_escape_htmltag($objMod->getPublisher());
  351. $publisher=dol_escape_htmltag($objMod->getPublisher());
  352. if ($reg[1] && $reg[1] != $publisher) continue;
  353. if (! $reg[1] && ! empty($publisher)) continue;
  354. }
  355. if ($search_nature == 'core' && $objMod->isCoreOrExternalModule() == 'external') continue;
  356. }
  357. if ($search_version)
  358. {
  359. if (($objMod->version == 'development' || $objMod->version == 'experimental' || preg_match('/deprecated/', $objMod->version)) && $search_version == 'stable') continue;
  360. if ($objMod->version != 'development' && ($search_version == 'development')) continue;
  361. if ($objMod->version != 'experimental' && ($search_version == 'experimental')) continue;
  362. if (! preg_match('/deprecated/', $objMod->version) && ($search_version == 'deprecated')) continue;
  363. }
  364. // Load all lang files of module
  365. if (isset($objMod->langfiles) && is_array($objMod->langfiles))
  366. {
  367. foreach($objMod->langfiles as $domain)
  368. {
  369. $langs->load($domain);
  370. }
  371. }
  372. // Print a separator if we change family
  373. //print "<tr><td>xx".$oldfamily."-".$familykey."-".$atleastoneforfamily."<br></td><tr>";
  374. //if ($oldfamily && $familykey!=$oldfamily && $atleastoneforfamily) {
  375. if ($familykey!=$oldfamily)
  376. {
  377. print '<tr class="liste_titre">'."\n";
  378. print '<td colspan="5">';
  379. $familytext=empty($familyinfo[$familykey]['label'])?$familykey:$familyinfo[$familykey]['label'];
  380. print $familytext;
  381. print "</td>\n";
  382. print '<td colspan="2" align="right">'.$langs->trans("SetupShort").'</td>'."\n";
  383. print "</tr>\n";
  384. $atleastoneforfamily=0;
  385. //print "<tr><td>yy".$oldfamily."-".$familykey."-".$atleastoneforfamily."<br></td><tr>";
  386. }
  387. $atleastoneforfamily++;
  388. if ($familykey!=$oldfamily)
  389. {
  390. $familytext=empty($familyinfo[$familykey]['label'])?$familykey:$familyinfo[$familykey]['label'];
  391. $oldfamily=$familykey;
  392. }
  393. $var=!$var;
  394. //print "\n<!-- Module ".$objMod->numero." ".$objMod->getName()." found into ".$dirmod[$key]." -->\n";
  395. print '<tr '.$bc[$var].">\n";
  396. // Picto
  397. print ' <td valign="top" width="14" align="center">';
  398. $alttext='';
  399. //if (is_array($objMod->need_dolibarr_version)) $alttext.=($alttext?' - ':'').'Dolibarr >= '.join('.',$objMod->need_dolibarr_version);
  400. //if (is_array($objMod->phpmin)) $alttext.=($alttext?' - ':'').'PHP >= '.join('.',$objMod->phpmin);
  401. if (! empty($objMod->picto))
  402. {
  403. if (preg_match('/^\//i',$objMod->picto)) print img_picto($alttext,$objMod->picto,' width="14px"',1);
  404. else print img_object($alttext,$objMod->picto,' width="14px"');
  405. }
  406. else
  407. {
  408. print img_object($alttext,'generic');
  409. }
  410. print '</td>';
  411. // Name
  412. print '<td valign="top">'.$objMod->getName();
  413. print "</td>\n";
  414. // Desc
  415. print '<td valign="top">';
  416. print nl2br($objMod->getDesc());
  417. print "</td>\n";
  418. // Help
  419. print '<td align="center" valign="top" class="nowrap" style="width: 82px;">';
  420. $text='';
  421. if ($objMod->getDescLong()) $text.=$objMod->getDesc().'<br>'.$objMod->getDescLong().'<br>';
  422. else $text.=$objMod->getDesc().'<br>';
  423. $textexternal='';
  424. if ($objMod->isCoreOrExternalModule() == 'external')
  425. {
  426. $textexternal.='<br><strong>'.$langs->trans("Origin").':</strong> '.$langs->trans("ExternalModule",$dirofmodule);
  427. if ($objMod->editor_name != 'dolibarr') $textexternal.='<br><strong>'.$langs->trans("Publisher").':</strong> '.(empty($objMod->editor_name)?$langs->trans("Unknown"):$objMod->editor_name);
  428. if (! empty($objMod->editor_url) && ! preg_match('/dolibarr\.org/i',$objMod->editor_url)) $textexternal.='<br><strong>'.$langs->trans("Url").':</strong> '.$objMod->editor_url;
  429. $text.=$textexternal;
  430. $text.='<br>';
  431. }
  432. else
  433. {
  434. $text.='<br><strong>'.$langs->trans("Origin").':</strong> '.$langs->trans("Core").'<br>';
  435. }
  436. $text.='<br><strong>'.$langs->trans("AddRemoveTabs").':</strong> ';
  437. if (isset($objMod->tabs) && is_array($objMod->tabs) && count($objMod->tabs))
  438. {
  439. $i=0;
  440. foreach($objMod->tabs as $val)
  441. {
  442. $tmp=explode(':',$val,3);
  443. $text.=($i?', ':'').$tmp[0].':'.$tmp[1];
  444. $i++;
  445. }
  446. }
  447. else $text.=$langs->trans("No");
  448. $text.='<br><strong>'.$langs->trans("AddDictionaries").':</strong> ';
  449. if (isset($objMod->dictionaries) && isset($objMod->dictionaries['tablib']) && is_array($objMod->dictionaries['tablib']) && count($objMod->dictionaries['tablib']))
  450. {
  451. $i=0;
  452. foreach($objMod->dictionaries['tablib'] as $val)
  453. {
  454. $text.=($i?', ':'').$val;
  455. $i++;
  456. }
  457. }
  458. else $text.=$langs->trans("No");
  459. $text.='<br><strong>'.$langs->trans("AddBoxes").':</strong> ';
  460. if (isset($objMod->boxes) && is_array($objMod->boxes) && count($objMod->boxes))
  461. {
  462. $i=0;
  463. foreach($objMod->boxes as $val)
  464. {
  465. $text.=($i?', ':'').($val['file']?$val['file']:$val[0]);
  466. $i++;
  467. }
  468. }
  469. else $text.=$langs->trans("No");
  470. $text.='<br><strong>'.$langs->trans("AddModels").':</strong> ';
  471. if (isset($objMod->module_parts) && isset($objMod->module_parts['models']) && $objMod->module_parts['models'])
  472. {
  473. $text.=$langs->trans("Yes");
  474. }
  475. else $text.=$langs->trans("No");
  476. $text.='<br><strong>'.$langs->trans("AddSubstitutions").':</strong> ';
  477. if (isset($objMod->module_parts) && isset($objMod->module_parts['substitutions']) && $objMod->module_parts['substitutions'])
  478. {
  479. $text.=$langs->trans("Yes");
  480. }
  481. else $text.=$langs->trans("No");
  482. $text.='<br><strong>'.$langs->trans("AddSheduledJobs").':</strong> ';
  483. if (isset($objMod->cronjobs) && is_array($objMod->cronjobs) && count($objMod->cronjobs))
  484. {
  485. $i=0;
  486. foreach($objMod->cronjobs as $val)
  487. {
  488. $text.=($i?', ':'').($val['label']);
  489. $i++;
  490. }
  491. }
  492. else $text.=$langs->trans("No");
  493. $text.='<br><strong>'.$langs->trans("AddTriggers").':</strong> ';
  494. if (isset($objMod->module_parts) && isset($objMod->module_parts['triggers']) && $objMod->module_parts['triggers'])
  495. {
  496. $text.=$langs->trans("Yes");
  497. }
  498. else $text.=$langs->trans("No");
  499. $text.='<br><strong>'.$langs->trans("AddHooks").':</strong> ';
  500. if (isset($objMod->module_parts) && is_array($objMod->module_parts['hooks']) && count($objMod->module_parts['hooks']))
  501. {
  502. $i=0;
  503. foreach($objMod->module_parts['hooks'] as $val)
  504. {
  505. $text.=($i?', ':'').($val);
  506. $i++;
  507. }
  508. }
  509. else $text.=$langs->trans("No");
  510. $text.='<br><strong>'.$langs->trans("AddPermissions").':</strong> ';
  511. if (isset($objMod->rights) && is_array($objMod->rights) && count($objMod->rights))
  512. {
  513. $i=0;
  514. foreach($objMod->rights as $val)
  515. {
  516. $text.=($i?', ':'').($val[1]);
  517. $i++;
  518. }
  519. }
  520. else $text.=$langs->trans("No");
  521. $text.='<br><strong>'.$langs->trans("AddMenus").':</strong> ';
  522. if (isset($objMod->menu) && is_array($objMod->menu) && ! empty($objMod->menu))
  523. {
  524. $text.=$langs->trans("Yes");
  525. }
  526. else $text.=$langs->trans("No");
  527. $text.='<br><strong>'.$langs->trans("AddExportProfiles").':</strong> ';
  528. if (isset($objMod->export_label) && is_array($objMod->export_label) && count($objMod->export_label))
  529. {
  530. $i=0;
  531. foreach($objMod->export_label as $val)
  532. {
  533. $text.=($i?', ':'').($val);
  534. $i++;
  535. }
  536. }
  537. else $text.=$langs->trans("No");
  538. $text.='<br><strong>'.$langs->trans("AddImportProfiles").':</strong> ';
  539. if (isset($objMod->import_label) && is_array($objMod->import_label) && count($objMod->import_label))
  540. {
  541. $i=0;
  542. foreach($objMod->import_label as $val)
  543. {
  544. $text.=($i?', ':'').($val);
  545. $i++;
  546. }
  547. }
  548. else $text.=$langs->trans("No");
  549. $text.='<br><strong>'.$langs->trans("AddOtherPagesOrServices").':</strong> ';
  550. $text.=$langs->trans("DetectionNotPossible");
  551. print $form->textwithpicto('', $text, 1, 'help', 'minheight20');
  552. // Picto warning
  553. $version=$objMod->getVersion(0);
  554. $versiontrans=$objMod->getVersion(1);
  555. if (preg_match('/development/i', $version)) print img_warning($langs->trans("Development"), 'style="float: right"');
  556. if (preg_match('/experimental/i', $version)) print img_warning($langs->trans("Experimental"), 'style="float: right"');
  557. if (preg_match('/deprecated/i', $version)) print img_warning($langs->trans("Deprecated"), 'style="float: right"');
  558. // Picto external
  559. if ($textexternal) print img_picto($langs->trans("ExternalModule",$dirofmodule), 'external', 'style="float: right"');
  560. print '</td>';
  561. // Version
  562. print '<td align="center" valign="top" class="nowrap">';
  563. print $versiontrans;
  564. print "</td>\n";
  565. // Activate/Disable and Setup (2 columns)
  566. if (! empty($conf->global->$const_name)) // If module is activated
  567. {
  568. $disableSetup = 0;
  569. print '<td align="center" valign="middle">';
  570. if (! empty($objMod->disabled))
  571. {
  572. print $langs->trans("Disabled");
  573. }
  574. else if (! empty($objMod->always_enabled) || ((! empty($conf->multicompany->enabled) && $objMod->core_enabled) && ($user->entity || $conf->entity!=1)))
  575. {
  576. print $langs->trans("Required");
  577. if (! empty($conf->multicompany->enabled) && $user->entity) $disableSetup++;
  578. }
  579. else
  580. {
  581. print '<a class="reposition" href="modules.php?id='.$objMod->numero.'&amp;module_position='.$module_position.'&amp;action=reset&amp;value=' . $modName . '&amp;mode=' . $mode . $param . '">';
  582. print img_picto($langs->trans("Activated"),'switch_on');
  583. print '</a>';
  584. }
  585. print '</td>'."\n";
  586. // Config link
  587. if (! empty($objMod->config_page_url) && !$disableSetup)
  588. {
  589. if (is_array($objMod->config_page_url))
  590. {
  591. print '<td class="tdsetuppicto" align="right" valign="top">';
  592. $i=0;
  593. foreach ($objMod->config_page_url as $page)
  594. {
  595. $urlpage=$page;
  596. if ($i++)
  597. {
  598. print '<a href="'.$urlpage.'" title="'.$langs->trans($page).'">'.img_picto(ucfirst($page),"setup").'</a>';
  599. // print '<a href="'.$page.'">'.ucfirst($page).'</a>&nbsp;';
  600. }
  601. else
  602. {
  603. if (preg_match('/^([^@]+)@([^@]+)$/i',$urlpage,$regs))
  604. {
  605. print '<a href="'.dol_buildpath('/'.$regs[2].'/admin/'.$regs[1],1).'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').'</a>';
  606. }
  607. else
  608. {
  609. print '<a href="'.$urlpage.'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').'</a>';
  610. }
  611. }
  612. }
  613. print "</td>\n";
  614. }
  615. else if (preg_match('/^([^@]+)@([^@]+)$/i',$objMod->config_page_url,$regs))
  616. {
  617. print '<td class="tdsetuppicto" align="right" valign="middle"><a href="'.dol_buildpath('/'.$regs[2].'/admin/'.$regs[1],1).'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').'</a></td>';
  618. }
  619. else
  620. {
  621. print '<td class="tdsetuppicto" align="right" valign="middle"><a href="'.$objMod->config_page_url.'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').'</a></td>';
  622. }
  623. }
  624. else
  625. {
  626. print '<td class="tdsetuppicto" align="right" valign="middle">'.img_picto($langs->trans("NothingToSetup"),"setup",'class="opacitytransp" style="padding-right: 6px"').'</td>';
  627. }
  628. }
  629. else // Module not activated
  630. {
  631. print '<td align="center" valign="middle">';
  632. if (! empty($objMod->always_enabled))
  633. {
  634. // Ne devrait pas arriver.
  635. }
  636. else if (! empty($objMod->disabled))
  637. {
  638. print $langs->trans("Disabled");
  639. }
  640. else
  641. {
  642. // Module non actif
  643. print '<a class="reposition" href="modules.php?id='.$objMod->numero.'&amp;module_position='.$module_position.'&amp;action=set&amp;value=' . $modName . '&amp;mode=' . $mode . $param . '">';
  644. print img_picto($langs->trans("Disabled"),'switch_off');
  645. print "</a>\n";
  646. }
  647. print "</td>\n";
  648. print '<td class="tdsetuppicto" align="right" valign="middle">'.img_picto($langs->trans("NothingToSetup"),"setup",'class="opacitytransp" style="padding-right: 6px"').'</td>';
  649. }
  650. print "</tr>\n";
  651. }
  652. print "</table>\n";
  653. }
  654. else
  655. {
  656. // Marketplace
  657. print "<table summary=\"list_of_modules\" class=\"noborder\" width=\"100%\">\n";
  658. print "<tr class=\"liste_titre\">\n";
  659. //print '<td>'.$langs->trans("Logo").'</td>';
  660. print '<td colspan="2">'.$langs->trans("WebSiteDesc").'</td>';
  661. print '<td>'.$langs->trans("URL").'</td>';
  662. print '</tr>';
  663. $var=!$var;
  664. print "<tr ".$bc[$var].">\n";
  665. $url='https://www.dolistore.com';
  666. print '<td align="left"><a href="'.$url.'" target="_blank" rel="external"><img border="0" width="180" src="'.DOL_URL_ROOT.'/theme/dolistore_logo.png"></a></td>';
  667. print '<td>'.$langs->trans("DoliStoreDesc").'</td>';
  668. print '<td><a href="'.$url.'" target="_blank" rel="external">'.$url.'</a></td>';
  669. print '</tr>';
  670. $var=!$var;
  671. print "<tr ".$bc[$var].">\n";
  672. $url='https://partners.dolibarr.org';
  673. print '<td align="left"><a href="'.$url.'" target="_blank" rel="external"><img border="0" width="180" src="'.DOL_URL_ROOT.'/theme/dolibarr_preferred_partner_int.png"></a></td>';
  674. print '<td>'.$langs->trans("DoliPartnersDesc").'</td>';
  675. print '<td><a href="'.$url.'" target="_blank" rel="external">'.$url.'</a></td>';
  676. print '</tr>';
  677. print "</table>\n";
  678. }
  679. dol_fiche_end();
  680. // Show warning about external users
  681. if ($mode != 'marketplace') print info_admin(showModulesExludedForExternal($modules))."\n";
  682. llxFooter();
  683. $db->close();