From 7651d633d828ae1f70ca70634c5ebfe0686db25a Mon Sep 17 00:00:00 2001 From: Guy Brand Date: Wed, 27 Feb 2008 15:25:15 +0100 Subject: 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 --- inc/auth.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'inc') 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; } } -- cgit v1.2.3