Commit 27321975 authored by Till Brehm's avatar Till Brehm

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
parents 541b240e 8fb9f4d8
......@@ -8,6 +8,11 @@ class dashlet_limits {
$limits = array();
/* Limits to be shown*/
$limits[] = array('field' => 'limit_mailquota',
'db_table' => 'mail_user',
'db_where' => 'quota > 0', /* Count only posive value of quota, negative value -1 is unlimited */
'q_type' => 'quota');
$limits[] = array('field' => 'limit_maildomain',
'db_table' => 'mail_domain',
......@@ -61,6 +66,11 @@ class dashlet_limits {
'db_table' => 'spamfilter_policy',
'db_where' => "");
$limits[] = array('field' => 'limit_web_quota',
'db_table' => 'web_domain',
'db_where' => 'hd_quota > 0', /* Count only posive value of quota, negative value -1 is unlimited */
'q_type' => 'hd_quota');
$limits[] = array('field' => 'limit_web_domain',
'db_table' => 'web_domain',
'db_where' => "type = 'vhost'");
......@@ -93,6 +103,11 @@ class dashlet_limits {
'db_table' => 'dns_rr',
'db_where' => "");
$limits[] = array('field' => 'limit_database_quota',
'db_table' => 'web_database',
'db_where' => 'database_quota > 0', /* Count only posive value of quota, negative value -1 is unlimited */
'q_type' => 'database_quota');
$limits[] = array('field' => 'limit_database',
'db_table' => 'web_database',
'db_where' => "");
......@@ -143,7 +158,11 @@ class dashlet_limits {
}
if($value != 0 || $value == $wb['unlimited_txt']) {
$value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value;
$usage = $this->_get_limit_usage($limit);
if($limit['q_type']!=''){
$usage = $this->_get_assigned_quota($limit) . " MB";
$value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value . " MB";
}
else $usage = $this->_get_limit_usage($limit);
$percentage = ($value == '-1' || $value == 0 ? 0 : round(100 * $usage / $value));
$rows[] = array('field' => $field,
'field_txt' => $wb[$field.'_txt'],
......@@ -172,6 +191,19 @@ class dashlet_limits {
return $rec['number'];
}
function _get_assigned_quota($limit) {
global $app;
$sql = "SELECT sum(??) as number FROM ?? WHERE ";
if($limit['db_where'] != '') $sql .= $limit['db_where']." AND ";
$sql .= $app->tform->getAuthSQL('r');
$rec = $app->db->queryOneRecord($sql, $limit['q_type'], $limit['db_table']);
if($limit['db_table']=='mail_user') $quotaMB = $rec['number'] / 1048576; // Mail quota is in bytes, must be converted to MB
else $quotaMB = $rec['number'];
return $quotaMB;
}
}
......
......@@ -28,4 +28,7 @@ $wb["limit_webdav_user_txt"] = 'Number of Webdav users';
$wb["limit_client_txt"] = 'Number of Clients';
$wb["limit_database_txt"] = 'Number of Databases';
$wb['limit_domain_txt'] = 'Number of Domains';
$wb['limit_mailquota_txt'] = 'Assigned mailbox quota';
$wb['limit_web_quota_txt'] = 'Assigned web quota';
$wb['limit_database_quota_txt'] = 'Assigned database quota';
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment