Skip to content

Commit a532654

Browse files
author
Till Brehm
committed
Merge branch '6528-account-limit-incorrectly-informed-in-dashboard-ispconfig-3-2-10' into 'develop'
Resolve "Account limit incorrectly informed in dashboard - ISPConfig 3.2.10" Closes #6528 See merge request ispconfig/ispconfig3!1771
2 parents 45ac1c9 + 224a596 commit a532654

File tree

4 files changed

+31
-64
lines changed

4 files changed

+31
-64
lines changed

interface/web/dashboard/dashlets/databasequota.php

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class dashlet_databasequota {
44

5-
function show($limit_to_client_id = null) {
5+
function show() {
66
global $app;
77

88
//* Loading Template
@@ -23,30 +23,19 @@ function show($limit_to_client_id = null) {
2323
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dashlet_databasequota.lng';
2424
if(is_file($lng_file)) include $lng_file;
2525
$tpl->setVar($wb);
26-
if ($_SESSION["s"]["user"]["typ"] != 'admin') {
27-
$client_id = $_SESSION['s']['user']['client_id'];
28-
} else {
29-
$client_id = $limit_to_client_id;
30-
}
3126

32-
$databases = $app->quota_lib->get_databasequota_data($client_id);
27+
$databases = $app->quota_lib->get_databasequota_data( ($_SESSION["s"]["user"]["typ"] != 'admin') ? $_SESSION['s']['user']['client_id'] : null);
3328
//print_r($databases);
3429

3530
$has_databasequota = false;
36-
$total_used = 0;
3731
if(is_array($databases) && !empty($databases)){
38-
foreach ($databases as &$db) {
39-
$total_used += $db['used_raw'] * 1000 * 1000;
40-
}
4132
$databases = $app->functions->htmlentities($databases);
4233
$tpl->setloop('databasequota', $databases);
4334
$has_databasequota = isset($databases[0]['used']);
44-
45-
$tpl->setVar('has_databasequota', $has_databasequota);
46-
$tpl->setVar('total_used', $app->functions->formatBytes($total_used, 0));
47-
48-
return $tpl->grab();
4935
}
36+
$tpl->setVar('has_databasequota', $has_databasequota);
37+
38+
return $tpl->grab();
5039
}
5140

5241
}

interface/web/dashboard/dashlets/limits.php

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class dashlet_limits
44
{
5-
public function show($limit_to_client_id = 0)
5+
public function show()
66
{
77
global $app, $conf;
88

@@ -147,35 +147,33 @@ public function show($limit_to_client_id = 0)
147147
}
148148
$tpl->setVar($wb);
149149

150-
if ($limit_to_client_id == 0) {
151-
$client_id = $_SESSION['s']['user']['client_id'];
152-
$user_is_admin = true;
150+
if ($app->auth->is_admin()) {
151+
$user_is_admin = true;
153152
} else {
154-
$client_id = $limit_to_client_id;
155-
$user_is_admin = false;
153+
$user_is_admin = false;
156154
}
155+
$tpl->setVar('is_admin', $user_is_admin);
157156

158-
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
159-
$client = $app->db->queryOneRecord("SELECT * FROM client WHERE client_id = ?", $client_id);
160-
157+
if ($user_is_admin == false) {
158+
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
159+
$client = $app->db->queryOneRecord("SELECT * FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
160+
}
161161

162162
$rows = array();
163163
foreach ($limits as $limit) {
164164
$field = $limit['field'];
165-
$value = $client[$field];
166165
if ($user_is_admin) {
167166
$value = $wb['unlimited_txt'];
168167
} else {
169168
$value = $client[$field];
170169
}
171-
172170
if ($value != 0 || $value == $wb['unlimited_txt']) {
173171
$value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value;
174172
if (isset($limit['q_type']) && $limit['q_type'] != '') {
175-
$usage = $this->_get_assigned_quota($limit, $client_id) . " MB";
173+
$usage = $this->_get_assigned_quota($limit) . " MB";
176174
$value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value . " MB";
177175
} else {
178-
$usage = $this->_get_limit_usage($limit, $client_id);
176+
$usage = $this->_get_limit_usage($limit);
179177
}
180178
$percentage = ($value == '-1' || intval($value) == 0 || trim($value) == '' ? -1 : round(100 * (int)$usage / (int)$value));
181179
$progressbar = $percentage > 100 ? 100 : $percentage;
@@ -197,31 +195,28 @@ public function show($limit_to_client_id = 0)
197195
return $tpl->grab();
198196
}
199197

200-
public function _get_limit_usage($limit, $limit_to_client_id)
198+
public function _get_limit_usage($limit)
201199
{
202200
global $app;
203201

204202
$sql = "SELECT count(sys_userid) as number FROM ?? WHERE ";
205203
if ($limit['db_where'] != '') {
206204
$sql .= $limit['db_where']." AND ";
207205
}
208-
$sql .= $app->tform->getAuthSQL('r', '', $limit_to_client_id);
209-
// TEST to show reseller data.
210-
//$sql .= $app->tform->getAuthSQL('r', '', 0, '3,28,39');
211-
//echo $sql;
206+
$sql .= $app->tform->getAuthSQL('r');
212207
$rec = $app->db->queryOneRecord($sql, $limit['db_table']);
213208
return $rec['number'];
214209
}
215210

216-
public function _get_assigned_quota($limit, $limit_to_client_id)
211+
public function _get_assigned_quota($limit)
217212
{
218213
global $app;
219214

220215
$sql = "SELECT sum(??) as number FROM ?? WHERE ";
221216
if ($limit['db_where'] != '') {
222217
$sql .= $limit['db_where']." AND ";
223218
}
224-
$sql .= $app->tform->getAuthSQL('r', '', $limit_to_client_id);
219+
$sql .= $app->tform->getAuthSQL('r');
225220
$rec = $app->db->queryOneRecord($sql, $limit['q_type'], $limit['db_table']);
226221
if ($limit['db_table']=='mail_user') {
227222
$quotaMB = $rec['number'] / 1048576;

interface/web/dashboard/dashlets/mailquota.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class dashlet_mailquota {
44

5-
function show($limit_to_client_id = null) {
5+
function show() {
66
global $app;
77

88
//* Loading Template
@@ -16,33 +16,23 @@ function show($limit_to_client_id = null) {
1616
if(is_file($lng_file)) include $lng_file;
1717
$tpl->setVar($wb);
1818

19-
if ($_SESSION["s"]["user"]["typ"] != 'admin') {
20-
$client_id = $_SESSION['s']['user']['client_id'];
21-
} else {
22-
$client_id = $limit_to_client_id;
23-
}
24-
25-
$emails = $app->quota_lib->get_mailquota_data($client_id);
19+
$emails = $app->quota_lib->get_mailquota_data( ($_SESSION["s"]["user"]["typ"] != 'admin') ? $_SESSION['s']['user']['client_id'] : null);
2620
//print_r($emails);
2721

2822
$has_mailquota = false;
29-
$total_used = 0;
3023
if(is_array($emails) && !empty($emails)){
3124
foreach($emails as &$email) {
3225
$email['email'] = $app->functions->idn_decode($email['email']);
33-
$total_used += $email['used_raw'];
3426
}
3527
unset($email);
3628
// email username is quoted in quota.lib already, so no htmlentities here to prevent double encoding
3729
//$emails = $app->functions->htmlentities($emails);
3830
$tpl->setloop('mailquota', $emails);
3931
$has_mailquota = isset($emails[0]['used']);
40-
41-
$tpl->setVar('has_mailquota', $has_mailquota);
42-
$tpl->setVar('total_used', $app->functions->formatBytes($total_used, 0));
43-
44-
return $tpl->grab();
4532
}
33+
$tpl->setVar('has_mailquota', $has_mailquota);
34+
35+
return $tpl->grab();
4636
}
4737

4838
}

interface/web/dashboard/dashlets/quota.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class dashlet_quota {
44

5-
function show($limit_to_client_id = null) {
5+
function show() {
66
global $app;
77

88
//* Loading Template
@@ -24,33 +24,26 @@ function show($limit_to_client_id = null) {
2424
if(is_file($lng_file)) include $lng_file;
2525
$tpl->setVar($wb);
2626

27-
if ($_SESSION["s"]["user"]["typ"] != 'admin') {
28-
$client_id = $_SESSION['s']['user']['client_id'];
29-
} else {
30-
$client_id = $limit_to_client_id;
31-
}
32-
33-
$sites = $app->quota_lib->get_quota_data($client_id);
27+
$sites = $app->quota_lib->get_quota_data( ($_SESSION["s"]["user"]["typ"] != 'admin') ? $_SESSION['s']['user']['client_id'] : null);
3428
//print_r($sites);
3529

3630
$has_quota = false;
3731
if(is_array($sites) && !empty($sites)){
3832
foreach($sites as &$site) {
3933
$site['domain'] = $app->functions->idn_decode($site['domain']);
4034
$site['progressbar'] = $site['hd_quota'];
41-
$total_used += $site['used_raw'] * 1000;
4235
}
4336
unset($site);
4437

4538
$sites = $app->functions->htmlentities($sites);
4639
$tpl->setloop('quota', $sites);
4740
$has_quota = isset($sites[0]['used']);
41+
}
42+
$tpl->setVar('has_quota', $has_quota);
43+
44+
return $tpl->grab();
4845

49-
$tpl->setVar('has_quota', $has_quota);
50-
$tpl->setVar('total_used', $app->functions->formatBytes($total_used, 0));
5146

52-
return $tpl->grab();
53-
}
5447
}
5548

5649
}

0 commit comments

Comments
 (0)