";
+ print " ";
+ $db->free($result);
+ }
- print '';
}
}
diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php
new file mode 100644
index 00000000000..eab5dfcbccd
--- /dev/null
+++ b/htdocs/user/group/perms.php
@@ -0,0 +1,185 @@
+
+ * Copyright (C) 2002-2003 Jean-Louis Bergamo
+ * Copyright (C) 2004-2005 Laurent Destailleur
+ * Copyright (C) 2004 Eric 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/user/group/perms.php
+ \brief Onglet user et permissions de la fiche utilisateur
+ \version $Revision$
+*/
+
+
+require("./pre.inc.php");
+
+$langs->load("users");
+
+
+$form = new Form($db);
+
+$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
+
+
+/**
+ * Actions
+ */
+if ($_GET["subaction"] == 'addrights' && $user->admin)
+{
+ $editgroup = new Usergroup($db,$_GET["id"]);
+ $editgroup->addrights($_GET["rights"]);
+}
+
+if ($_GET["subaction"] == 'delrights' && $user->admin)
+{
+ $editgroup = new Usergroup($db,$_GET["id"]);
+ $editgroup->delrights($_GET["rights"]);
+}
+
+
+llxHeader('',$langs->trans("Permissions"));
+
+
+/* ************************************************************************** */
+/* */
+/* Visu et edition */
+/* */
+/* ************************************************************************** */
+
+if ($_GET["id"])
+{
+ $fgroup = new Usergroup($db, $_GET["id"]);
+ $fgroup->fetch($_GET["id"]);
+ $fgroup->getrights($_GET["id"]);
+
+ /*
+ * Affichage onglets
+ */
+
+ $h = 0;
+
+ $head[$h][0] = DOL_URL_ROOT.'/user/group/fiche.php?id='.$fgroup->id;
+ $head[$h][1] = $langs->trans("GroupCard");
+ $h++;
+
+ $head[$h][0] = DOL_URL_ROOT.'/user/group/perms.php?id='.$fgroup->id;
+ $head[$h][1] = $langs->trans("GroupRights");
+ $hselected=$h;
+ $h++;
+
+
+ dolibarr_fiche_head($head, $hselected, $langs->trans("Group").": ".$fgroup->nom);
+
+ // Lecture des droits du groupe
+ $sql = "SELECT r.id, r.libelle, r.module ";
+ $sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";
+ $sql .= ", ".MAIN_DB_PREFIX."usergroup_rights as ugr";
+ $sql .= " WHERE ugr.fk_id = r.id AND ugr.fk_usergroup = ".$fgroup->id;
+
+ $result=$db->query($sql);
+
+ $perms = array();
+
+ if ($result)
+ {
+ $num = $db->num_rows();
+ $i = 0;
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($i);
+
+ array_push($perms,$obj->id);
+
+ $i++;
+ }
+ $db->free();
+ }
+ else
+ {
+ dolibarr_print_error($db);
+ }
+
+
+ /*
+ * Ecran ajout/suppression permission
+ */
+
+
+ print '
';
+ print '
 
 
'.$langs->trans("Permissions").'
'.$langs->trans("Module").'
';
+
+ $sql = "SELECT r.id, r.libelle, r.module FROM ".MAIN_DB_PREFIX."rights_def as r ORDER BY r.module, r.id ASC";
+
+ if ($db->query($sql))
+ {
+ $num = $db->num_rows();
+ $i = 0;
+ $var = True;
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($i);
+ if ($oldmod <> $obj->module)
+ {
+ $oldmod = $obj->module;
+ $var = !$var;
+ }
+ print '
';
+
+ if ( $user->admin )
+ {
+ if (in_array($obj->id, $perms))
+ {
+ print '
';
- }
-}
-
-
-llxHeader('','Fiche Utilisateur');
+llxHeader('',$langs->trans("Permissions"));
/* ************************************************************************** */
@@ -151,10 +81,9 @@ if ($_GET["id"])
$h++;
$head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$fuser->id;
- $head[$h][1] = $langs->trans("Permissions");
+ $head[$h][1] = $langs->trans("UserRights");
$hselected=$h;
$h++;
-
if ($conf->bookmark4u->enabled)
{
@@ -165,7 +94,7 @@ if ($_GET["id"])
dolibarr_fiche_head($head, $hselected, $langs->trans("User").": ".$fuser->fullname);
-
+ // Lecture des droits de l'utilisateur
$sql = "SELECT r.id, r.libelle, r.module ";
$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";
$sql .= ", ".MAIN_DB_PREFIX."user_rights as ur";
@@ -201,7 +130,7 @@ if ($_GET["id"])
print '
';
- print '
 
 
'.$langs->trans("AvailableRights").'
'.$langs->trans("Module").'
';
+ print '
 
 
'.$langs->trans("Permissions").'
'.$langs->trans("Module").'
';
$sql = "SELECT r.id, r.libelle, r.module FROM ".MAIN_DB_PREFIX."rights_def as r ORDER BY r.module, r.id ASC";
@@ -226,9 +155,8 @@ if ($_GET["id"])
{
print '