diff --git a/interface/lib/classes/auth.inc.php b/interface/lib/classes/auth.inc.php index 2075c7b90d10aaf8f14cc4648bf75a727f14ebb7..5daabd50b35a6ffdfc3e6933e7314c9ecd90cb99 100644 --- a/interface/lib/classes/auth.inc.php +++ b/interface/lib/classes/auth.inc.php @@ -141,12 +141,18 @@ class auth { } } - public function check_module_permissions($module) { + + /** + * Check that the user has access to the given module. + * + * @return boolean + */ + public function verify_module_permissions($module) { // Check if the current user has the permissions to access this module $module = trim(preg_replace('@\s+@', '', $module)); $user_modules = explode(',',$_SESSION["s"]["user"]["modules"]); + $can_use_module = false; if(strpos($module, ',') !== false){ - $can_use_module = false; $tmp_modules = explode(',', $module); if(is_array($tmp_modules) && !empty($tmp_modules)){ foreach($tmp_modules as $tmp_module){ @@ -158,17 +164,21 @@ class auth { } } } - if(!$can_use_module){ - // echo "LOGIN_REDIRECT:/index.php"; - header("Location: /index.php"); - exit; - } - } else { - if(!in_array($module,$user_modules)) { - // echo "LOGIN_REDIRECT:/index.php"; - header("Location: /index.php"); - exit; - } + } + elseif(in_array($module,$user_modules)) { + $can_use_module = true; + } + return $can_use_module; + } + + /** + * Check that the user has access to the given module, redirect and exit on failure. + */ + public function check_module_permissions($module) { + if(!$this->verify_module_permissions($module)) { + // echo "LOGIN_REDIRECT:/index.php"; + header("Location: /index.php"); + exit; } } diff --git a/interface/web/dashboard/dashlets/databasequota.php b/interface/web/dashboard/dashlets/databasequota.php index 6439cdee1269e2c2d2e4db64eb8d3003a1669f81..d8c131702f043fff173249df1ce222c22a59f71f 100644 --- a/interface/web/dashboard/dashlets/databasequota.php +++ b/interface/web/dashboard/dashlets/databasequota.php @@ -7,6 +7,9 @@ class dashlet_databasequota { //* Loading Template $app->uses('tpl,quota_lib'); + if (!$app->auth->verify_module_permissions('sites')) { + return; + } $tpl = new tpl; $tpl->newTemplate("dashlets/templates/databasequota.htm"); diff --git a/interface/web/dashboard/dashlets/quota.php b/interface/web/dashboard/dashlets/quota.php index 6ff975b6235f368a14597ac72d5d461ff19d83f2..dfb82d5c242bbe6ad8699e97db26855e1d378829 100644 --- a/interface/web/dashboard/dashlets/quota.php +++ b/interface/web/dashboard/dashlets/quota.php @@ -7,6 +7,9 @@ class dashlet_quota { //* Loading Template $app->uses('tpl,quota_lib'); + if (!$app->auth->verify_module_permissions('sites')) { + return; + } $tpl = new tpl; $tpl->newTemplate("dashlets/templates/quota.htm");