-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
modules.php
163 lines (148 loc) · 4.52 KB
/
modules.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
/* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/admin/system/modules.php
* \brief File to list all Dolibarr modules
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("install","other","admin"));
if (! $user->admin)
accessforbidden();
/*
* View
*/
llxHeader();
print load_fiche_titre($langs->trans("AvailableModules"),'','title_setup');
print $langs->trans("ToActivateModule").'<br>';
print "<br>\n";
$modules = array();
$modules_names = array();
$modules_files = array();
$modules_fullpath = array();
$modulesdir = dolGetModulesDirs();
// Load list of modules
$i=0;
foreach($modulesdir as $dir)
{
$handle=@opendir(dol_osencode($dir));
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
{
$modName = substr($file, 0, dol_strlen($file) - 10);
if ($modName)
{
//print 'xx'.$dir.$file.'<br>';
if (in_array($file, $modules_files))
{
// File duplicate
print "Warning duplicate file found : ".$file." (Found ".$dir.$file.", already found ".$modules_fullpath[$file].")<br>";
}
else
{
// File to load
$res=include_once $dir.$file;
if (class_exists($modName))
{
try {
$objMod = new $modName($db);
$modules[$objMod->numero]=$objMod;
$modules_names[$objMod->numero]=$objMod->name;
$modules_files[$objMod->numero]=$file;
$modules_fullpath[$file]=$dir.$file;
$picto[$objMod->numero]=(isset($objMod->picto) && $objMod->picto)?$objMod->picto:'generic';
}
catch(Exception $e)
{
dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
}
}
else
{
print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)<br>";
}
}
}
}
}
closedir($handle);
}
}
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Modules").'</td>';
print '<td>'.$langs->trans("Version").'</td>';
print '<td align="center">'.$langs->trans("IdModule").'</td>';
print '<td>'.$langs->trans("IdPermissions").'</td>';
print '</tr>';
$var=false;
$sortorder=$modules_names;
ksort($sortorder);
$rights_ids = array();
foreach($sortorder as $numero=>$name)
{
$idperms="";
// Module
print '<tr class="oddeven"><td width="300" class="nowrap">';
$alt=$name.' - '.$modules_files[$numero];
if (! empty($picto[$numero]))
{
if (preg_match('/^\//',$picto[$numero])) print img_picto($alt,$picto[$numero],'width="14px"',1);
else print img_object($alt,$picto[$numero],'width="14px"');
}
else
{
print img_object($alt,$picto[$numero],'width="14px"');
}
print ' '.$modules[$numero]->getName();
print "</td>";
// Version
print '<td>'.$modules[$numero]->getVersion().'</td>';
// Id
print '<td align="center">'.$numero.'</td>';
// Permissions
if ($modules[$numero]->rights)
{
foreach($modules[$numero]->rights as $rights)
{
$idperms.=($idperms?", ":"").$rights[0];
array_push($rights_ids, $rights[0]);
}
}
print '<td>'.($idperms?$idperms:" ").'</td>';
print "</tr>\n";
}
print '</table>';
print '</div>';
print '<br>';
sort($rights_ids);
$old='';
foreach($rights_ids as $right_id)
{
if ($old == $right_id) print "Warning duplicate id on permission : ".$right_id."<br>";
$old = $right_id;
}
// End of page
llxFooter();
$db->close();