Un utilisateur normal peut désormais consulter la liste de ses permissions

This commit is contained in:
Rodolphe Quiedeville 2005-02-21 11:32:14 +00:00
parent d3d0271eb1
commit eee50121ae

View File

@ -55,7 +55,7 @@ if ($_GET["subaction"] == 'delrights' && $user->admin)
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes") if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes")
{ {
if ($_GET["id"] <> $user->id) if ($_GET["id"] <> $user->id && $user->admin)
{ {
$edituser = new User($db, $_GET["id"]); $edituser = new User($db, $_GET["id"]);
$edituser->fetch($_GET["id"]); $edituser->fetch($_GET["id"]);
@ -70,15 +70,18 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes")
if ($_POST["action"] == 'add' && $user->admin) if ($_POST["action"] == 'add' && $user->admin)
{ {
$message=""; $message="";
if (! $_POST["nom"]) { if (! $_POST["nom"])
{
$message='<div class="error">'.$langs->trans("NameNotDefined").'</div>'; $message='<div class="error">'.$langs->trans("NameNotDefined").'</div>';
$action="create"; // Go back to create page $action="create"; // Go back to create page
} }
if (! $_POST["login"]) { if (! $_POST["login"])
{
$message='<div class="error">'.$langs->trans("LoginNotDefined").'</div>'; $message='<div class="error">'.$langs->trans("LoginNotDefined").'</div>';
$action="create"; // Go back to create page $action="create"; // Go back to create page
} }
if (! $message) { if (! $message)
{
$edituser = new User($db,0); $edituser = new User($db,0);
$edituser->nom = trim($_POST["nom"]); $edituser->nom = trim($_POST["nom"]);
@ -91,7 +94,8 @@ if ($_POST["action"] == 'add' && $user->admin)
$id = $edituser->create(); $id = $edituser->create();
if ($id) { if ($id)
{
if (isset($_POST['password']) && trim($_POST['password'])) if (isset($_POST['password']) && trim($_POST['password']))
{ {
$edituser->password(trim($_POST['password']),$conf->password_encrypted); $edituser->password(trim($_POST['password']),$conf->password_encrypted);
@ -99,7 +103,8 @@ if ($_POST["action"] == 'add' && $user->admin)
Header("Location: fiche.php?id=$id"); Header("Location: fiche.php?id=$id");
} }
else { else
{
$message='<div class="error">'.$langs->trans("ErrorLoginAlreadyExists",$edituser->login).'</div>'; $message='<div class="error">'.$langs->trans("ErrorLoginAlreadyExists",$edituser->login).'</div>';
$action="create"; // Go back to create page $action="create"; // Go back to create page
} }
@ -145,7 +150,7 @@ if ($_GET["id"])
$head[$h][1] = $langs->trans("UserCard"); $head[$h][1] = $langs->trans("UserCard");
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?action=perms&amp;id='.$fuser->id; $head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$fuser->id;
$head[$h][1] = $langs->trans("Permissions"); $head[$h][1] = $langs->trans("Permissions");
$hselected=$h; $hselected=$h;
$h++; $h++;
@ -215,8 +220,8 @@ if ($_GET["id"])
} }
print '<tr '. $bc[$var].'>'; print '<tr '. $bc[$var].'>';
if ( $user->admin )
{
if (in_array($obj->id, $perms)) if (in_array($obj->id, $perms))
{ {
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
@ -234,9 +239,18 @@ if ($_GET["id"])
} }
print '<td>'.$obj->libelle . '</td><td>'.$obj->module . '</td>'; print '<td>'.$obj->libelle . '</td><td>'.$obj->module . '</td>';
print '</tr>'; 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++; $i++;