dolibarr/htdocs/admin/modules.php

185 lines
3.8 KiB
PHP
Raw Normal View History

2003-03-11 17:18:54 +01:00
<?PHP
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
2003-03-11 17:18:54 +01: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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
require("./pre.inc.php");
//
// TODO mettre cette section dans la base de donn<6E>es
//
if ($_GET["action"] == 'set' && $user->admin)
2003-03-11 17:18:54 +01:00
{
Activate($_GET["value"]);
Header("Location: modules.php");
}
function Activate($value)
{
global $db, $modules;
2003-11-13 16:09:12 +01:00
$modName = $value;
2003-03-11 17:18:54 +01:00
2003-11-13 16:09:12 +01:00
if ($modName)
2003-03-11 17:18:54 +01:00
{
2003-11-13 16:09:12 +01:00
$file = $modName . ".class.php";
include_once("../includes/modules/$file");
$objMod = new $modName($db);
$objMod->init();
2003-03-11 17:18:54 +01:00
}
2003-11-13 16:09:12 +01:00
for ($i = 0; $i < sizeof($objMod->depends); $i++)
{
Activate($objMod->depends[$i]);
}
2003-03-11 17:18:54 +01:00
}
if ($_GET["action"] == 'reset' && $user->admin)
2003-03-11 17:18:54 +01:00
{
2003-11-13 16:09:12 +01:00
$modName = $_GET["value"];
2003-03-11 17:18:54 +01:00
2003-11-13 16:09:12 +01:00
if ($modName)
2003-03-11 17:18:54 +01:00
{
2003-11-13 16:09:12 +01:00
$file = $modName . ".class.php";
include_once("../includes/modules/$file");
2003-11-13 16:09:12 +01:00
$objMod = new $modName($db);
$objMod->remove();
2003-03-11 17:18:54 +01:00
}
2003-11-13 16:09:12 +01:00
Header("Location: modules.php");
2003-03-11 17:18:54 +01:00
}
$db->close();
llxHeader();
if (!$user->admin)
{
print "Forbidden";
llxfooter();
exit;
}
2003-03-11 17:18:54 +01:00
print_titre("Modules");
2003-11-13 16:09:12 +01:00
print '<table class="border" cellpadding="3" cellspacing="0">';
2003-03-11 17:18:54 +01:00
print '<TR class="liste_titre">';
print '<td>Nom</td>';
2003-11-13 16:09:12 +01:00
print '<td>Info</td>';
print '<td align="center">Activ<69></td>';
print '<td colspan="2">&nbsp;</td>';
print "</tr>\n";
$dir = DOL_DOCUMENT_ROOT . "/includes/modules/";
$handle=opendir($dir);
$modules = array();
$i = 0;
$j = 0;
while (($file = readdir($handle))!==false)
{
if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, strlen($file) - 10) == '.class.php')
{
$modName = substr($file, 0, strlen($file) - 10);
if ($modName)
{
include_once("../includes/modules/$file");
2003-11-13 16:09:12 +01:00
$objMod = new $modName($db);
if ($objMod->numero > 0)
{
$j = $objMod->numero;
$modules[$objMod->numero] = $modName;
}
else
{
$j = 1000 + $i;
}
$modules[$j] = $modName;
$orders[$i] = $j;
$j++;
$i++;
}
}
}
2003-03-11 17:18:54 +01:00
2003-11-13 16:09:12 +01:00
sort($orders);
foreach ($orders as $key => $value)
2003-03-11 17:18:54 +01:00
{
2003-11-13 16:09:12 +01:00
$modName = $modules[$orders[$key]];
2003-03-11 17:18:54 +01:00
2003-11-13 16:09:12 +01:00
if ($modName)
{
$objMod = new $modName($db);
}
$const_name = $objMod->const_name;
$const_value = $objMod->const_config;
2003-09-13 15:39:12 +02:00
print '<tr class="pair"><td>';
2003-11-13 16:09:12 +01:00
echo $objMod->name;
2003-03-11 17:18:54 +01:00
print "</td><td>\n";
2003-11-13 16:09:12 +01:00
print $objMod->description;
2003-03-11 17:18:54 +01:00
print '</td><td align="center">';
2003-11-13 16:09:12 +01:00
2003-03-11 17:18:54 +01:00
if ($const_value == 1)
{
2003-06-24 00:18:58 +02:00
print '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/tick.png" border="0"></a>';
2003-03-11 17:18:54 +01:00
}
else
{
print "&nbsp;";
}
print '</td><td align="center">';
2003-11-13 16:09:12 +01:00
2003-03-11 17:18:54 +01:00
if ($const_value == 1)
{
2003-11-13 16:09:12 +01:00
print '<a href="modules.php?action=reset&value='.$modName.'">D<>sactiver</a></td>';
if ($objMod->config_page_url)
{
print '<td><a href="'.$objMod->config_page_url.'">Configurer</a></td>';
}
else
{
print "<td>&nbsp;</td>";
}
2003-03-11 17:18:54 +01:00
}
else
{
2003-11-13 16:09:12 +01:00
print '<a href="modules.php?action=set&value='.$modName.'">Activer</a></td><td>&nbsp;</td>';
2003-03-11 17:18:54 +01:00
}
print '</tr>';
2003-11-13 16:09:12 +01:00
2003-03-11 17:18:54 +01:00
}
2003-11-13 16:09:12 +01:00
print "</table>";
2003-03-11 17:18:54 +01:00
llxFooter();
?>