From e152a86eae1faf86959803d5807114f866bc8c87 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 29 Oct 2010 07:27:33 +0000 Subject: [PATCH] New: Task #10725 --- htdocs/user/fiche.php | 20 +++---- htdocs/user/group/index.php | 6 +-- htdocs/user/home.php | 105 +++++++++++++++++++----------------- 3 files changed, 68 insertions(+), 63 deletions(-) diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index ca6bcd60892..2f81d95e995 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -39,8 +39,8 @@ if ($conf->adherent->enabled) require_once(DOL_DOCUMENT_ROOT."/adherents/class/a // Define value to know what current user can do on users $canadduser=($user->admin || $user->rights->user->user->creer); $canreaduser=($user->admin || $user->rights->user->user->lire); -$caneditperms=($user->admin || $user->rights->user->user->creer); -$candisableperms=($user->admin || $user->rights->user->user->supprimer); +$canedituser=($user->admin || $user->rights->user->user->creer); +$candisableuser=($user->admin || $user->rights->user->user->supprimer); // Define value to know what current user can do on properties of edited user if ($_GET["id"]) { @@ -81,14 +81,14 @@ $quality = 80; /** * Actions */ -if ($_GET["subaction"] == 'addrights' && $caneditperms) +if ($_GET["subaction"] == 'addrights' && $canedituser) { $edituser = new User($db); $edituser->fetch($_GET["id"]); $edituser->addrights($_GET["rights"]); } -if ($_GET["subaction"] == 'delrights' && $caneditperms) +if ($_GET["subaction"] == 'delrights' && $canedituser) { $edituser = new User($db); $edituser->fetch($_GET["id"]); @@ -1143,19 +1143,19 @@ else } // Activer - if ($user->id <> $_GET["id"] && $candisableperms && $fuser->statut == 0 && + if ($user->id <> $_GET["id"] && $candisableuser && $fuser->statut == 0 && (empty($conf->global->MAIN_MODULE_MULTICOMPANY) || ($fuser->entity == $conf->entity)) ) { print ''.$langs->trans("Reactivate").''; } // Desactiver - if ($user->id <> $_GET["id"] && $candisableperms && $fuser->statut == 1 && + if ($user->id <> $_GET["id"] && $candisableuser && $fuser->statut == 1 && (empty($conf->global->MAIN_MODULE_MULTICOMPANY) || ($fuser->entity == $conf->entity)) ) { print ''.$langs->trans("DisableUser").''; } // Delete - if ($user->id <> $_GET["id"] && $candisableperms && + if ($user->id <> $_GET["id"] && $candisableuser && (empty($conf->global->MAIN_MODULE_MULTICOMPANY) || ($fuser->entity == $conf->entity)) ) { print ''.$langs->trans("DeleteUser").''; @@ -1256,7 +1256,7 @@ else } $db->free($resql); - if ($caneditperms) + if ($canedituser) { $form = new Form($db); print '
'."\n"; @@ -1309,7 +1309,7 @@ else print ''; print ''; - if ($caneditperms) + if ($canedituser) { print 'id.'">'; print img_delete($langs->trans("RemoveFromGroup")); @@ -1335,7 +1335,7 @@ else * Fiche en mode edition */ - if ($_GET["action"] == 'edit' && ($caneditperms || ($user->id == $fuser->id))) + if ($_GET["action"] == 'edit' && ($canedituser || ($user->id == $fuser->id))) { print ''; diff --git a/htdocs/user/group/index.php b/htdocs/user/group/index.php index 1b7e4a1fe6e..6b1224f4b21 100644 --- a/htdocs/user/group/index.php +++ b/htdocs/user/group/index.php @@ -1,7 +1,7 @@ - * Copyright (C) 2004-2005 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2005-2010 Regis Houssin * * 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 @@ -28,7 +28,7 @@ require("../../main.inc.php"); -if (! $user->rights->user->user->lire && ! $user->admin) accessforbidden(); +if (! $user->rights->user->group->lire && ! $user->admin) accessforbidden(); $langs->load("users"); diff --git a/htdocs/user/home.php b/htdocs/user/home.php index fcd79c61e71..7c3db54c3e2 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2009 Regis Houssin +/* Copyright (C) 2005-2010 Laurent Destailleur + * Copyright (C) 2005-2010 Regis Houssin * * 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 @@ -48,7 +48,7 @@ print ''; print ''; print '
'; -// Recherche User +// Search User $var=false; print ''; print ''; @@ -60,17 +60,20 @@ print '
'.$langs->trans("Other").':
\n"; print ''; -// Recherche Group -$var=false; -print '
'; -print ''; -print ''; -print ''; -print ''; -print ''; -print "
'.$langs->trans("SearchAGroup").'
'; -print $langs->trans("Ref").':
'.$langs->trans("Other").':

\n"; -print '
'; +// Search Group +if ($user->user->group->read) +{ + $var=false; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print "
'.$langs->trans("SearchAGroup").'
'; + print $langs->trans("Ref").':
'.$langs->trans("Other").':

\n"; + print '
'; +} print '
'; @@ -142,48 +145,50 @@ else /* * Derniers groupes crees */ -$max=5; - -$sql = "SELECT g.rowid, g.nom, g.note, g.entity, g.datec"; -$sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g"; -$sql.= " WHERE g.entity IN (0,".$conf->entity.")"; -$sql.= $db->order("g.datec","DESC"); -$sql.= $db->plimit($max); - -$resql=$db->query($sql); -if ($resql) +if ($user->user->group->read) { - $num = $db->num_rows($resql); - print ''; - print ''; - $var = true; - $i = 0; - - while ($i < $num && (! $max || $i < $max)) + $max=5; + + $sql = "SELECT g.rowid, g.nom, g.note, g.entity, g.datec"; + $sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g"; + $sql.= " WHERE g.entity IN (0,".$conf->entity.")"; + $sql.= $db->order("g.datec","DESC"); + $sql.= $db->plimit($max); + + $resql=$db->query($sql); + if ($resql) { - $obj = $db->fetch_object($resql); - $var=!$var; - - print ""; - print '
'.$langs->trans("LastGroupsCreated",($num ? $num : $max)).'
'.img_object($langs->trans("ShowGroup"),"group").' '.$obj->nom.''; - if (!$obj->entity) + $num = $db->num_rows($resql); + print ''; + print ''; + $var = true; + $i = 0; + + while ($i < $num && (! $max || $i < $max)) { - print img_picto($langs->trans("GlobalGroup"),'redstar'); + $obj = $db->fetch_object($resql); + $var=!$var; + + print ""; + print '"; + print ""; + print ""; + $i++; } - print ""; - print ""; - print ""; - $i++; + print "
'.$langs->trans("LastGroupsCreated",($num ? $num : $max)).'
'.img_object($langs->trans("ShowGroup"),"group").' '.$obj->nom.''; + if (!$obj->entity) + { + print img_picto($langs->trans("GlobalGroup"),'redstar'); + } + print "".dol_print_date($db->jdate($obj->datec))."
".dol_print_date($db->jdate($obj->datec))."

"; + + $db->free($resql); + } + else + { + dol_print_error($db); } - print "

"; - - $db->free($resql); } -else -{ - dol_print_error($db); -} - print '
';