From 1737b4df54a5f8eb36d23f38d06b744e4658a06d Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Fri, 14 Jan 2005 15:39:46 +0000 Subject: [PATCH] Suppression de la liste des permissions en mode visu --- htdocs/user/fiche.php | 445 +++++++++++++++++++----------------------- 1 file changed, 202 insertions(+), 243 deletions(-) diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 39352e246a2..909eb2546a7 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -23,9 +23,9 @@ */ /** - \file htdocs/user/fiche.php - \brief Onglet user et permissions de la fiche utilisateur - \version $Revision$ + \file htdocs/user/fiche.php + \brief Onglet user et permissions de la fiche utilisateur + \version $Revision$ */ @@ -41,14 +41,14 @@ $action=isset($_GET["action"])?$_GET["action"]:$_POST["action"]; if ($_GET["subaction"] == 'addrights' && $user->admin) { - $edituser = new User($db,$_GET["id"]); - $edituser->addrights($_GET["rights"]); + $edituser = new User($db,$_GET["id"]); + $edituser->addrights($_GET["rights"]); } if ($_GET["subaction"] == 'delrights' && $user->admin) { - $edituser = new User($db,$_GET["id"]); - $edituser->delrights($_GET["rights"]); + $edituser = new User($db,$_GET["id"]); + $edituser->delrights($_GET["rights"]); } if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes") @@ -67,41 +67,41 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes") */ if ($_POST["action"] == 'add' && $user->admin) { - $message=""; - if (! $_POST["nom"]) { - $message='
'.$langs->trans("NameNotDefined").'
'; - $action="create"; // Go back to create page - } - if (! $_POST["login"]) { - $message='
'.$langs->trans("LoginNotDefined").'
'; - $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='
'.$langs->trans("LoginAlreadyExists",$edituser->login).'
'; - $action="create"; // Go back to create page - } + $message=""; + if (! $_POST["nom"]) { + $message='
'.$langs->trans("NameNotDefined").'
'; + $action="create"; // Go back to create page + } + if (! $_POST["login"]) { + $message='
'.$langs->trans("LoginNotDefined").'
'; + $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='
'.$langs->trans("LoginAlreadyExists",$edituser->login).'
'; + $action="create"; // Go back to create page } + } } if ($_POST["action"] == 'update' && $user->admin) @@ -129,12 +129,12 @@ if ($_POST["action"] == 'update' && $user->admin) if ($_GET["action"] == 'password' && $user->admin) { - $edituser = new User($db, $_GET["id"]); - $edituser->fetch(); + $edituser = new User($db, $_GET["id"]); + $edituser->fetch(); - if ($edituser->password('',$conf->password_encrypted)) + if ($edituser->password('',$conf->password_encrypted)) { - $message = "Mot de passe changé et envoyé à $edituser->email"; + $message = "Mot de passe changé et envoyé à $edituser->email"; } } @@ -151,49 +151,49 @@ llxHeader(); if ($action == 'create') { - print_titre($langs->trans("NewUser")); + print_titre($langs->trans("NewUser")); - if ($message) { print "
".$message."
"; } + if ($message) { print "
".$message."
"; } - print '
'; - print ''; + print ''; + print ''; - print ''; + print '
'; - print "".''; - print ''; + print "".''; + print ''; - print ''; - print ''; + print ''; + print ''; - print "".''; - print ''; + print "".''; + print ''; - print "".''; - print ''; + print "".''; + print ''; - print "".''; - print ''; + print "".''; + print ''; - print "".''; - print '\n"; + print "".''; + print '\n"; - print "".'\n"; + print "".'\n"; - // Autres caractéristiques issus des autres modules - if ($conf->webcal->enabled) + // Autres caractéristiques issus des autres modules + if ($conf->webcal->enabled) { - print "".''; - print ''; + print "".''; + print ''; } - print "".''; - print ""; - print "
'.$langs->trans("Lastname").'
'.$langs->trans("Lastname").'
'.$langs->trans("Firstname").'
'.$langs->trans("Firstname").'
'.$langs->trans("Login").'
'.$langs->trans("Login").'
'.$langs->trans("Password").'
'.$langs->trans("Password").'
'.$langs->trans("EMail").'
'.$langs->trans("EMail").'
'.$langs->trans("Administrator").''; - $form->selectyesnonum('admin',0); - print "
'.$langs->trans("Administrator").''; + $form->selectyesnonum('admin',0); + print "
'.$langs->trans("Note").''; - print "
'.$langs->trans("Note").''; + print "
'.$langs->trans("LoginWebcal").'
'.$langs->trans("LoginWebcal").'
\n"; + print "".''; + print ""; + print "\n"; } @@ -204,50 +204,50 @@ if ($action == 'create') /* ************************************************************************** */ else { - if ($_GET["id"]) + if ($_GET["id"]) { - $fuser = new User($db, $_GET["id"]); - $fuser->fetch(); - $fuser->getrights(); + $fuser = new User($db, $_GET["id"]); + $fuser->fetch(); + $fuser->getrights(); - /* - * Affichage onglets - */ + /* + * Affichage onglets + */ - $h = 0; + $h = 0; - $head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?id='.$fuser->id; - $head[$h][1] = $langs->trans("UserCard"); - if ($_GET["action"] != 'perms') { $hselected=$h; } - $h++; + $head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?id='.$fuser->id; + $head[$h][1] = $langs->trans("UserCard"); + if ($_GET["action"] != 'perms') { $hselected=$h; } + $h++; - if ($user->admin) + if ($user->admin) { - $head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?action=perms&id='.$fuser->id; - $head[$h][1] = $langs->trans("Permissions"); - if ($_GET["action"] == 'perms') { $hselected=$h; } - $h++; + $head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?action=perms&id='.$fuser->id; + $head[$h][1] = $langs->trans("Permissions"); + if ($_GET["action"] == 'perms') { $hselected=$h; } + $h++; } - $head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$fuser->id; - $head[$h][1] = $langs->trans("Addons"); - $h++; + $head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$fuser->id; + $head[$h][1] = $langs->trans("Addons"); + $h++; - dolibarr_fiche_head($head, $hselected, $fuser->fullname); + dolibarr_fiche_head($head, $hselected, $fuser->fullname); - /* - * Confirmation suppression - */ - if ($action == 'delete') + /* + * 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 = new Form($db); + $html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$fuser->login),"confirm_delete"); } - if ($_GET["action"] == 'perms') + if ($_GET["action"] == 'perms') { if ($message) { print "$message
"; } @@ -320,187 +320,146 @@ else } - if ($_GET["action"] != 'perms' && $_GET["action"] != 'edit') - { - /* - * Fiche en mode visu - */ + if ($_GET["action"] != 'perms' && $_GET["action"] != 'edit') + { + /* + * Fiche en mode visu + */ - print ''; + print '
'; - print "".''; - print ''; - print ''; - print ''; - print "\n"; + print "".''; + print ''; + print ''; + print ''; + print "\n"; - print "".''; - print ''; - print ''; - print ''; - print "\n"; + print "".''; + print ''; + print ''; + print ''; + print "\n"; - print "".''; - print ''; - print "\n"; + print "".''; + print ''; + print "\n"; - if ($fuser->societe_id > 0) - { - $societe = new Societe($db); - $societe->fetch($fuser->societe_id); - print "".''; - print ''; - print "\n"; - } + if ($fuser->societe_id > 0) + { + $societe = new Societe($db); + $societe->fetch($fuser->societe_id); + print "".''; + print ''; + print "\n"; + } - print "".''; - print '".''; + print ''; - print "\n"; + print ''; + print "\n"; - print "".''; - print ''; - print "\n"; + print "".''; + print ''; + print "\n"; - // Autres caractéristiques issus des autres modules - if ($conf->webcal->enabled) + // Autres caractéristiques issus des autres modules + if ($conf->webcal->enabled) { - $langs->load("other"); - print ''; - print ''; - print "\n"; + $langs->load("other"); + print ''; + print ''; + print "\n"; } - print "
'.$langs->trans("Lastname").''.$fuser->nom.''.$langs->trans("Firstname").''.$fuser->prenom.'
'.$langs->trans("Lastname").''.$fuser->nom.''.$langs->trans("Firstname").''.$fuser->prenom.'
'.$langs->trans("Login").''.$fuser->login.''.$langs->trans("EMail").''.$fuser->email.'
'.$langs->trans("Login").''.$fuser->login.''.$langs->trans("EMail").''.$fuser->email.'
'.$langs->trans("Administrator").''.yn($fuser->admin).'
'.$langs->trans("Administrator").''.yn($fuser->admin).'
'.$langs->trans("Company").''.$societe->nom.' 
'.$langs->trans("Company").''.$societe->nom.' 
'.$langs->trans("ContactCard").''; - if ($fuser->contact_id) + print "
'.$langs->trans("ContactCard").''; + if ($fuser->contact_id) { - print ''.$langs->trans("ContactCard").''; + print ''.$langs->trans("ContactCard").''; } - else + else { - print $langs->trans("NoContactCard"); + print $langs->trans("NoContactCard"); } - print '
'.$langs->trans("Note").''.nl2br($fuser->note).' 
'.$langs->trans("Note").''.nl2br($fuser->note).' 
'.$langs->trans("LoginWebcal").''.$fuser->webcal_login.' 
'.$langs->trans("LoginWebcal").''.$fuser->webcal_login.' 
\n"; - print "
\n"; + print "\n"; + print "
\n"; - print "\n"; + print "\n"; - /* - * Barre d'actions - * - */ - print '
'; + /* + * Barre d'actions + * + */ + print '
'; - if ($user->admin) + if ($user->admin) { - print ''.$langs->trans("Edit").''; + print ''.$langs->trans("Edit").''; } - if ($user->id == $_GET["id"] or $user->admin) + if ($user->id == $_GET["id"] or $user->admin) { - print ''.$langs->trans("SendNewPassword").''; + print ''.$langs->trans("SendNewPassword").''; } - if ($user->id <> $_GET["id"] && $user->admin) + if ($user->id <> $_GET["id"] && $user->admin) { - print ''.$langs->trans("DisableUser").''; + print ''.$langs->trans("DisableUser").''; } - print "
\n"; - print "
\n"; - - - /* - * Droits - */ - print ''; - print ''; - $sql = "SELECT r.libelle, r.module, r.perms, r.subperms FROM ".MAIN_DB_PREFIX."rights_def as r, ".MAIN_DB_PREFIX."user_rights as ur"; - $sql .= " WHERE ur.fk_id = r.id AND ur.fk_user = ".$fuser->id. " ORDER BY r.module, r.id ASC"; - $var = True; - if ($db->query($sql)) - { - $num = $db->num_rows(); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($i); - if ($oldmod <> $obj->module) - { - $oldmod = $obj->module; - $var = !$var; - } - if (! $obj->perms) { - // Si droit selon ancien modèle - print "\n"; - } else { - // Si droit selon nouveau modèle (avec sous niveaux de droits) - $mod=$obj->module; - $perm=$obj->perms; - $subperm=$obj->subperms; - $droit = $fuser->rights->$mod->$perm->$subperm; - if ($droit) - { - print "\n"; - } - } - $i++; - } - } - print "
'.$langs->trans("Module").''.$langs->trans("Permissions").'
".$obj->module."".$obj->libelle . "
".$obj->module."".$obj->libelle."
\n"; - print "
\n"; + print "
\n"; + print "
\n"; - } + } - /* - * Fiche en mode edition - */ - if ($_GET["action"] == 'edit' && $user->admin) + /* + * Fiche en mode edition + */ + if ($_GET["action"] == 'edit' && $user->admin) { - print '
'; - print ''; - print ''; + print ''; + print ''; + print '
'; - print "".''; - print ''; + print "".''; + print ''; - print "".''; - print ''; + print "".''; + print ''; - print "".''; - print ''; + print "".''; + print ''; - print "".''; - print ''; + print "".''; + print ''; - print "".''; - if ($fuser->societe_id > 0) - { - print ''; - } - else - { - print ''; - } + print "".''; + if ($fuser->societe_id > 0) + { + print ''; + } + else + { + print ''; + } - print "".'"; + print "".'"; - // Autres caractéristiques issus des autres modules - $langs->load("other"); - print "".''; - print ''; + // Autres caractéristiques issus des autres modules + $langs->load("other"); + print "".''; + print ''; - print "".''; + print "".''; - print '
'.$langs->trans("Lastname").'
'.$langs->trans("Lastname").'
'.$langs->trans("Firstname").'
'.$langs->trans("Firstname").'
'.$langs->trans("Login").'
'.$langs->trans("Login").'
'.$langs->trans("EMail").'
'.$langs->trans("EMail").'
'.$langs->trans("Administrator").''; - print ''.$langs->trans("No"); - print '
'; - $form->selectyesnonum('admin',$fuser->admin); - print '
'.$langs->trans("Administrator").''; + print ''.$langs->trans("No"); + print '
'; + $form->selectyesnonum('admin',$fuser->admin); + print '
'.$langs->trans("Note").''; - print "
'.$langs->trans("Note").''; + print "
'.$langs->trans("LoginWebcal").'
'.$langs->trans("LoginWebcal").'

'; - print '
'; + print '
'; + print ''; } }