From f68f9f06c4f2c427ee10c68b32eedf8d8f61f110 Mon Sep 17 00:00:00 2001 From: Herman van Rink <rink@initfour.nl> Date: Sun, 27 Nov 2022 22:26:12 +0100 Subject: [PATCH] Fix dashlets for admin. --- interface/web/dashboard/dashlets/databasequota.php | 4 ++-- interface/web/dashboard/dashlets/limits.php | 8 ++++++++ interface/web/dashboard/dashlets/mailquota.php | 4 ++-- interface/web/dashboard/dashlets/quota.php | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/interface/web/dashboard/dashlets/databasequota.php b/interface/web/dashboard/dashlets/databasequota.php index ca8a70dd31..641dfd7784 100644 --- a/interface/web/dashboard/dashlets/databasequota.php +++ b/interface/web/dashboard/dashlets/databasequota.php @@ -2,7 +2,7 @@ class dashlet_databasequota { - function show($limit_to_client_id = 0) { + function show($limit_to_client_id = null) { global $app; //* Loading Template @@ -23,7 +23,7 @@ class dashlet_databasequota { $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dashlet_databasequota.lng'; if(is_file($lng_file)) include $lng_file; $tpl->setVar($wb); - if ($limit_to_client_id == 0 || $_SESSION["s"]["user"]["typ"] != 'admin') { + if ($_SESSION["s"]["user"]["typ"] != 'admin') { $client_id = $_SESSION['s']['user']['client_id']; } else { $client_id = $limit_to_client_id; diff --git a/interface/web/dashboard/dashlets/limits.php b/interface/web/dashboard/dashlets/limits.php index d68015dd11..79ac2126c8 100644 --- a/interface/web/dashboard/dashlets/limits.php +++ b/interface/web/dashboard/dashlets/limits.php @@ -149,8 +149,10 @@ class dashlet_limits if ($limit_to_client_id == 0) { $client_id = $_SESSION['s']['user']['client_id']; + $user_is_admin = true; } else { $client_id = $limit_to_client_id; + $user_is_admin = false; } $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); @@ -161,6 +163,12 @@ class dashlet_limits foreach ($limits as $limit) { $field = $limit['field']; $value = $client[$field]; + if ($user_is_admin) { + $value = $wb['unlimited_txt']; + } else { + $value = $client[$field]; + } + if ($value != 0 || $value == $wb['unlimited_txt']) { $value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value; if (isset($limit['q_type']) && $limit['q_type'] != '') { diff --git a/interface/web/dashboard/dashlets/mailquota.php b/interface/web/dashboard/dashlets/mailquota.php index 784e6b1c87..b310cc1dcb 100644 --- a/interface/web/dashboard/dashlets/mailquota.php +++ b/interface/web/dashboard/dashlets/mailquota.php @@ -2,7 +2,7 @@ class dashlet_mailquota { - function show($limit_to_client_id = 0) { + function show($limit_to_client_id = null) { global $app; //* Loading Template @@ -16,7 +16,7 @@ class dashlet_mailquota { if(is_file($lng_file)) include $lng_file; $tpl->setVar($wb); - if ($limit_to_client_id == 0 || $_SESSION["s"]["user"]["typ"] != 'admin') { + if ($_SESSION["s"]["user"]["typ"] != 'admin') { $client_id = $_SESSION['s']['user']['client_id']; } else { $client_id = $limit_to_client_id; diff --git a/interface/web/dashboard/dashlets/quota.php b/interface/web/dashboard/dashlets/quota.php index 6380e18d87..3225bd304f 100644 --- a/interface/web/dashboard/dashlets/quota.php +++ b/interface/web/dashboard/dashlets/quota.php @@ -2,7 +2,7 @@ class dashlet_quota { - function show($limit_to_client_id = 0) { + function show($limit_to_client_id = null) { global $app; //* Loading Template @@ -24,7 +24,7 @@ class dashlet_quota { if(is_file($lng_file)) include $lng_file; $tpl->setVar($wb); - if ($limit_to_client_id == 0 || $_SESSION["s"]["user"]["typ"] != 'admin') { + if ($_SESSION["s"]["user"]["typ"] != 'admin') { $client_id = $_SESSION['s']['user']['client_id']; } else { $client_id = $limit_to_client_id; -- GitLab