* Copyright (C) 2004-2006 Laurent Destailleur * * 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/perms.php \ingroup core,menudb \brief Page d'administration/configuration des permissions par defaut \version $Revision$ */ require("./pre.inc.php"); $langs->load("admin"); $langs->load("users"); $langs->load("other"); if (!$user->admin) accessforbidden(); if ($_GET["action"] == 'add') { $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=1 WHERE id =".$_GET["pid"]; $db->query($sql); } if ($_GET["action"] == 'remove') { $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=0 WHERE id =".$_GET["pid"]; $db->query($sql); } llxHeader(); print_fiche_titre($langs->trans("SecuritySetup"),'','setup'); print $langs->trans("DefaultRightsDesc")."
\n"; print "
\n"; $h = 0; $head[$h][0] = DOL_URL_ROOT."/admin/perms.php"; $head[$h][1] = $langs->trans("DefaultRights"); $hselected=$h; $h++; $head[$h][0] = DOL_URL_ROOT."/admin/security.php"; $head[$h][1] = $langs->trans("Passwords"); $h++; $head[$h][0] = DOL_URL_ROOT."/admin/security_other.php"; $head[$h][1] = $langs->trans("Miscellanous"); $h++; dolibarr_fiche_head($head, $hselected, $langs->trans("Security")); print ''; // Charge les modules soumis a permissions $db->begin(); $dir = DOL_DOCUMENT_ROOT . "/includes/modules/"; $handle=opendir($dir); $modules = array(); 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->rights_class) { $ret=$objMod->insert_permissions(); $modules[$objMod->rights_class]=$objMod; //print "modules[".$objMod->rights_class."]=$objMod;"; } } } } $db->commit(); // Affiche lignes des permissions $sql ="SELECT r.id, r.libelle, r.module, r.bydefault"; $sql.=" FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql.=" WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" $sql.=" ORDER BY r.module, r.id"; $result = $db->query($sql); if ($result) { $num = $db->num_rows(); $i = 0; $var=True; $old = ""; while ($i < $num) { $obj = $db->fetch_object($result); // Si la ligne correspond a un module qui n'existe plus (absent de includes/module), on l'ignore if (! $modules[$obj->module]) { $i++; continue; } if ($old <> $obj->module) { // Rupture détectée, on récupère objMod $objMod=$modules[$obj->module]; $picto=($objMod->picto?$objMod->picto:'generic'); print ''; print ''; print ''; print ''; print ''; print "\n"; $old = $obj->module; } $var=!$var; print ''; print ''; print ''; $i++; } } print '
'.$langs->trans("Module").''.$langs->trans("Permission").''.$langs->trans("Default").' 
'.img_object('',$picto).' '.$objMod->getName(); print ' '; $perm_libelle=(($langs->trans("Permission".$obj->id)!=("Permission".$obj->id))?$langs->trans("Permission".$obj->id):$obj->libelle); print ''.$perm_libelle. ''; if ($obj->bydefault == 1) { print img_tick(); print ''; print ''.img_edit_remove().''; } else { print ' '; print ''; print ''.img_edit_add().''; } print '
'; print ''; $db->close(); llxFooter('$Date$ - $Revision$'); ?>