dolibarr  9.0.0
modules.php
Go to the documentation of this file.
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-2012 Regis Houssin <regis.houssin@inodbox.com>
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 3 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 
25 require '../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
27 
28 // Load translation files required by the page
29 $langs->loadLangs(array("install","other","admin"));
30 
31 if (! $user->admin)
33 
34 
35 /*
36  * View
37  */
38 
39 llxHeader();
40 
41 print load_fiche_titre($langs->trans("AvailableModules"),'','title_setup');
42 
43 print $langs->trans("ToActivateModule").'<br>';
44 print "<br>\n";
45 
46 $modules = array();
47 $modules_names = array();
48 $modules_files = array();
49 $modules_fullpath = array();
50 $modulesdir = dolGetModulesDirs();
51 
52 // Load list of modules
53 $i=0;
54 foreach($modulesdir as $dir)
55 {
56  $handle=@opendir(dol_osencode($dir));
57  if (is_resource($handle))
58  {
59  while (($file = readdir($handle))!==false)
60  {
61  if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
62  {
63  $modName = substr($file, 0, dol_strlen($file) - 10);
64 
65  if ($modName)
66  {
67  //print 'xx'.$dir.$file.'<br>';
68  if (in_array($file, $modules_files))
69  {
70  // File duplicate
71  print "Warning duplicate file found : ".$file." (Found ".$dir.$file.", already found ".$modules_fullpath[$file].")<br>";
72  }
73  else
74  {
75  // File to load
76  $res=include_once $dir.$file;
77  if (class_exists($modName))
78  {
79  try {
80  $objMod = new $modName($db);
81 
82  $modules[$objMod->numero]=$objMod;
83  $modules_names[$objMod->numero]=$objMod->name;
84  $modules_files[$objMod->numero]=$file;
85  $modules_fullpath[$file]=$dir.$file;
86  $picto[$objMod->numero]=(isset($objMod->picto) && $objMod->picto)?$objMod->picto:'generic';
87  }
88  catch(Exception $e)
89  {
90  dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
91  }
92  }
93  else
94  {
95  print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)<br>";
96  }
97  }
98  }
99  }
100  }
101  closedir($handle);
102  }
103 }
104 
105 print '<div class="div-table-responsive-no-min">';
106 print '<table class="noborder" width="100%">';
107 print '<tr class="liste_titre">';
108 print '<td>'.$langs->trans("Modules").'</td>';
109 print '<td>'.$langs->trans("Version").'</td>';
110 print '<td align="center">'.$langs->trans("IdModule").'</td>';
111 print '<td>'.$langs->trans("IdPermissions").'</td>';
112 print '</tr>';
113 $var=false;
114 $sortorder=$modules_names;
115 ksort($sortorder);
116 $rights_ids = array();
117 foreach($sortorder as $numero=>$name)
118 {
119  $idperms="";
120  // Module
121  print '<tr class="oddeven"><td width="300" class="nowrap">';
122  $alt=$name.' - '.$modules_files[$numero];
123  if (! empty($picto[$numero]))
124  {
125  if (preg_match('/^\//',$picto[$numero])) print img_picto($alt,$picto[$numero],'width="14px"',1);
126  else print img_object($alt,$picto[$numero],'width="14px"');
127  }
128  else
129  {
130  print img_object($alt,$picto[$numero],'width="14px"');
131  }
132  print ' '.$modules[$numero]->getName();
133  print "</td>";
134  // Version
135  print '<td>'.$modules[$numero]->getVersion().'</td>';
136  // Id
137  print '<td align="center">'.$numero.'</td>';
138  // Permissions
139  if ($modules[$numero]->rights)
140  {
141  foreach($modules[$numero]->rights as $rights)
142  {
143  $idperms.=($idperms?", ":"").$rights[0];
144  array_push($rights_ids, $rights[0]);
145  }
146  }
147  print '<td>'.($idperms?$idperms:"&nbsp;").'</td>';
148  print "</tr>\n";
149 }
150 print '</table>';
151 print '</div>';
152 print '<br>';
153 sort($rights_ids);
154 $old='';
155 foreach($rights_ids as $right_id)
156 {
157  if ($old == $right_id) print "Warning duplicate id on permission : ".$right_id."<br>";
158  $old = $right_id;
159 }
160 
161 // End of page
162 llxFooter();
163 $db->close();
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
print
Draft customers invoices.
Definition: index.php:91
dolGetModulesDirs($subdir='')
Return list of modules directories.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
llxHeader()
Empty header.
Definition: wrapper.php:44
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)