New: Ajout page configuration triggers
This commit is contained in:
parent
517176eed6
commit
1415df0e46
220
htdocs/admin/triggers.php
Normal file
220
htdocs/admin/triggers.php
Normal file
@ -0,0 +1,220 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.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 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$
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/admin/modules.php
|
||||
\brief Page de configuration et activation des modules
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
|
||||
|
||||
|
||||
if ($_GET["action"] == 'set' && $user->admin)
|
||||
{
|
||||
Activate($_GET["value"]);
|
||||
|
||||
Header("Location: modules.php?spe=".$_GET["spe"]);
|
||||
}
|
||||
|
||||
if ($_GET["action"] == 'reset' && $user->admin)
|
||||
{
|
||||
UnActivate($_GET["value"]);
|
||||
|
||||
Header("Location: modules.php?spe=".$_GET["spe"]);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Active un module
|
||||
\param value Nom du module a activer
|
||||
*/
|
||||
function Activate($value)
|
||||
{
|
||||
global $db, $modules;
|
||||
|
||||
$modName = $value;
|
||||
|
||||
// Activation du module
|
||||
if ($modName)
|
||||
{
|
||||
$file = $modName . ".class.php";
|
||||
include_once("../includes/modules/$file");
|
||||
$objMod = new $modName($db);
|
||||
$objMod->init();
|
||||
}
|
||||
|
||||
// Activation des modules dont le module dépend
|
||||
for ($i = 0; $i < sizeof($objMod->depends); $i++)
|
||||
{
|
||||
Activate($objMod->depends[$i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** \brief Désactive un module
|
||||
\param value Nom du module a désactiver
|
||||
*/
|
||||
function UnActivate($value)
|
||||
{
|
||||
global $db, $modules;
|
||||
|
||||
$modName = $value;
|
||||
|
||||
// Desactivation du module
|
||||
if ($modName)
|
||||
{
|
||||
$file = $modName . ".class.php";
|
||||
include_once("../includes/modules/$file");
|
||||
$objMod = new $modName($db);
|
||||
$objMod->remove();
|
||||
}
|
||||
|
||||
// Desactivation des modules qui dependent de lui
|
||||
for ($i = 0; $i < sizeof($objMod->requiredby); $i++)
|
||||
{
|
||||
UnActivate($objMod->requiredby[$i]);
|
||||
}
|
||||
|
||||
Header("Location: modules.php");
|
||||
}
|
||||
|
||||
|
||||
|
||||
llxHeader("","");
|
||||
|
||||
|
||||
print_titre($langs->trans("TriggersAvailable"));
|
||||
print '<br>';
|
||||
|
||||
print $langs->trans("TriggersDesc")."<br>";
|
||||
print "<br>\n";
|
||||
|
||||
print "<table class=\"noborder\" width=\"100%\">\n";
|
||||
print "<tr class=\"liste_titre\">\n";
|
||||
print " <td colspan=\"2\">".$langs->trans("File")."</td>\n";
|
||||
print " <td>".$langs->trans("Description")."</td>\n";
|
||||
print " <td align=\"center\">".$langs->trans("Version")."</td>\n";
|
||||
print " <td align=\"center\">".$langs->trans("Activated")."</td>\n";
|
||||
//print " <td align=\"center\">".$langs->trans("Action")."</td>\n";
|
||||
print " <td align=\"center\"> </td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
$dir = DOL_DOCUMENT_ROOT . "/includes/triggers/";
|
||||
|
||||
$handle=opendir($dir);
|
||||
$files = array();
|
||||
$modules = array();
|
||||
$orders = array();
|
||||
$i = 0;
|
||||
$j = 0;
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (is_readable($dir.$file) && ereg('^interface_(.*)\.class\.php',$file,$reg))
|
||||
{
|
||||
$modName = 'Interface'.ucfirst($reg[1]);
|
||||
if ($modName)
|
||||
{
|
||||
include_once($dir.$file);
|
||||
$objMod = new $modName($db);
|
||||
|
||||
$modules[$i] = $modName;
|
||||
$files[$i] = $file;
|
||||
$orders[$i] = "$objMod->family"; // Tri par famille
|
||||
$j++;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
asort($orders);
|
||||
$var=True;
|
||||
|
||||
foreach ($orders as $key => $value)
|
||||
{
|
||||
$tab=split('_',$value);
|
||||
$family=$tab[0]; $numero=$tab[1];
|
||||
|
||||
$modName = $modules[$key];
|
||||
if ($modName)
|
||||
{
|
||||
$objMod = new $modName($db);
|
||||
}
|
||||
|
||||
$const_name = $objMod->const_name;
|
||||
$const_value = $objMod->const_config;
|
||||
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>\n";
|
||||
|
||||
print '<td valign="top" width="14" align="center">';
|
||||
print $objMod->picto?img_object('',$objMod->picto):img_object('','generic');
|
||||
print '</td><td valign="top">'.$files[$key];
|
||||
print "</td>\n <td valign=\"top\">";
|
||||
print $objMod->getDesc();
|
||||
print "</td>\n <td valign=\"top\" align=\"center\">";
|
||||
print $objMod->getVersion();
|
||||
print "</td>\n <td valign=\"top\" align=\"center\">";
|
||||
|
||||
$const_value=1;
|
||||
|
||||
if ($const_value == 1)
|
||||
{
|
||||
print img_tick();
|
||||
}
|
||||
else
|
||||
{
|
||||
print " ";
|
||||
}
|
||||
|
||||
print "</td>\n";
|
||||
|
||||
/*
|
||||
print "<td valign=\"top\" align=\"center\">";
|
||||
if ($const_value == 1)
|
||||
{
|
||||
// Module actif
|
||||
print "<a href=\"modules.php?id=".$objMod->numero."&action=reset&value=" . $modName . "&spe=" . $_GET["spe"] . "\">" . $langs->trans("Disable") . "</a></td>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Module non actif
|
||||
print "<a href=\"modules.php?id=".$objMod->numero."&action=set&value=" . $modName . "&spe=" . $_GET["spe"] . "\">" . $langs->trans("Activate") . "</a></td>\n";
|
||||
}
|
||||
*/
|
||||
print "<td> </td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
}
|
||||
print "</table></div>\n";
|
||||
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user