* Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2005 Laurent Destailleur * Copyright (C) 2004 Éric Seigne * * 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("",""); if (!$_GET["spe"]) { $hselected = 0; } else { $hselected = 1; } $h = 0; $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?spe=0"; $head[$h][1] = $langs->trans("ModulesCommon"); $h++; $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?spe=1"; $head[$h][1] = $langs->trans("ModulesSpecial"); $h++; dolibarr_fiche_head($head, $hselected, $langs->trans("Modules")); if (!$_GET["spe"]) { print $langs->trans("ModulesDesc")."
\n"; } else { print $langs->trans("ModulesSpecialDesc")."
\n"; } print "
\n"; print "\n"; print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "\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"); $objMod = new $modName($db); if ($objMod->numero > 0) { $j = $objMod->numero; } else { $j = 1000 + $i; } $modules[$i] = $modName; $numero[$i] = $j; $orders[$i] = "$objMod->family"."_".$j; // Tri par famille puis numero module $j++; $i++; } } } asort($orders); $var=True; $familylib=array( 'crm'=>$langs->trans("ModuleFamilyCrm"), 'products'=>$langs->trans("ModuleFamilyProducts"), 'hr'=>$langs->trans("ModuleFamilyHr"), 'projects'=>$langs->trans("ModuleFamilyProjects"), 'other'=>$langs->trans("ModuleFamilyOther"), 'technic'=>$langs->trans("ModuleFamilyTechnic"), 'financial'=>$langs->trans("ModuleFamilyFinancial"), 'experimental'=>$langs->trans("ModuleFamilyExperimental") ); 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; if ($oldfamily && $family!=$oldfamily && $atleastoneforfamily) { print "\n \n\n"; $atleastoneforfamily=0; } if((!$objMod->special && !$_GET["spe"] ) or ($objMod->special && $_GET["spe"])) { $atleastoneforfamily=1; $var=!$var; print "\n"; print " \n"; print ' \n \n \n \n \n"; if ($objMod->config_page_url) { if (is_array($objMod->config_page_url)) { print " \n"; } else { print ' '; } } else { print " "; } } else { // Module non actif print "numero."&action=set&value=" . $modName . "&spe=" . $_GET["spe"] . "\">" . $langs->trans("Activate") . "\n \n"; } print "\n"; } } print "
".$langs->trans("Family")."".$langs->trans("Module")."".$langs->trans("Description")."".$langs->trans("Version")."".$langs->trans("Activated")."".$langs->trans("Action")." 
"; if ($family!=$oldfamily) { print "
".$familylib[$family]."
"; $oldfamily=$family; } else { print ' '; } print "
'; print $objMod->picto?img_object('',$objMod->picto):img_object('','generic'); print ''.$objMod->getName(); print ""; print $objMod->getDesc(); print ""; print $objMod->getVersion(); print ""; if ($const_value == 1) { print ''; } else { print " "; } print ""; if ($const_value == 1) { // Module actif print "numero."&action=reset&value=" . $modName . "&spe=" . $_GET["spe"] . "\">" . $langs->trans("Disable") . ""; $i=0; foreach ($objMod->config_page_url as $page) { if ($i++) { print ''.ucfirst($page).' '; } else { print ''.$langs->trans("Setup").' '; } } print "'.$langs->trans("Setup").'  
\n"; llxFooter(); ?>