PageRenderTime 41ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/admin/modules.php

https://bitbucket.org/speedealing/speedealing
PHP | 295 lines | 203 code | 52 blank | 40 comment | 22 complexity | 96b63a4314782a1a8e16f5b9af45034b MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  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-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
  6. * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
  7. * Copyright (C) 2011-2013 Herve Prot <herve.prot@symeos.com>
  8. * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. */
  23. require '../main.inc.php';
  24. require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
  25. $langs->load("errors");
  26. $langs->load("admin");
  27. if (empty($user->admin))
  28. accessforbidden();
  29. $action = GETPOST('action', 'alpha');
  30. $object = new DolibarrModules($db);
  31. $filename = array();
  32. $modules = array();
  33. $orders = array();
  34. $categ = array();
  35. $dirmod = array();
  36. $i = 0; // is a sequencer of modules found
  37. $j = 0; // j is module number. Automatically affected if module number not defined.
  38. $modNameLoaded = array();
  39. $mesg = $object->load_modules_files($filename, $modules, $orders, $categ, $dirmod, $modNameLoaded);
  40. if (!empty($mesg))
  41. setEventMessage($mesg, 'errors');
  42. /*
  43. * Actions
  44. */
  45. /*
  46. * View
  47. */
  48. llxHeader('', $langs->trans("Setup"));
  49. print_fiche_titre($langs->trans("Setup"));
  50. print '<div class="with-padding">';
  51. print '<div class="columns">';
  52. print start_box($langs->trans("ModulesSetup"), 'icon-object-config', '', false);
  53. $obj = new stdClass();
  54. $i = 0;
  55. print '<table class="display dt_act" id="list_modules">';
  56. print'<thead>';
  57. print'<tr>';
  58. print'<th>';
  59. print'</th>';
  60. $obj->aoColumns[$i] = new stdClass();
  61. $obj->aoColumns[$i]->mDataProp = "id";
  62. $obj->aoColumns[$i]->sDefaultContent = "";
  63. $obj->aoColumns[$i]->bVisible = false;
  64. $i++;
  65. print'<th class="essential">';
  66. print $langs->trans("Family");
  67. print'</th>';
  68. $obj->aoColumns[$i] = new stdClass();
  69. $obj->aoColumns[$i]->mDataProp = "family";
  70. $obj->aoColumns[$i]->sDefaultContent = "other";
  71. $obj->aoColumns[$i]->bVisible = false;
  72. $i++;
  73. print'<th class="essential">';
  74. print $langs->trans("Module");
  75. print'</th>';
  76. $obj->aoColumns[$i] = new stdClass();
  77. $obj->aoColumns[$i]->mDataProp = "name";
  78. $obj->aoColumns[$i]->sDefaultContent = "";
  79. $i++;
  80. print'<th>';
  81. print $langs->trans("Description");
  82. print'</th>';
  83. $obj->aoColumns[$i] = new stdClass();
  84. $obj->aoColumns[$i]->mDataProp = "desc";
  85. $obj->aoColumns[$i]->sDefaultContent = "";
  86. $obj->aoColumns[$i]->bVisible = true;
  87. $i++;
  88. print'<th class="essential">';
  89. print $langs->trans("Version");
  90. print'</th>';
  91. $obj->aoColumns[$i] = new stdClass();
  92. $obj->aoColumns[$i]->mDataProp = "version";
  93. $obj->aoColumns[$i]->sDefaultContent = "false";
  94. $obj->aoColumns[$i]->sClass = "center";
  95. $obj->aoColumns[$i]->sWidth = "100px";
  96. $i++;
  97. print'<th class="essential">';
  98. print $langs->trans("Status");
  99. print'</th>';
  100. $obj->aoColumns[$i] = new stdClass();
  101. $obj->aoColumns[$i]->mDataProp = "Status";
  102. $obj->aoColumns[$i]->sDefaultContent = "false";
  103. $obj->aoColumns[$i]->sClass = "center";
  104. $i++;
  105. print'<th class="essential">';
  106. print $langs->trans("SetupShort");
  107. print'</th>';
  108. $obj->aoColumns[$i] = new stdClass();
  109. $obj->aoColumns[$i]->mDataProp = "setup";
  110. $obj->aoColumns[$i]->sDefaultContent = "";
  111. $obj->aoColumns[$i]->bSortable = false;
  112. $obj->aoColumns[$i]->sClass = "center";
  113. print'</tr>';
  114. print'</thead>';
  115. $obj->fnDrawCallback = "
  116. function(oSettings) {
  117. if ( oSettings.aiDisplay.length == 0 ) {
  118. return;
  119. }
  120. var nTrs = jQuery('#list_modules tbody tr');
  121. var iColspan = nTrs[0].getElementsByTagName('td').length;
  122. var sLastGroup = '';
  123. for ( var i=0 ; i<nTrs.length ; i++ ) {
  124. var iDisplayIndex = oSettings._iDisplayStart + i;
  125. var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData['family'];
  126. if (sGroup!=null && sGroup!='' && sGroup != sLastGroup) {
  127. var nGroup = document.createElement('tr');
  128. var nCell = document.createElement('td');
  129. nCell.colSpan = iColspan;
  130. nCell.className = 'group';
  131. nCell.innerHTML = sGroup;
  132. nGroup.appendChild( nCell );
  133. nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
  134. sLastGroup = sGroup;
  135. }
  136. }
  137. }";
  138. print'<tfoot>';
  139. print'</tfoot>';
  140. print'<tbody>';
  141. // Affichage liste modules
  142. $var = true;
  143. $oldfamily = '';
  144. $familylib = array(
  145. 'base' => $langs->trans("ModuleFamilyBase"),
  146. 'crm' => $langs->trans("ModuleFamilyCrm"),
  147. 'products' => $langs->trans("ModuleFamilyProducts"),
  148. 'hr' => $langs->trans("ModuleFamilyHr"),
  149. 'projects' => $langs->trans("ModuleFamilyProjects"),
  150. 'financial' => $langs->trans("ModuleFamilyFinancial"),
  151. 'ecm' => $langs->trans("ModuleFamilyECM"),
  152. 'technic' => $langs->trans("ModuleFamilyTechnic"),
  153. 'other' => $langs->trans("ModuleFamilyOther")
  154. );
  155. foreach ($orders as $key => $value) {
  156. $tab = explode('_', $value);
  157. $family = $tab[0];
  158. $numero = $tab[1];
  159. $modName = $filename[$key];
  160. $objMod = $modules[$key];
  161. //var_dump($objMod);
  162. if (!$objMod->getName()) {
  163. continue;
  164. }
  165. $const_name = 'MAIN_MODULE_' . strtoupper(preg_replace('/^mod/i', '', get_class($objMod)));
  166. // Load all lang files of module
  167. if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
  168. foreach ($objMod->langfiles as $domain) {
  169. $langs->load($domain);
  170. }
  171. }
  172. //print "\n<!-- Module ".$objMod->numero." ".$objMod->getName()." found into ".$dirmod[$key]." -->\n";
  173. print '<tr>';
  174. // Id
  175. print '<td>';
  176. print $objMod->numero;
  177. print '</td>';
  178. // Family
  179. print '<td>';
  180. $family = $objMod->family;
  181. print $familytext = empty($familylib[$family]) ? $family : $familylib[$family];
  182. print "</td>\n";
  183. // Picto
  184. print ' <td>';
  185. $alttext = '';
  186. //if (is_array($objMod->need_dolibarr_version)) $alttext.=($alttext?' - ':'').'Dolibarr >= '.join('.',$objMod->need_dolibarr_version);
  187. //if (is_array($objMod->phpmin)) $alttext.=($alttext?' - ':'').'PHP >= '.join('.',$objMod->phpmin);
  188. if (!empty($objMod->picto)) {
  189. if (preg_match('/^\//i', $objMod->picto))
  190. print img_picto($alttext, $objMod->picto, ' width="14px"', 1);
  191. else
  192. print img_object($alttext, $objMod->picto, ' width="14px"');
  193. }
  194. else {
  195. print img_object($alttext, 'generic');
  196. }
  197. // Name
  198. print ' ' . $objMod->getName();
  199. print "</td>\n";
  200. // Desc
  201. print "<td>";
  202. print nl2br($objMod->getDesc());
  203. print "</td>\n";
  204. // Version
  205. print "<td>";
  206. print $objMod->getVersion();
  207. print "</td>\n";
  208. // Activate/Disable and Setup (2 columns)
  209. print '<td>';
  210. print ajax_moduleonoff($objMod, $key);
  211. print '</td>' . "\n";
  212. print '<td>';
  213. if (!empty($objMod->config_page_url)) {
  214. print '<div id="config_' . $key . '" class="hideobject">';
  215. if (is_array($objMod->config_page_url)) {
  216. foreach ($objMod->config_page_url as $page) {
  217. if (preg_match('/^([^@]+)@([^@]+)$/i', $page, $regs)) {
  218. print '<a href="' . dol_buildpath('/' . $regs[2] . '/admin/' . $regs[1], 1) . '" title="' . $langs->trans("Setup") . '">' . img_picto($langs->trans("Setup"), "setup") . '</a>&nbsp;';
  219. } else {
  220. print '<a href="' . DOL_URL_ROOT . '/admin/' . $page . '" title="' . $langs->trans("Setup") . '">' . img_picto($langs->trans("Setup"), "setup") . '</a>&nbsp;';
  221. }
  222. }
  223. } else if (preg_match('/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) {
  224. print '<a href="' . dol_buildpath('/' . $regs[2] . '/admin/' . $regs[1], 1) . '" title="' . $langs->trans("Setup") . '">' . img_picto($langs->trans("Setup"), "setup") . '</a>';
  225. } else {
  226. print '<a href="' . $objMod->config_page_url . '" title="' . $langs->trans("Setup") . '">' . img_picto($langs->trans("Setup"), "setup") . '</a>';
  227. }
  228. print '</div>';
  229. }
  230. print "</td>\n";
  231. print "</tr>\n";
  232. }
  233. print'</tbody>';
  234. print'</table>';
  235. $obj->aaSorting = array(array(1, 'asc'));
  236. $obj->sDom = 'l<fr>t<\"clear\"rtip>';
  237. $obj->iDisplayLength = 100;
  238. $obj->bServerSide = false;
  239. print $object->datatablesCreate($obj, "list_modules");
  240. print end_box();
  241. print '</div></div>';
  242. llxFooter();
  243. ?>