Skip to content

Commit 3ce8e22

Browse files
committed
Show use mail quota on mail user edit form
1 parent dab6683 commit 3ce8e22

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

interface/lib/classes/quota_lib.inc.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public function get_ftptrafficquota_data($clientid = null, $lastdays = 0) {
218218
return $traffic_data;
219219
}
220220

221-
public function get_mailquota_data($clientid = null, $readable = true) {
221+
public function get_mailquota_data($clientid = null, $readable = true, $email = null) {
222222
global $app;
223223

224224
$tmp_rec = $app->db->queryAllRecords("SELECT data from monitor_data WHERE type = 'email_quota' ORDER BY created DESC");
@@ -236,6 +236,9 @@ public function get_mailquota_data($clientid = null, $readable = true) {
236236
}
237237
//print_r($monitor_data);
238238

239+
if ($email) {
240+
return $monitor_data[$email];
241+
}
239242
// select all email accounts or email accounts belonging to client
240243
$emails = $app->db->queryAllRecords("SELECT * FROM mail_user".(($clientid != null)? " WHERE sys_groupid = (SELECT default_group FROM sys_user WHERE client_id=?)" : '') . " ORDER BY email", $clientid);
241244

interface/web/mail/lib/lang/en_mail_user.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,5 @@ $wb['purge_junk_days_txt'] = 'Purge Junk automatically after X days';
7676
$wb['tooltip_purge_junk_days_txt'] = '0 = disabled';
7777
$wb['imap_prefix_txt'] = 'IMAP prefix';
7878
$wb['tooltip_imap_prefix_txt'] = 'In most cases this should be left empty. To allow seamless per-mailbox migration of legacy systems you can specify a prefix followed by the hierarchy separator. e.g.: \'INBOX.\'';
79+
$wb['used_txt'] = 'Used';
7980
?>

interface/web/mail/lib/lang/nl_mail_user.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,5 @@ $wb['purge_junk_days_txt'] = 'Purge Junk automatically after X days';
7676
$wb['tooltip_purge_junk_days_txt'] = '0 = disabled';
7777
$wb['imap_prefix_txt'] = 'IMAP prefix';
7878
$wb['tooltip_imap_prefix_txt'] = 'In most cases this should be left empty. To allow seamless per-mailbox migration of legacy systems you can specify a prefix followed by the hierarchy separator. e.g.: \'INBOX.\'';
79+
$wb['used_txt'] = 'Gebruikt';
7980
?>

interface/web/mail/mail_user_edit.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ function onShowEnd() {
143143
$global_config = $app->getconf->get_global_config();
144144
$app->tpl->setVar('show_delete_on_forms', $global_config['misc']['show_delete_on_forms']);
145145

146+
# Fetch current disk usage.
147+
$app->uses('quota_lib');
148+
$clientid = $app->db->queryOneRecord('SELECT `client_id` FROM `sys_group` WHERE `groupid` = ?', $this->dataRecord['sys_groupid']);
149+
$monitor_data = $app->quota_lib->get_mailquota_data($clientid, FALSE, $this->dataRecord['email']);
150+
$app->tpl->setVar("used_percentage", round($monitor_data['used'] * 100 / $this->dataRecord['quota']));
151+
$app->tpl->setVar('used', $app->functions->formatBytes($monitor_data['used'], 0));
152+
146153
parent::onShowEnd();
147154
}
148155

interface/web/mail/templates/mail_user_mailbox_edit.htm

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,16 @@
5353
</div>
5454
<div class="form-group">
5555
<label for="quota" class="col-sm-3 control-label">{tmpl_var name='quota_txt'}</label>
56-
<div class="col-sm-9"><div class="input-group"><input type="text" name="quota" id="quota" value="{tmpl_var name='quota'}" class="form-control" aria-describedby="quota-desc" /><span class="input-group-addon" id="quota-desc">MB</span></div></div>
56+
<div class="col-sm-9"><div class="input-group"><input type="text" name="quota" id="quota" value="{tmpl_var name='quota'}" class="form-control" aria-describedby="quota-desc" /><span class="input-group-addon" id="quota-desc">MB</span></div>
57+
58+
{tmpl_if name="quota" op="!=" value="0"}
59+
<div class='progress'>
60+
<div class='progress-bar-striped progress-bar progress-bar-{tmpl_if name="used_percentage" op="<" value="50"}success{tmpl_elseif name="used_percentage" op="<" value="75"}warning{tmpl_else}danger{/tmpl_if}' role='progressbar' aria-valuemin='0' aria-valuemax='100' aria-valuenow='{tmpl_var name="used_percentage"}' style='width:{tmpl_var name="used_percentage"}%'><span>{tmpl_var name='used_txt'}: {tmpl_var name='used'} / {tmpl_var name="used_percentage"}%</span>
61+
<span class='sr-only'>{tmpl_var name='used'} {tmpl_var name='of_txt'} {tmpl_var name='quota'}</span>
62+
</div>
63+
</div>
64+
{tmpl_else}{tmpl_var name='used_txt'}: {tmpl_var name='used'}{/tmpl_if}
65+
</div>
5766
</div>
5867
<div class="form-group">
5968
<label for="name" class="col-sm-3 control-label">{tmpl_var name='cc_txt'}</label>

0 commit comments

Comments
 (0)