dolibarr/htdocs/admin/system/modules.php

164 lines
4.5 KiB
PHP
Raw Normal View History

2008-10-12 13:41:13 +02:00
<?php
/* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
2012-12-30 15:13:49 +01:00
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
2008-10-12 13:41:13 +02:00
*
* 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
2008-10-12 13:41:13 +02:00
* (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
2011-08-01 00:21:57 +02:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2008-10-12 13:41:13 +02:00
*/
/**
2011-01-22 10:54:08 +01:00
* \file htdocs/admin/system/modules.php
* \brief File to list all Dolibarr modules
2008-10-12 13:41:13 +02:00
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
2008-10-12 13:41:13 +02:00
$langs->load("admin");
$langs->load("install");
$langs->load("other");
2012-08-02 10:07:55 +02:00
if (! $user->admin)
accessforbidden();
2009-05-08 05:53:36 +02:00
2008-10-12 13:41:13 +02:00
/*
* View
*/
2009-05-08 05:53:36 +02:00
2008-10-12 13:41:13 +02:00
llxHeader();
print load_fiche_titre($langs->trans("AvailableModules"),'','title_setup');
2008-10-12 13:41:13 +02:00
print $langs->trans("ToActivateModule").'<br>';
print "<br>\n";
$modules = array();
$modules_names = array();
$modules_files = array();
2013-04-09 23:04:59 +02:00
$modules_fullpath = array();
$modulesdir = dolGetModulesDirs();
2011-08-13 11:36:45 +02:00
// Load list of modules
2013-04-09 23:04:59 +02:00
$i=0;
2011-08-13 11:36:45 +02:00
foreach($modulesdir as $dir)
2008-10-12 13:41:13 +02:00
{
$handle=@opendir(dol_osencode($dir));
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
2011-08-13 11:36:45 +02:00
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)
{
2013-04-09 23:04:59 +02:00
//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>";
}
2013-04-09 23:04:59 +02:00
}
}
}
}
2010-12-16 12:43:45 +01:00
closedir($handle);
}
2008-10-12 13:41:13 +02:00
}
2017-01-17 20:04:41 +01:00
print '<div class="div-table-responsive-no-min">';
2008-10-12 13:41:13 +02:00
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Modules").'</td>';
print '<td>'.$langs->trans("Version").'</td>';
2014-05-01 16:23:18 +02:00
print '<td align="center">'.$langs->trans("IdModule").'</td>';
print '<td>'.$langs->trans("IdPermissions").'</td>';
2008-10-12 13:41:13 +02:00
print '</tr>';
$var=false;
$sortorder=$modules_names;
ksort($sortorder);
$rights_ids = array();
2009-05-08 05:53:36 +02:00
foreach($sortorder as $numero=>$name)
2008-10-12 13:41:13 +02:00
{
$idperms="";
// Module
2017-04-13 15:59:51 +02:00
print '<tr class="oddeven"><td width="300" class="nowrap">';
2008-10-12 13:41:13 +02:00
$alt=$name.' - '.$modules_files[$numero];
if (! empty($picto[$numero]))
2008-10-12 13:41:13 +02:00
{
2011-01-22 10:55:07 +01:00
if (preg_match('/^\//',$picto[$numero])) print img_picto($alt,$picto[$numero],'width="14px"',1);
else print img_object($alt,$picto[$numero],'width="14px"');
2008-10-12 13:41:13 +02:00
}
else
{
2011-01-22 10:55:07 +01:00
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:"&nbsp;").'</td>';
print "</tr>\n";
2008-10-12 13:41:13 +02:00
}
print '</table>';
2017-01-17 20:04:41 +01:00
print '</div>';
2008-10-12 13:41:13 +02:00
print '<br>';
sort($rights_ids);
2012-08-02 10:07:55 +02:00
$old='';
2008-10-12 13:41:13 +02:00
foreach($rights_ids as $right_id)
{
2013-04-09 23:04:59 +02:00
if ($old == $right_id) print "Warning duplicate id on permission : ".$right_id."<br>";
$old = $right_id;
2008-10-12 13:41:13 +02:00
}
llxFooter();
2012-08-02 10:07:55 +02:00
$db->close();