* Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2004 Laurent Destailleur * * 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$ */ require("./pre.inc.php"); $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 ($id <> $user->id) { $edituser = new User($db, $id); $edituser->fetch($id); $edituser->delete(); Header("Location: index.php"); } } if ($_POST["action"] == 'add' && $user->admin) { $edituser = new User($db,0); $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"]; $id = $edituser->create(); if (isset($_POST['password']) && $_POST['password']!='' ) { $edituser->password($_POST['password'],$conf->password_encrypted); } } 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 ($action == 'password' && $user->admin) { $edituser = new User($db, $id); $edituser->fetch(); if ($edituser->password('',$conf->password_encrypted)) { $message = "Mot de passe changé et envoyé à $edituser->email"; } } llxHeader(); /* ************************************************************************** */ /* */ /* Nouvel utilisateur */ /* */ /* ************************************************************************** */ if ($action == 'create') { print_titre('Nouvel utilisateur'); print '
'; print ''; print ''; print ''; print ''; print "".''; print ''; print "".''; print ''; print "".''; print ''; print "".''; print ''; print "".''; print '\n"; if (defined("MAIN_MODULE_WEBCALENDAR")) { print "".''; print ''; } print "".'\n"; print "".''; print ""; print "
Prénom
Nom
Login
Password
Email
Admin'; $form->selectyesnonum('admin',0); print "
Login Webcal
Note'; print "
\n"; } /* ************************************************************************** */ /* */ /* Visu et edition */ /* */ /* ************************************************************************** */ else { if ($_GET["id"]) { $fuser = new User($db, $_GET["id"]); $fuser->fetch(); /* * Confirmation suppression */ if ($action == 'delete') { print_fiche_titre("Suppression fiche utilisateur",$message); print '
'; $html = new Form($db); $html->form_confirm("$PHP_SELF?id=$fuser->id","Désactiver cet utilisateur","Etes-vous sûr de vouloir désactiver cet utilisateur ?","confirm_delete"); } if ($_GET["action"] == 'perms') { print_fiche_titre("Permissions utilisateur",$message); print '
'; /* * Ecran ajout/suppression permission */ print ''; print ''; print ''; print ''; print ''; // Droits existant print "".''; print "".'
Nom'.$fuser->nom.'Prénom'.$fuser->prenom.'
'; print ''; $sql = "SELECT r.id, r.libelle, r.module FROM ".MAIN_DB_PREFIX."rights_def as r ORDER BY 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 ''; $i++; } } print '
Ajouter'.$obj->libelle . ''.$obj->module . '
'; print '
'; // Droits possédés 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.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 ''; $i++; } } print '
".$obj->libelle . ''.$obj->module . ''.img_delete().'
'; print '
ok
'; } if ($_GET["action"] != 'perms' && $_GET["action"] != 'edit') { /* * Affichage onglet */ $h = 0; $head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?id='.$fuser->id; $head[$h][1] = "Fiche utilisateur"; $h++; dolibarr_fiche_head($head, $hselected); 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"; // Autres caractéristiques issus des autres modules if (defined("MAIN_MODULE_WEBCALENDAR")) { print "".''; print ''; print "\n"; } print "
Nom'.$fuser->nom.'Prénom'.$fuser->prenom.'
Login'.$fuser->login.'Email'.$fuser->email.'
Administrateur'.$yn[$fuser->admin].'
Id Société'.$fuser->societe_id.' 
Fiche contact'; if ($fuser->contact_id) { print 'Fiche contact'; } else { print "Pas de fiche parmi les Contacts"; } print '
Note'.nl2br($fuser->note).' 
Webcal Login'.$fuser->webcal_login.' 
\n"; print "
\n"; print "\n"; /* * Droits */ print ''; print ''; $sql = "SELECT 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.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 "\n"; $i++; } } print "
DroitsModule
".$obj->libelle . ''.$obj->module."
\n"; print "
\n"; /* * Barre d'actions * */ print '
'; if ($user->admin) { print 'Editer'; } if ($user->id == $id or $user->admin) { print 'Envoyer nouveau mot de passe'; } if ($user->admin) { print 'Permissions'; } if ($user->admin && $user->id <> $id) { print 'Désactiver utilisateur'; } print "
\n"; print "
\n"; } /* ************************************************************************** */ /* */ /* Edition */ /* */ /* ************************************************************************** */ if ($action == 'edit' && $user->admin && !$fuser->societe_id) { print_fiche_titre("Edition fiche utilisateur",$message); print '
'; print '
'; print ''; print ''; print "".''; print ''; print "".''; print ''; print "".''; print ''; print "".''; print ''; print "".''; print ''; print "".''; print ''; print "".'"; print "".''; print ''; print '
Nom
Prénom
Login
Email
Admin ?'; $form->selectyesnonum('admin',$fuser->admin); print '
Login Webcal
Note'; print "
'; } } } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>