summaryrefslogtreecommitdiff
path: root/inc/auth.php
diff options
context:
space:
mode:
authorGuy Brand <gb@isis.u-strasbg.fr>2008-02-27 15:25:15 +0100
committerGuy Brand <gb@isis.u-strasbg.fr>2008-02-27 15:25:15 +0100
commit7651d633d828ae1f70ca70634c5ebfe0686db25a (patch)
treed4d1aadeff14bdd43a83af4fc6daa7bae59e5b45 /inc/auth.php
parent52b0dd6759c3a1c726ae81acf5ab430b1ee6f308 (diff)
downloadrpg-7651d633d828ae1f70ca70634c5ebfe0686db25a.tar.gz
rpg-7651d633d828ae1f70ca70634c5ebfe0686db25a.tar.bz2
Superuser and manager now can be comma separated lists
This patch allows $conf['superuser'] and $conf['manager'] to be lists of values instead of only a single value. So one can put: $conf['superuser'] darcs-hash:20080227142515-19e2d-c160914589f71531583e7ddaab1fc6a81996efa1.gz
Diffstat (limited to 'inc/auth.php')
-rw-r--r--inc/auth.php23
1 files changed, 19 insertions, 4 deletions
diff --git a/inc/auth.php b/inc/auth.php
index 85576b680..5316ca382 100644
--- a/inc/auth.php
+++ b/inc/auth.php
@@ -273,9 +273,22 @@ function auth_ismanager($user=null,$groups=null,$adminonly=false){
$user = auth_nameencode($user);
// check username against superuser and manager
- if(auth_nameencode($conf['superuser']) == $user) return true;
+ $superusers = explode(',', $conf['superuser']);
+ $superusers = array_unique($superusers);
+ $superusers = array_map('trim', $superusers);
+ // prepare an array containing only true values for array_map call
+ $alltrue = array_fill(0, count($superusers), true);
+ $superusers = array_map('auth_nameencode', $superusers, $alltrue);
+ if(in_array($user, $superusers)) return true;
+
if(!$adminonly){
- if(auth_nameencode($conf['manager']) == $user) return true;
+ $managers = explode(',', $conf['manager']);
+ $managers = array_unique($managers);
+ $managers = array_map('trim', $managers);
+ // prepare an array containing only true values for array_map call
+ $alltrue = array_fill(0, count($managers), true);
+ $managers = array_map('auth_nameencode', $managers, $alltrue);
+ if(in_array($user, $managers)) return true;
}
// check user's groups against superuser and manager
@@ -288,9 +301,11 @@ function auth_ismanager($user=null,$groups=null,$adminonly=false){
}
// check groups against superuser and manager
- if(in_array(auth_nameencode($conf['superuser'],true), $groups)) return true;
+ foreach($superusers as $supu)
+ if(in_array($supu, $groups)) return true;
if(!$adminonly){
- if(in_array(auth_nameencode($conf['manager'],true), $groups)) return true;
+ foreach($managers as $mana)
+ if(in_array($mana, $groups)) return true;
}
}