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