Skip to content

Commit 0113a3f

Browse files
author
Marius Burkard
committed
Merge branch 'patch-skip-irrelevant-dashlets' into 'stable-3.1'
Show harddisk and database quota dashlet only when user has access See merge request ispconfig/ispconfig3!964
2 parents 53c84aa + cf593c7 commit 0113a3f

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

interface/lib/classes/auth.inc.php

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,18 @@ public function remove_group_from_user($userid, $groupid) {
141141
}
142142
}
143143

144-
public function check_module_permissions($module) {
144+
145+
/**
146+
* Check that the user has access to the given module.
147+
*
148+
* @return boolean
149+
*/
150+
public function verify_module_permissions($module) {
145151
// Check if the current user has the permissions to access this module
146152
$module = trim(preg_replace('@\s+@', '', $module));
147153
$user_modules = explode(',',$_SESSION["s"]["user"]["modules"]);
154+
$can_use_module = false;
148155
if(strpos($module, ',') !== false){
149-
$can_use_module = false;
150156
$tmp_modules = explode(',', $module);
151157
if(is_array($tmp_modules) && !empty($tmp_modules)){
152158
foreach($tmp_modules as $tmp_module){
@@ -158,17 +164,21 @@ public function check_module_permissions($module) {
158164
}
159165
}
160166
}
161-
if(!$can_use_module){
162-
// echo "LOGIN_REDIRECT:/index.php";
163-
header("Location: /index.php");
164-
exit;
165-
}
166-
} else {
167-
if(!in_array($module,$user_modules)) {
168-
// echo "LOGIN_REDIRECT:/index.php";
169-
header("Location: /index.php");
170-
exit;
171-
}
167+
}
168+
elseif(in_array($module,$user_modules)) {
169+
$can_use_module = true;
170+
}
171+
return $can_use_module;
172+
}
173+
174+
/**
175+
* Check that the user has access to the given module, redirect and exit on failure.
176+
*/
177+
public function check_module_permissions($module) {
178+
if(!$this->verify_module_permissions($module)) {
179+
// echo "LOGIN_REDIRECT:/index.php";
180+
header("Location: /index.php");
181+
exit;
172182
}
173183
}
174184

interface/web/dashboard/dashlets/databasequota.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ function show() {
77

88
//* Loading Template
99
$app->uses('tpl,quota_lib');
10+
if (!$app->auth->verify_module_permissions('sites')) {
11+
return;
12+
}
1013

1114
$tpl = new tpl;
1215
$tpl->newTemplate("dashlets/templates/databasequota.htm");

interface/web/dashboard/dashlets/quota.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ function show() {
77

88
//* Loading Template
99
$app->uses('tpl,quota_lib');
10+
if (!$app->auth->verify_module_permissions('sites')) {
11+
return;
12+
}
1013

1114
$tpl = new tpl;
1215
$tpl->newTemplate("dashlets/templates/quota.htm");

0 commit comments

Comments
 (0)