Skip to content

Commit 2732197

Browse files
author
Till Brehm
committed
Merge branch 'Patch-2-stable' into 'stable-3.1'
Add information about assigned and total quota of web, mail, database to Account limits See merge request ispconfig/ispconfig3!726
2 parents 541b240 + 8fb9f4d commit 2732197

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

interface/web/dashboard/dashlets/limits.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ function show() {
88
$limits = array();
99

1010
/* Limits to be shown*/
11+
12+
$limits[] = array('field' => 'limit_mailquota',
13+
'db_table' => 'mail_user',
14+
'db_where' => 'quota > 0', /* Count only posive value of quota, negative value -1 is unlimited */
15+
'q_type' => 'quota');
1116

1217
$limits[] = array('field' => 'limit_maildomain',
1318
'db_table' => 'mail_domain',
@@ -61,6 +66,11 @@ function show() {
6166
'db_table' => 'spamfilter_policy',
6267
'db_where' => "");
6368

69+
$limits[] = array('field' => 'limit_web_quota',
70+
'db_table' => 'web_domain',
71+
'db_where' => 'hd_quota > 0', /* Count only posive value of quota, negative value -1 is unlimited */
72+
'q_type' => 'hd_quota');
73+
6474
$limits[] = array('field' => 'limit_web_domain',
6575
'db_table' => 'web_domain',
6676
'db_where' => "type = 'vhost'");
@@ -93,6 +103,11 @@ function show() {
93103
'db_table' => 'dns_rr',
94104
'db_where' => "");
95105

106+
$limits[] = array('field' => 'limit_database_quota',
107+
'db_table' => 'web_database',
108+
'db_where' => 'database_quota > 0', /* Count only posive value of quota, negative value -1 is unlimited */
109+
'q_type' => 'database_quota');
110+
96111
$limits[] = array('field' => 'limit_database',
97112
'db_table' => 'web_database',
98113
'db_where' => "");
@@ -143,7 +158,11 @@ function show() {
143158
}
144159
if($value != 0 || $value == $wb['unlimited_txt']) {
145160
$value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value;
146-
$usage = $this->_get_limit_usage($limit);
161+
if($limit['q_type']!=''){
162+
$usage = $this->_get_assigned_quota($limit) . " MB";
163+
$value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value . " MB";
164+
}
165+
else $usage = $this->_get_limit_usage($limit);
147166
$percentage = ($value == '-1' || $value == 0 ? 0 : round(100 * $usage / $value));
148167
$rows[] = array('field' => $field,
149168
'field_txt' => $wb[$field.'_txt'],
@@ -172,6 +191,19 @@ function _get_limit_usage($limit) {
172191
return $rec['number'];
173192

174193
}
194+
195+
function _get_assigned_quota($limit) {
196+
global $app;
197+
198+
$sql = "SELECT sum(??) as number FROM ?? WHERE ";
199+
if($limit['db_where'] != '') $sql .= $limit['db_where']." AND ";
200+
$sql .= $app->tform->getAuthSQL('r');
201+
$rec = $app->db->queryOneRecord($sql, $limit['q_type'], $limit['db_table']);
202+
if($limit['db_table']=='mail_user') $quotaMB = $rec['number'] / 1048576; // Mail quota is in bytes, must be converted to MB
203+
else $quotaMB = $rec['number'];
204+
return $quotaMB;
205+
206+
}
175207

176208
}
177209

interface/web/dashboard/lib/lang/en_dashlet_limits.lng

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ $wb["limit_webdav_user_txt"] = 'Number of Webdav users';
2828
$wb["limit_client_txt"] = 'Number of Clients';
2929
$wb["limit_database_txt"] = 'Number of Databases';
3030
$wb['limit_domain_txt'] = 'Number of Domains';
31+
$wb['limit_mailquota_txt'] = 'Assigned mailbox quota';
32+
$wb['limit_web_quota_txt'] = 'Assigned web quota';
33+
$wb['limit_database_quota_txt'] = 'Assigned database quota';
3134
?>

0 commit comments

Comments
 (0)