PageRenderTime 65ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/admin/system/modules.php

https://github.com/asterix14/dolibarr
PHP | 157 lines | 112 code | 16 blank | 29 comment | 26 complexity | 8666019776ac65bac5030be3927417d4 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  4. * Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/admin/system/modules.php
  21. * \brief File to list all Dolibarr modules
  22. */
  23. require("../../main.inc.php");
  24. $langs->load("admin");
  25. $langs->load("install");
  26. $langs->load("other");
  27. if (!$user->admin)
  28. accessforbidden();
  29. /*
  30. * View
  31. */
  32. llxHeader();
  33. print_fiche_titre($langs->trans("AvailableModules"),'','setup');
  34. print $langs->trans("ToActivateModule").'<br>';
  35. print "<br>\n";
  36. $modules = array();
  37. $modules_names = array();
  38. $modules_files = array();
  39. foreach ($conf->file->dol_document_root as $type => $dirroot)
  40. {
  41. $modulesdir[] = $dirroot . "/core/modules/";
  42. if ($type == 'alt')
  43. {
  44. $handle=@opendir($dirroot);
  45. if (is_resource($handle))
  46. {
  47. while (($file = readdir($handle))!==false)
  48. {
  49. if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes')
  50. {
  51. if (is_dir($dirroot . '/' . $file . '/core/modules/'))
  52. {
  53. $modulesdir[] = $dirroot . '/' . $file . '/core/modules/';
  54. }
  55. }
  56. }
  57. closedir($handle);
  58. }
  59. }
  60. }
  61. // Load list of modules
  62. foreach($modulesdir as $dir)
  63. {
  64. $handle=@opendir($dir);
  65. if (is_resource($handle))
  66. {
  67. while (($file = readdir($handle))!==false)
  68. {
  69. if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
  70. {
  71. $modName = substr($file, 0, dol_strlen($file) - 10);
  72. if ($modName)
  73. {
  74. include_once($dir.$file);
  75. $objMod = new $modName($db);
  76. $modules[$objMod->numero]=$objMod;
  77. $modules_names[$objMod->numero]=$objMod->name;
  78. $modules_files[$objMod->numero]=$file;
  79. $picto[$objMod->numero]=(isset($objMod->picto) && $objMod->picto)?$objMod->picto:'generic';
  80. }
  81. }
  82. }
  83. closedir($handle);
  84. }
  85. }
  86. print '<table class="noborder" width="100%">';
  87. print '<tr class="liste_titre">';
  88. print '<td>'.$langs->trans("Modules").'</td>';
  89. print '<td>'.$langs->trans("Version").'</td>';
  90. print '<td align="center">'.$langs->trans("Id Module").'</td>';
  91. print '<td>'.$langs->trans("Id Permissions").'</td>';
  92. print '</tr>';
  93. $var=false;
  94. $sortorder=$modules_names;
  95. ksort($sortorder);
  96. $rights_ids = array();
  97. foreach($sortorder as $numero=>$name)
  98. {
  99. $idperms="";
  100. $var=!$var;
  101. // Module
  102. print "<tr $bc[$var]><td width=\"300\" nowrap=\"nowrap\">";
  103. $alt=$name.' - '.$modules_files[$numero];
  104. if (! empty($picto[$numero]))
  105. {
  106. if (preg_match('/^\//',$picto[$numero])) print img_picto($alt,$picto[$numero],'width="14px"',1);
  107. else print img_object($alt,$picto[$numero],'width="14px"');
  108. }
  109. else
  110. {
  111. print img_object($alt,$picto[$numero],'width="14px"');
  112. }
  113. print ' '.$modules[$numero]->getName();
  114. print "</td>";
  115. // Version
  116. print '<td>'.$modules[$numero]->getVersion().'</td>';
  117. // Id
  118. print '<td align="center">'.$numero.'</td>';
  119. // Permissions
  120. if ($modules[$numero]->rights)
  121. {
  122. foreach($modules[$numero]->rights as $rights)
  123. {
  124. $idperms.=($idperms?", ":"").$rights[0];
  125. array_push($rights_ids, $rights[0]);
  126. }
  127. }
  128. print '<td>'.($idperms?$idperms:"&nbsp;").'</td>';
  129. print "</tr>\n";
  130. }
  131. print '</table>';
  132. print '<br>';
  133. sort($rights_ids);
  134. foreach($rights_ids as $right_id)
  135. {
  136. if ($old == $right_id)
  137. print "Warning duplicate id on permission : ".$right_id."<br>";
  138. $old = $right_id;
  139. }
  140. llxFooter();
  141. ?>