* Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2006 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"); $mode=isset($_GET["mode"])?$_GET["mode"]:0; $mesg=isset($_GET["mesg"])?urldecode($_GET["mesg"]):""; if (!$user->admin) accessforbidden(); /* * Actions */ if ($_GET["action"] == 'set' && $user->admin) { $result=Activate($_GET["value"]); $mesg=''; if ($result) $mesg=$result; Header("Location: modules.php?mode=".$mode."&mesg=".urlencode($mesg)); exit; } if ($_GET["action"] == 'reset' && $user->admin) { $result=UnActivate($_GET["value"]); $mesg=''; if ($result) $mesg=$result; Header("Location: modules.php?mode=".$mode."&mesg=".urlencode($mesg)); exit; } /** \brief Active un module \param value Nom du module a activer \param withdeps Active/désactive aussi les dépendances */ function Activate($value,$withdeps=1) { global $db, $modules, $langs; $modName = $value; // Activation du module if ($modName) { $file = $modName . ".class.php"; include_once(DOL_DOCUMENT_ROOT."/includes/modules/$file"); $objMod = new $modName($db); // Test si version PHP ok $verphp=versionphp(); $vermin=$objMod->phpmin; if (is_array($vermin) && versioncompare($verphp,$vermin) < 0) { return $langs->trans("ErrorModuleRequirePHPVersion",versiontostring($vermin)); } $objMod->init(); } if ($withdeps) { // Activation des modules dont le module dépend for ($i = 0; $i < sizeof($objMod->depends); $i++) { Activate($objMod->depends[$i]); } // Desactivation des modules qui entrent en conflit for ($i = 0; $i < sizeof($objMod->conflictwith); $i++) { UnActivate($objMod->conflictwith[$i],0); } } return 0; } /** \brief Désactive un module \param value Nom du module a désactiver \param requiredby 1=Desactive aussi modules dépendants */ function UnActivate($value,$requiredby=1) { global $db, $modules; $modName = $value; // Desactivation du module if ($modName) { $file = $modName . ".class.php"; include_once(DOL_DOCUMENT_ROOT."/includes/modules/$file"); $objMod = new $modName($db); $objMod->remove(); } // Desactivation des modules qui dependent de lui if ($requiredby) { for ($i = 0; $i < sizeof($objMod->requiredby); $i++) { UnActivate($objMod->requiredby[$i]); } } return 0; } /* * Affichage page */ llxHeader("",""); print_fiche_titre($langs->trans("ModulesSetup"),'','setup'); if ($mode==0) print $langs->trans("ModulesDesc")."
\n"; if ($mode==1) print $langs->trans("ModulesInterfaceDesc")."
\n"; if ($mode==2) print $langs->trans("ModulesSpecialDesc")."
\n"; print "
\n"; $h = 0; $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=0"; $head[$h][1] = $langs->trans("ModulesCommon"); if ($mode==0) $hselected=$h; $h++; $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=1"; $head[$h][1] = $langs->trans("ModulesInterfaces"); if ($mode==1) $hselected=$h; $h++; $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=2"; $head[$h][1] = $langs->trans("ModulesSpecial"); if ($mode==2) $hselected=$h; $h++; dolibarr_fiche_head($head, $hselected, $langs->trans("Modules")); if ($mesg) print '
'.$mesg.'
'; 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/"; // Charge tableaux modules, nom, numero, orders depuis répertoire dir $handle=opendir($dir); $nom = array(); $modules = array(); $orders = 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($dir.$file); $objMod = new $modName($db); if ($objMod->numero > 0) { $j = $objMod->numero; } else { $j = 1000 + $i; } $modules[$i] = $objMod; $nom[$i] = $modName; $orders[$i] = "$objMod->family"."_".$j; // Tri par famille puis numero module $j++; $i++; } } } asort($orders); $var=True; $familylib=array( 'base'=>$langs->trans("ModuleFamilyBase"), '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"), ); foreach ($orders as $key => $value) { $tab=split('_',$value); $family=$tab[0]; $numero=$tab[1]; $modName = $nom[$key]; $objMod = $modules[$key]; // On affiche pas les modules en version 'development' si // constante MAIN_SHOW_DEVELOPMENT_MODULES non définie if ($objMod->version == 'development' && ! $conf->global->MAIN_SHOW_DEVELOPMENT_MODULES) { continue; } $const_name = $objMod->const_name; if ($oldfamily && $family!=$oldfamily && $atleastoneforfamily) { print "\n \n\n"; $atleastoneforfamily=0; } if ($objMod->special == $mode) { $atleastoneforfamily=1; $var=!$var; print "\n"; print " \n"; print ' \n \n \n \n \n \n"; if ($objMod->config_page_url) { if (is_array($objMod->config_page_url)) { print ' \n"; } else { //print ' '; print ' '; } } else { print " "; } } else { if ($family == 'base') { // Ne devrait pas arriver. } // Module non actif print "numero."&action=set&value=" . $modName . "&mode=" . $mode . "\">" . $langs->trans("Activate") . "\n \n"; } print "\n"; } } print "
".$langs->trans("Family")."".$langs->trans("Module")."".$langs->trans("Description")."".$langs->trans("Version")."".$langs->trans("DbVersion")."".$langs->trans("Activated")."".$langs->trans("Action")."".$langs->trans("SetupShort")."
"; 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 nl2br($objMod->getDesc()); print ""; print $objMod->getVersion(); // print ""; // print $objMod->getDbVersion(); print ""; if ($conf->global->$const_name) { print img_tick(); } else { print " "; } print ""; if ($conf->global->$const_name) { // Module actif if ($family == 'base') print $langs->trans("Required"); else print "numero."&action=reset&value=" . $modName . "&mode=" . $mode . "\">" . $langs->trans("Disable") . "'; $i=0; foreach ($objMod->config_page_url as $page) { if ($i++) { print ''.img_picto(ucfirst($page),"setup").' '; // print ''.ucfirst($page).' '; } else { //print ''.$langs->trans("Setup").' '; print ''.img_picto($langs->trans("Setup"),"setup").' '; } } print "'.$langs->trans("Setup").''.img_picto($langs->trans("Setup"),"setup").'  
\n"; // Pour eviter bug mise en page IE print '
'; print '
'; $db->close(); llxFooter('$Date$ - $Revision$'); ?>