From 94ea9f3c555b9ccb86fbd086019714efebafbbb4 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 13 Jan 2012 18:24:25 +0100 Subject: [PATCH] Fix: uniform code --- htdocs/user/class/user.class.php | 8 +++----- htdocs/user/group/fiche.php | 27 +++++++++++++-------------- htdocs/user/group/ldap.php | 14 ++++---------- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index b1caeaba7815a..6fac46f76ea0b 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -95,11 +95,11 @@ class User extends CommonObject /** * Constructor de la classe * - * @param DoliDb $DB Database handler + * @param DoliDb $db Database handler */ - function User($DB) + function __construct($db) { - $this->db = $DB; + $this->db = $db; // Preference utilisateur $this->liste_limit = 0; @@ -107,8 +107,6 @@ function User($DB) $this->all_permissions_are_loaded = 0; $this->admin=0; - - return 1; } /** diff --git a/htdocs/user/group/fiche.php b/htdocs/user/group/fiche.php index 9bf6c38b66be9..9c26e7be32ce8 100644 --- a/htdocs/user/group/fiche.php +++ b/htdocs/user/group/fiche.php @@ -43,10 +43,10 @@ $langs->load("users"); $langs->load("other"); -$id=GETPOST("id"); -$action=GETPOST("action"); -$confirm=GETPOST("confirm"); -$userid=GETPOST("user","int"); +$id=GETPOST('id', 'int'); +$action=GETPOST('action', 'alpha'); +$confirm=GETPOST('confirm', 'alpha'); +$userid=GETPOST('user', 'int'); // Security check $result = restrictedArea($user, 'user', $id, 'usergroup&usergroup', 'user'); @@ -66,7 +66,7 @@ { if ($caneditperms) { - $object->fetch($_GET["id"]); + $object->fetch($id); $object->delete(); Header("Location: index.php"); exit; @@ -95,11 +95,10 @@ if (! $message) { $object->nom = trim($_POST["nom"]); - if($conf->multicompany->enabled && !empty($conf->multicompany->transverse_mode)) - $object->entity = 0; - else - $object->entity = $_POST["entity"]; $object->note = trim($_POST["note"]); + + if($conf->multicompany->enabled && ! empty($conf->multicompany->transverse_mode)) $object->entity = 0; + else $object->entity = $_POST["entity"]; $db->begin(); @@ -176,11 +175,10 @@ $object->oldcopy=dol_clone($object); $object->nom = trim($_POST["group"]); - if($conf->multicompany->enabled && !empty($conf->multicompany->transverse_mode)) - $object->entity = 0; - else - $object->entity = $_POST["entity"]; $object->note = dol_htmlcleanlastbr($_POST["note"]); + + if($conf->multicompany->enabled && !empty($conf->multicompany->transverse_mode)) $object->entity = 0; + else $object->entity = $_POST["entity"]; $ret=$object->update(); @@ -507,5 +505,6 @@ llxFooter(); -if (is_object($db)) $db->close(); +$db->close(); + ?> diff --git a/htdocs/user/group/ldap.php b/htdocs/user/group/ldap.php index 4275fc08a79df..69d21031574d8 100644 --- a/htdocs/user/group/ldap.php +++ b/htdocs/user/group/ldap.php @@ -40,12 +40,10 @@ } $id = GETPOST('id', 'int'); +$action = GETPOST('action', 'alpha'); $socid=0; -if ($user->societe_id > 0) -{ - $socid = $user->societe_id; -} +if ($user->societe_id > 0) $socid = $user->societe_id; $fgroup = new Usergroup($db); $fgroup->fetch($id); @@ -56,7 +54,7 @@ * Actions */ -if ($_GET["action"] == 'dolibarr2ldap') +if ($action == 'dolibarr2ldap') { $message=""; @@ -84,8 +82,6 @@ } - - /* * View */ @@ -208,10 +204,8 @@ print ''; - - +llxFooter(); $db->close(); -llxFooter(); ?>