* 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/fiche.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"]; if ($_GET["subaction"] == 'addrights' && $user->admin) { $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"]); } if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes") { if ($_GET["id"] <> $user->id) { $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='
'.$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) { $edituser = new User($db, $_GET["id"]); $edituser->fetch(); $edituser->nom = $_POST["nom"]; $edituser->note = $_POST["note"]; $edituser->prenom = $_POST["prenom"]; $edituser->login = $_POST["login"]; $edituser->email = $_POST["email"]; $edituser->admin = $_POST["admin"]; $edituser->webcal_login = $_POST["webcal_login"]; if (! $edituser->update()) { print $edituser->error(); } if (isset($password) && $password !='' ) { $edituser->password($password,$conf->password_encrypted); } } if ($_GET["action"] == 'password' && $user->admin) { $edituser = new User($db, $_GET["id"]); $edituser->fetch(); if ($edituser->password('',$conf->password_encrypted)) { $message = "Mot de passe changé et envoyé à $edituser->email"; } } llxHeader(); /* ************************************************************************** */ /* */ /* Affichage fiche en mode création */ /* */ /* ************************************************************************** */ if ($action == 'create') { print_titre($langs->trans("NewUser")); if ($message) { print "
".$message."
"; } print '
'; print ''; print ''; print "".''; print ''; print ''; print ''; print "".''; print ''; print "".''; print ''; print "".''; print ''; print "".''; print '\n"; print "".'\n"; // Autres caractéristiques issus des autres modules if ($conf->webcal->enabled) { print "".''; print ''; } print "".''; print ""; print "
'.$langs->trans("Lastname").'
'.$langs->trans("Firstname").'
'.$langs->trans("Login").'
'.$langs->trans("Password").'
'.$langs->trans("EMail").'
'.$langs->trans("Administrator").''; $form->selectyesnonum('admin',0); print "
'.$langs->trans("Note").''; print "
'.$langs->trans("LoginWebcal").'
\n"; } /* ************************************************************************** */ /* */ /* Visu et edition */ /* */ /* ************************************************************************** */ else { if ($_GET["id"]) { $fuser = new User($db, $_GET["id"]); $fuser->fetch(); $fuser->getrights(); /* * Affichage onglets */ $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++; 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/addon.php?id='.$fuser->id; $head[$h][1] = $langs->trans("Addons"); $h++; dolibarr_fiche_head($head, $hselected, $fuser->fullname); /* * 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"); } if ($_GET["action"] == 'perms') { if ($message) { print "$message
"; } /* * Ecran ajout/suppression permission */ print ''; // Droits existant print "".''; } if ($_GET["action"] != 'perms' && $_GET["action"] != 'edit') { /* * Fiche en mode visu */ print '
'; print ''; print ''; $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 ''; print ''; print ''; print ''; $i++; } } print '
'.$langs->trans("AvailableRights").''.$langs->trans("Module").' 
'.$obj->libelle . ''.$obj->module . ''.img_edit_add().'
'; print '
'; // Droits possédés print ''; print ''; $sql = "SELECT r.id, r.libelle, r.module 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; } print ""; print " \n"; print " \n"; print ""; $i++; } } print '
 '.$langs->trans("OwnedRights").''.$langs->trans("Module").'
id."&action=perms&subaction=delrights&rights=".$obj->id."\">".img_edit_remove()."".$obj->libelle . "".$obj->module . "
'; print '
'; print ''; print ''; print ''; print ''; print ''; print "\n"; print ''; print ''; print ''; print ''; print "\n"; print ''; print ''; print "\n"; 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"; } print "".''; print ''; print "\n"; // Autres caractéristiques issus des autres modules if ($conf->webcal->enabled) { $langs->load("other"); print ''; print ''; print "\n"; } print "
'.$langs->trans("Lastname").''.$fuser->nom.''; if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg")) { print ''; } else { print ''; } print '
'.$langs->trans("Firstname").''.$fuser->prenom.'
'.$langs->trans("Login").''.$fuser->login.'
'.$langs->trans("EMail").''.$fuser->email.'
'.$langs->trans("Administrator").''.yn($fuser->admin).'
'.$langs->trans("DateCreation").''.dolibarr_print_date($fuser->datec).'
'.$langs->trans("DateModification").''.dolibarr_print_date($fuser->datem).'
'.$langs->trans("ContactCard").''; if ($fuser->contact_id) { print ''.$langs->trans("ContactCard").''; } else { print $langs->trans("NoContactCard"); } print '
'.$langs->trans("Company").''.$societe->nom.' 
'.$langs->trans("Note").''.nl2br($fuser->note).' 
'.$langs->trans("LoginWebcal").''.$fuser->webcal_login.' 
\n"; print "
\n"; print "\n"; /* * Barre d'actions * */ print '
'; if ($user->admin) { print ''.$langs->trans("Edit").''; } if ($user->id == $_GET["id"] or $user->admin) { print ''.$langs->trans("SendNewPassword").''; } if ($user->id <> $_GET["id"] && $user->admin) { print ''.$langs->trans("DisableUser").''; } print "
\n"; print "
\n"; } /* * Fiche en mode edition */ if ($_GET["action"] == 'edit' && $user->admin) { print '
'; print ''; print ''; print "".''; print ''; print "".''; print ''; print "".''; print ''; print "".''; print ''; print "".''; if ($fuser->societe_id > 0) { print ''; } else { print ''; } print "".'"; // Autres caractéristiques issus des autres modules $langs->load("other"); print "".''; print ''; print "".''; print '
'.$langs->trans("Lastname").'
'.$langs->trans("Firstname").'
'.$langs->trans("Login").'
'.$langs->trans("EMail").'
'.$langs->trans("Administrator").''; print ''.$langs->trans("No"); print '
'; $form->selectyesnonum('admin',$fuser->admin); print '
'.$langs->trans("Note").''; print "
'.$langs->trans("LoginWebcal").'

'; print '
'; } } } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>