Skip to content
Snippets Groups Projects
Commit bf009e5c authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

New: Ajout possibilité de mettre des permissions sur les groupes

New: Possibilité de supprimer un groupe
parent 0ab22e23
No related branches found
No related tags found
No related merge requests found
......@@ -75,24 +75,24 @@ if ($_GET["id"])
if ($user->admin)
{
$head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$fuser->id;
$head[$h][1] = $langs->trans("Permissions");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$fuser->id;
$head[$h][1] = $langs->trans("UserRights");
$h++;
}
if ($conf->bookmark4u->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$fuser->id;
$head[$h][1] = $langs->trans("Bookmark4u");
$hselected=$h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$fuser->id;
$head[$h][1] = $langs->trans("Bookmark4u");
$hselected=$h;
$h++;
}
if ($conf->clicktodial->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$fuser->id;
$head[$h][1] = $langs->trans("ClickToDial");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$fuser->id;
$head[$h][1] = $langs->trans("ClickToDial");
$h++;
}
dolibarr_fiche_head($head, $hselected, $langs->trans("User").": ".$fuser->fullname);
......
......@@ -78,24 +78,24 @@ if ($_GET["id"])
if ($user->admin)
{
$head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?action=perms&id='.$fuser->id;
$head[$h][1] = $langs->trans("Permissions");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?action=perms&id='.$fuser->id;
$head[$h][1] = $langs->trans("UserRights");
$h++;
}
if ($conf->bookmark4u->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$fuser->id;
$head[$h][1] = $langs->trans("Bookmark4u");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$fuser->id;
$head[$h][1] = $langs->trans("Bookmark4u");
$h++;
}
if ($conf->clicktodial->enabled)
{
$head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$fuser->id;
$head[$h][1] = $langs->trans("ClickToDial");
$hselected=$h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$fuser->id;
$head[$h][1] = $langs->trans("ClickToDial");
$hselected=$h;
$h++;
}
dolibarr_fiche_head($head, $hselected, $langs->trans("User")." : ".$fuser->fullname);
......
......@@ -53,6 +53,17 @@ if ($_GET["subaction"] == 'delrights' && $user->admin)
$edituser->delrights($_GET["rights"]);
}
if ($_POST["action"] == 'confirm_disable' && $_POST["confirm"] == "yes")
{
if ($_GET["id"] <> $user->id)
{
$edituser = new User($db, $_GET["id"]);
$edituser->fetch($_GET["id"]);
$edituser->disable();
Header("Location: index.php");
}
}
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes")
{
if ($_GET["id"] <> $user->id)
......@@ -209,21 +220,21 @@ if ($action == 'create')
print '<tr><td valign="top" width="20%">'.$langs->trans("Firstname").'</td>';
print '<td class="valeur"><input size="30" type="text" name="prenom" value=""></td></tr>';
print "<tr>".'<td valign="top">'.$langs->trans("Login").'</td>';
print '<tr><td valign="top">'.$langs->trans("Login").'</td>';
print '<td class="valeur"><input size="20" type="text" name="login" value=""></td></tr>';
print "<tr>".'<td valign="top">'.$langs->trans("Password").'</td>';
print '<tr><td valign="top">'.$langs->trans("Password").'</td>';
print '<td class="valeur"><input size="30" type="text" name="password" value=""></td></tr>';
print "<tr>".'<td valign="top">'.$langs->trans("EMail").'</td>';
print '<tr><td valign="top">'.$langs->trans("EMail").'</td>';
print '<td class="valeur"><input size="40" type="text" name="email" value=""></td></tr>';
print "<tr>".'<td valign="top">'.$langs->trans("Administrator").'</td>';
print '<tr><td valign="top">'.$langs->trans("Administrator").'</td>';
print '<td class="valeur">';
$form->selectyesnonum('admin',0);
print "</td></tr>\n";
print "<tr>".'<td valign="top">'.$langs->trans("Note").'</td><td>';
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td>';
print "<textarea name=\"note\" rows=\"12\" cols=\"40\">";
print "</textarea></td></tr>\n";
......@@ -264,7 +275,7 @@ else
$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");
$h++;
if ($conf->bookmark4u->enabled)
......@@ -277,13 +288,22 @@ else
dolibarr_fiche_head($head, $hselected, $langs->trans("User").": ".$fuser->fullname);
/*
* Confirmation dsactivation
*/
if ($action == 'disable')
{
$html = new Form($db);
$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$fuser->login),"confirm_disable");
}
/*
* Confirmation suppression
*/
if ($action == 'delete')
{
$html = new Form($db);
$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$fuser->login),"confirm_delete");
$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$fuser->login),"confirm_delete");
}
if ($_GET["action"] != 'edit')
......@@ -390,7 +410,12 @@ else
if ($user->id <> $_GET["id"] && $user->admin)
{
print '<a class="butDelete" href="fiche.php?action=delete&amp;id='.$fuser->id.'">'.$langs->trans("DisableUser").'</a>';
print '<a class="butDelete" href="fiche.php?action=disable&amp;id='.$fuser->id.'">'.$langs->trans("DisableUser").'</a>';
}
if ($user->id <> $_GET["id"] && $user->admin)
{
print '<a class="butDelete" href="fiche.php?action=delete&amp;id='.$fuser->id.'">'.$langs->trans("DeleteUser").'</a>';
}
print "</div>\n";
......
......@@ -35,61 +35,72 @@ $action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
/**
* Action ajout
* Action suppression groupe
*/
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes")
{
$editgroup = new Usergroup($db, $_GET["id"]);
$editgroup->fetch($_GET["id"]);
$editgroup->delete();
Header("Location: index.php");
}
/**
* Action ajout groupe
*/
if ($_POST["action"] == 'add' && $user->admin)
{
$message="";
if (! $_POST["nom"]) {
$message='<div class="error">'.$langs->trans("NameNotDefined").'</div>';
$action="create"; // Go back to create page
}
if (! $message) {
$editgroup = new UserGroup($db,0);
$editgroup->nom = trim($_POST["nom"]);
$editgroup->note = trim($_POST["note"]);
$db->begin();
$id = $editgroup->create();
if ($id > 0)
{
$db->commit();
Header("Location: fiche.php?id=".$editgroup->id);
}
else
{
$db->rollback();
$message='<div class="error">'.$langs->trans("ErrorGroupAlreadyExists",$editgroup->nom).'</div>';
$action="create"; // Go back to create page
}
}
$message="";
if (! $_POST["nom"]) {
$message='<div class="error">'.$langs->trans("NameNotDefined").'</div>';
$action="create"; // Go back to create page
}
if (! $message) {
$editgroup = new UserGroup($db,0);
$editgroup->nom = trim($_POST["nom"]);
$editgroup->note = trim($_POST["note"]);
$db->begin();
$id = $editgroup->create();
if ($id > 0)
{
$db->commit();
Header("Location: fiche.php?id=".$editgroup->id);
}
else
{
$db->rollback();
$message='<div class="error">'.$langs->trans("ErrorGroupAlreadyExists",$editgroup->nom).'</div>';
$action="create"; // Go back to create page
}
}
}
if ($_POST["action"] == 'adduser' && $user->admin)
{
if ($_POST["user"])
if ($_POST["user"])
{
$edituser = new User($db, $_POST["user"]);
$edituser->SetInGroup($_GET["id"]);
$edituser = new User($db, $_POST["user"]);
$edituser->SetInGroup($_GET["id"]);
Header("Location: fiche.php?id=".$_GET["id"]);
Header("Location: fiche.php?id=".$_GET["id"]);
}
}
if ($_GET["action"] == 'removeuser' && $user->admin)
{
if ($_GET["user"])
if ($_GET["user"])
{
$edituser = new User($db, $_GET["user"]);
$edituser->RemoveFromGroup($_GET["id"]);
$edituser = new User($db, $_GET["user"]);
$edituser->RemoveFromGroup($_GET["id"]);
Header("Location: fiche.php?id=".$_GET["id"]);
Header("Location: fiche.php?id=".$_GET["id"]);
}
}
......@@ -104,26 +115,26 @@ llxHeader();
if ($action == 'create')
{
print_titre($langs->trans("NewGroup"));
print "<br>";
print_titre($langs->trans("NewGroup"));
print "<br>";
if ($message) { print $message."<br>"; }
if ($message) { print $message."<br>"; }
print '<form action="fiche.php" method="post">';
print '<input type="hidden" name="action" value="add">';
print '<form action="fiche.php" method="post">';
print '<input type="hidden" name="action" value="add">';
print '<table class="border" width="100%">';
print '<table class="border" width="100%">';
print "<tr>".'<td valign="top">'.$langs->trans("Name").'</td>';
print '<td class="valeur"><input size="30" type="text" name="nom" value=""></td></tr>';
print "<tr>".'<td valign="top">'.$langs->trans("Name").'</td>';
print '<td class="valeur"><input size="30" type="text" name="nom" value=""></td></tr>';
print "<tr>".'<td valign="top">'.$langs->trans("Note").'</td><td>';
print "<textarea name=\"note\" rows=\"12\" cols=\"40\">";
print "</textarea></td></tr>\n";
print "<tr>".'<td valign="top">'.$langs->trans("Note").'</td><td>';
print "<textarea name=\"note\" rows=\"12\" cols=\"40\">";
print "</textarea></td></tr>\n";
print "<tr>".'<td align="center" colspan="2"><input value="'.$langs->trans("CreateGroup").'" type="submit"></td></tr>';
print "</form>";
print "</table>\n";
print "<tr>".'<td align="center" colspan="2"><input value="'.$langs->trans("CreateGroup").'" type="submit"></td></tr>';
print "</form>";
print "</table>\n";
}
......@@ -134,147 +145,180 @@ if ($action == 'create')
/* ************************************************************************** */
else
{
if ($_GET["id"])
if ($_GET["id"])
{
$group = new UserGroup($db);
$group->fetch($_GET["id"]);
/*
* Affichage onglets
*/
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/user/group/fiche.php?id='.$group->id;
$head[$h][1] = $langs->trans("GroupCard");
$hselected=$h;
$h++;
$group = new UserGroup($db);
$group->fetch($_GET["id"]);
/*
* Affichage onglets
*/
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/user/group/fiche.php?id='.$group->id;
$head[$h][1] = $langs->trans("GroupCard");
$hselected=$h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/user/group/perms.php?id='.$group->id;
$head[$h][1] = $langs->trans("GroupRights");
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("Group").": ".$group->nom);
/*
* Confirmation suppression
*/
if ($action == 'delete')
{
$html = new Form($db);
$html->form_confirm("fiche.php?id=$group->id",$langs->trans("DeleteAGroup"),$langs->trans("ConfirmDeleteGroup",$group->name),"confirm_delete");
}
/*
* Fiche en mode visu
*/
print '<table class="border" width="100%">';
print '<tr><td width="25%" valign="top">'.$langs->trans("Name").'</td>';
print '<td width="75%" class="valeur">'.$group->nom.'</td>';
print "</tr>\n";
print '<tr><td width="25%" valign="top">'.$langs->trans("Note").'</td>';
print '<td class="valeur">'.nl2br($group->note).'&nbsp;</td>';
print "</tr>\n";
print "</table>\n";
print "<br>\n";
print '</div>';
if ($message) { print $message; }
/*
* Barre d'actions
*
*/
print '<div class="tabsAction">';
if ($user->admin)
{
print '<a class="tabAction" href="fiche.php?id='.$group->id.'&amp;action=edit">'.$langs->trans("Edit").'</a>';
}
if ($user->id <> $_GET["id"] && $user->admin)
{
print '<a class="butDelete" href="fiche.php?action=delete&amp;id='.$group->id.'">'.$langs->trans("DeleteGroup").'</a>';
}
print "</div>\n";
print "<br>\n";
print_titre($langs->trans("ListOfUsersInGroup"));
print "<br>\n";
dolibarr_fiche_head($head, $hselected, $langs->trans("Group").": ".$group->nom);
// On slectionne les users qui ne sont pas dj dans le groupe
$uss = array();
/*
* Confirmation suppression
*/
if ($action == 'delete')
$sql = "SELECT u.rowid, u.name, u.firstname, u.code ";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u ";
# $sql .= " LEFT JOIN llx_usergroup_user ug ON u.rowid = ug.fk_user";
# $sql .= " WHERE ug.fk_usergroup IS NULL";
$sql .= " ORDER BY u.name";
$result = $db->query($sql);
if ($result)
{
$html = new Form($db);
$html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DisableAGroup"),$langs->trans("ConfirmDisableGroup",$fuser->login),"confirm_delete");
$num = $db->num_rows();
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object();
$uss[$obj->rowid] = ucfirst(stripslashes($obj->firstname)) . " ".ucfirst(stripslashes($obj->name));
$i++;
}
}
else {
dolibarr_print_error($db);
}
if ($user->admin)
{
$form = new Form($db);
print '<form action="fiche.php?id='.$group->id.'" method="post">'."\n";
print '<input type="hidden" name="action" value="adduser">';
print '<table class="noborder" width="100%">'."\n";
// print '<tr class="liste_titre"><td width="25%">'.$langs->trans("NonAffectedUsers").'</td>'."\n";
print '<tr class="liste_titre"><td width="25%">'.$langs->trans("Users").'</td>'."\n";
print '<td>';
print $form->select_array("user",$uss);
print ' &nbsp; ';
print '<input type="submit" class=button value="'.$langs->trans("Add").'">';
print '</td></tr>'."\n";
print '</table></form>'."\n";
}
/*
* Membres du groupe
*/
$sql = "SELECT u.rowid, u.login, u.name, u.firstname, u.code ";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
$sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug";
$sql .= " WHERE ug.fk_user = u.rowid";
$sql .= " AND ug.fk_usergroup = ".$group->id;
$sql .= " ORDER BY u.name";
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
print '<br>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td width="25%">'.$langs->trans("Login").'</td>';
print '<td width="25%">'.$langs->trans("Lastname").'</td>';
print '<td width="25%">'.$langs->trans("Firstname").'</td>';
print '<td>'.$langs->trans("Code").'</td>';
print "<td>&nbsp;</td></tr>\n";
$var=True;
while ($i < $num)
{
$obj = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowUser"),"user").' '.$obj->login.'</a>';
print '</td>';
print '<td>'.ucfirst(stripslashes($obj->name)).'</td>';
print '<td>'.ucfirst(stripslashes($obj->firstname)).'</td>';
print '<td>'.$obj->code.'</td><td>';
if ($user->admin)
{
print '<a href="fiche.php?id='.$group->id.'&amp;action=removeuser&amp;user='.$obj->rowid.'">';
print img_delete($langs->trans("RemoveFromGroup"));
}
else
{
print "-";
}
print "</td></tr>\n";
$i++;
}
print "</table>";
print "<br>";
$db->free($result);
}
/*
* Fiche en mode visu
*/
print '<table class="border" width="100%">';
print '<tr><td width="25%" valign="top">'.$langs->trans("Name").'</td>';
print '<td width="75%" class="valeur">'.$group->nom.'</td>';
print "</tr>\n";
print '<tr><td width="25%" valign="top">'.$langs->trans("Note").'</td>';
print '<td class="valeur">'.nl2br($group->note).'&nbsp;</td>';
print "</tr>\n";
print "</table>\n";
print "<br>\n";
$uss = array();
// On slectionne les users qui ne sont pas dj dans le groupe
$sql = "SELECT u.rowid, u.name, u.firstname, u.code ";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u ";
# $sql .= " LEFT JOIN llx_usergroup_user ug ON u.rowid = ug.fk_user";
# $sql .= " WHERE ug.fk_usergroup IS NULL";
$sql .= " ORDER BY u.name";
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows();
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object();
$uss[$obj->rowid] = ucfirst(stripslashes($obj->firstname)) . " ".ucfirst(stripslashes($obj->name));
$i++;
}
}
else {
dolibarr_print_error($db);
}
if ($user->admin)
{
$form = new Form($db);
print '<form action="fiche.php?id='.$group->id.'" method="post">'."\n";
print '<input type="hidden" name="action" value="adduser">';
print '<table class="noborder" width="100%">'."\n";
// print '<tr class="liste_titre"><td width="25%">'.$langs->trans("NonAffectedUsers").'</td>'."\n";
print '<tr class="liste_titre"><td width="25%">'.$langs->trans("Users").'</td>'."\n";
print '<td>';
print $form->select_array("user",$uss);
print '</td><td align="left">';
print '<input type="submit" class=button value="'.$langs->trans("Add").'">';
print '</td></tr>'."\n";
print '</table></form>'."\n";
}
/*
* Membres du groupe
*
*/
$sql = "SELECT u.rowid, u.name, u.firstname, u.code ";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
$sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug";
$sql .= " WHERE ug.fk_user = u.rowid";
$sql .= " AND ug.fk_usergroup = ".$group->id;
$sql .= " ORDER BY u.name";
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
print "<br>";
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td width="25%">'.$langs->trans("Lastname").'</td>';
print '<td width="25%">'.$langs->trans("Firstname").'</td>';
print '<td>'.$langs->trans("Code").'</td>';
print "<td>&nbsp;</td></tr>\n";
$var=True;
while ($i < $num)
{
$obj = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowUser"),"user").'</a> ';
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->rowid.'">'.ucfirst(stripslashes($obj->name)).'</a>';
print '</td>';
print '<td>'.ucfirst(stripslashes($obj->firstname)).'</td>';
print '<td>'.$obj->code.'</td><td>';
if ($user->admin)
{
print '<a href="fiche.php?id='.$group->id.'&amp;action=removeuser&amp;user='.$obj->rowid.'">';
print img_delete($langs->trans("RemoveFromGroup"));
}
else
{
print "-";
}
print "</td></tr>\n";
$i++;
}
print "</table>";
print "<br>";
$db->free($result);
}
print '</div>';
}
}
......
<?php
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric 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/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 '<table width="100%" class="noborder">';
print '<tr class="liste_titre"><td width="24">&nbsp</td><td width="24">&nbsp</td><td>'.$langs->trans("Permissions").'</td><td>'.$langs->trans("Module").'</td></tr>';
$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 '<tr '. $bc[$var].'>';
if ( $user->admin )
{
if (in_array($obj->id, $perms))
{
print '<td>&nbsp;</td>';
print '<td>';
print '<a href="perms.php?id='.$fgroup->id.'&amp;action=perms&amp;subaction=delrights&amp;rights='.$obj->id.'">'.img_edit_remove().'</a>';
print '</td>';
}
else
{
print '<td>';
print '<a href="perms.php?id='.$fgroup->id.'&amp;action=perms&amp;subaction=addrights&amp;rights='.$obj->id.'">'.img_edit_add().'</a>';
print '</td>';
print '<td>&nbsp;</td>';
}
print '<td>'.$obj->libelle . '</td><td>'.$obj->module . '</td>';
print '</tr>';
}
else
{
if (in_array($obj->id, $perms))
{
print '<td>&nbsp;</td><td>&nbsp;</td>';
print '<td>'.$obj->libelle . '</td><td>'.$obj->module . '</td>';
print '</tr>';
}
}
$i++;
}
}
print '</table>';
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>
......@@ -40,7 +40,7 @@ if ($page < 0) $page = 0;
$limit = $conf->liste_limit;
$offset = $limit * $page ;
if (! $sortfield) $sortfield="u.name";
if (! $sortfield) $sortfield="u.login";
if (! $sortorder) $sortorder="ASC";
......@@ -66,9 +66,9 @@ if ($result)
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Login"),"index.php","u.login","","","",$sortfield);
print_liste_field_titre($langs->trans("Lastname"),"index.php","u.name","","","",$sortfield);
print_liste_field_titre($langs->trans("Firstname"),"index.php","u.firstname","","","",$sortfield);
print_liste_field_titre($langs->trans("Login"),"index.php","u.login","","","",$sortfield);
print_liste_field_titre($langs->trans("Code"),"index.php","u.code","","","",$sortfield);
print_liste_field_titre($langs->trans("DateCreation"),"index.php","u.datec","","","",$sortfield);
print "</tr>\n";
......@@ -79,8 +79,6 @@ if ($result)
$var=!$var;
print "<tr $bc[$var]>";
print '<td>'.ucfirst($obj->name).'</td>';
print '<td>'.ucfirst($obj->firstname).'</td>';
if ($obj->login)
{
print '<td><a href="fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowUser"),"user").' '.$obj->login.'</a></td>';
......@@ -89,6 +87,8 @@ if ($result)
{
print '<td><a class="impayee" href="fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowUser"),"user").' Inactif</a></td>';
}
print '<td>'.ucfirst($obj->name).'</td>';
print '<td>'.ucfirst($obj->firstname).'</td>';
print '<td>'.$obj->code.'</td>';
print '<td width="100" align="center">'.dolibarr_print_date($obj->datec,"%d %b %Y").'</td>';
print "</tr>\n";
......
......@@ -22,7 +22,7 @@
* $Source$
*/
/** \file htdocs/user/fiche.php
/** \file htdocs/user/perms.php
\brief Onglet user et permissions de la fiche utilisateur
\version $Revision$
*/
......@@ -53,79 +53,9 @@ if ($_GET["subaction"] == 'delrights' && $user->admin)
$edituser->delrights($_GET["rights"]);
}
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes")
{
if ($_GET["id"] <> $user->id && $user->admin)
{
$edituser = new User($db, $_GET["id"]);
$edituser->fetch($_GET["id"]);
$edituser->delete();
Header("Location: index.php");
}
}
/**
* Action ajout user
*/
if ($_POST["action"] == 'add' && $user->admin)
{
$message="";
if (! $_POST["nom"])
{
$message='<div class="error">'.$langs->trans("NameNotDefined").'</div>';
$action="create"; // Go back to create page
}
if (! $_POST["login"])
{
$message='<div class="error">'.$langs->trans("LoginNotDefined").'</div>';
$action="create"; // Go back to create page
}
if (! $message)
{
$edituser = new User($db,0);
$edituser->nom = trim($_POST["nom"]);
$edituser->note = trim($_POST["note"]);
$edituser->prenom = trim($_POST["prenom"]);
$edituser->login = trim($_POST["login"]);
$edituser->email = trim($_POST["email"]);
$edituser->admin = trim($_POST["admin"]);
$edituser->webcal_login = trim($_POST["webcal_login"]);
$id = $edituser->create();
if ($id)
{
if (isset($_POST['password']) && trim($_POST['password']))
{
$edituser->password(trim($_POST['password']),$conf->password_encrypted);
}
Header("Location: fiche.php?id=$id");
}
else
{
$message='<div class="error">'.$langs->trans("ErrorLoginAlreadyExists",$edituser->login).'</div>';
$action="create"; // Go back to create page
}
}
}
if ($_GET["action"] == 'password' && $user->admin)
{
$edituser = new User($db, $_GET["id"]);
$edituser->fetch();
if ($edituser->password($user,'',$conf->password_encrypted))
{
$message = '<div class="ok">'.$langs->trans("PasswordChangedAndSentTo",$edituser->email).'</div>';
}
}
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 '<table width="100%" class="noborder">';
print '<tr class="liste_titre"><td width="24">&nbsp</td><td width="24">&nbsp</td><td>'.$langs->trans("AvailableRights").'</td><td>'.$langs->trans("Module").'</td></tr>';
print '<tr class="liste_titre"><td width="24">&nbsp</td><td width="24">&nbsp</td><td>'.$langs->trans("Permissions").'</td><td>'.$langs->trans("Module").'</td></tr>';
$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 '<td>&nbsp;</td>';
print '<td>';
print "<a href=\"perms.php?id=".$fuser->id."&amp;action=perms&amp;subaction=delrights&amp;rights=".$obj->id."\">".img_edit_remove()."</a>\n";
print '<a href="perms.php?id='.$fuser->id.'&amp;action=perms&amp;subaction=delrights&amp;rights='.$obj->id.'">'.img_edit_remove().'</a>';
print '</td>';
}
else
{
......@@ -238,7 +166,6 @@ if ($_GET["id"])
print '<td>&nbsp;</td>';
}
print '<td>'.$obj->libelle . '</td><td>'.$obj->module . '</td>';
print '</tr>';
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment