From 0acf5a566100a8895086e0b23dc3054302b1294e Mon Sep 17 00:00:00 2001 From: james Date: Mon, 6 Dec 2010 18:33:02 +0000 Subject: [PATCH] Allow superuser to always access admin/config even if its not in their session roles --- user.inc.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/user.inc.php b/user.inc.php index 146a369..f54654c 100644 --- a/user.inc.php +++ b/user.inc.php @@ -1086,7 +1086,16 @@ function user_auth_required($all_required = array(), $one_required = array()) * in $all_required that are also in the session roles */ if(!is_array($all_required)) $all_required = array($all_required); - $match = array_intersect($all_required, $_SESSION['roles']); + + //superuser always can access admin and config, even if its not in their SESSION roles + if($_SESSION['superuser']=="yes") { + $roles=array_merge(array("admin","config"),$_SESSION['roles']); + } + else { + $roles=$_SESSION['roles']; + } + + $match = array_intersect($all_required, $roles); if($all_required != $match) { /* Something is missing */ $ok = false; @@ -1095,7 +1104,7 @@ function user_auth_required($all_required = array(), $one_required = array()) /* Make sure the user has one role in $one_required */ if(!is_array($one_required)) $one_required = array($one_required); if(count($one_required)) { - $match = array_intersect($one_required, $_SESSION['roles']); + $match = array_intersect($one_required, $roles); if(count($match) == 0) { /* Missing any role in $one_required */ $ok = false;