From 1d24e8346bb54eb73f6a46b3adf836f505555681 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 20 Dec 2009 23:34:13 +0000 Subject: [PATCH] If multicompany is not enabled, admin users must be treated as superadmin. --- htdocs/admin/system/constall.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/system/constall.php b/htdocs/admin/system/constall.php index 70fbcad18d3..d10f184eab8 100644 --- a/htdocs/admin/system/constall.php +++ b/htdocs/admin/system/constall.php @@ -45,7 +45,7 @@ print ''; print ''; print ''; print ''; -if (!$user->entity) print ''; +if (empty($conf->multicompany->enabled) || !$user->entity) print ''; // If superadmin or multicompany disabled print "\n"; $sql = "SELECT"; @@ -56,25 +56,33 @@ $sql.= ", type"; $sql.= ", note"; $sql.= ", entity"; $sql.= " FROM ".MAIN_DB_PREFIX."const"; -$sql.= " WHERE entity IN (".$user->entity.",".$conf->entity.")"; -$sql.= " ORDER BY entity, name ASC"; - -$result = $db->query($sql); -if ($result) +if (empty($conf->multicompany->enabled)) { - $num = $db->num_rows(); + // If no multicompany mode, admins can see global and their constantes + $sql.= " WHERE entity IN (0,".$conf->entity.")"; +} +else +{ + // If multicompany mode, superadmin (user->entity=0) can see everything, admin are limited to their entities. + if ($user->entity) $sql.= " WHERE entity IN (".$user->entity.",".$conf->entity.")"; +} +$sql.= " ORDER BY entity, name ASC"; +$resql = $db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); $i = 0; $var=True; while ($i < $num) { - $obj = $db->fetch_object($result); + $obj = $db->fetch_object($resql); $var=!$var; print ''; print ''."\n"; print ''."\n"; - if (!$user->entity) print ''."\n"; + if (empty($conf->multicompany->enabled) || !$user->entity) print ''."\n"; // If superadmin or multicompany disabled print "\n"; $i++;
'.$langs->trans("Parameter").''.$langs->trans("Value").''.$langs->trans("Entity").''.$langs->trans("Entity").'
'.$obj->name.''.$obj->value.''.$obj->entity.''.$obj->entity.'