From aaf34925882216060fd5e60a3ebe52b810a33c1e Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Mon, 13 Mar 2017 10:49:32 +0100 Subject: [PATCH] Warn user about mail quota limit if it's 99% full and freespace is less than 50 mb --- mail/inc/class.mail_ui.inc.php | 23 +++++++++++++---------- mail/js/app.js | 4 ++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index fe77c49608..e3c505086f 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -2453,20 +2453,21 @@ $filter['before']= date("d-M-Y", $cutoffdate2); /** * gather Info on how to display the quota info * - * @param int $_usage - * @param int $_limit + * @param int $_usage amount of usage in Kb + * @param int $_limit amount of limit in Kb * @return array returns an array of info used for quota * array( - * class => string, - * text => string, - * $percent=> string + * class => string, + * text => string, + * percent => string, + * freespace => integer * ) */ function quotaDisplay($_usage, $_limit) { $percent = $_limit == 0 ? 100 : round(($_usage*100)/$_limit); - $limit=Mail::show_readable_size($_limit*1024); - $usage=Mail::show_readable_size($_usage*1024); + $limit = Mail::show_readable_size($_limit*1024); + $usage = Mail::show_readable_size($_usage*1024); if ($_limit > 0) { @@ -2491,7 +2492,8 @@ $filter['before']= date("d-M-Y", $cutoffdate2); return array ( 'class' => $class, 'text' => lang('Quota: %1',$text), - 'percent' => $percent + 'percent' => $percent, + 'freespace' => $_limit*1024 - $_usage*1024 ); } @@ -4483,7 +4485,8 @@ $filter['before']= date("d-M-Y", $cutoffdate2); 'quotainpercent' => (string)$quotainfo['percent'], 'quotaclass' => $quotainfo['class'], 'quotanotsupported' => "", - 'profileid' => $icServerID + 'profileid' => $icServerID, + 'quotawarning' => ($quotainfo['freespace']/pow(1024, 2)) < 50 && $quotainfo['percent'] >= 99 ? true : false ); } else @@ -5240,4 +5243,4 @@ $filter['before']= date("d-M-Y", $cutoffdate2); $response->data($res); } } -} +} \ No newline at end of file diff --git a/mail/js/app.js b/mail/js/app.js index eebfc8bec0..42510e069c 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -1232,7 +1232,7 @@ app.classes.mail = AppJS.extend( quotabox.set_class(_data.data.quotaclass); quotabox.set_value(_data.data.quotainpercent); quotabox.set_label(_data.data.quota); - if (parseInt(_data.data.quotainpercent) >= 99) + if (_data.data.quotawarning) { var self = this; var buttons = [ @@ -1248,7 +1248,7 @@ app.classes.mail = AppJS.extend( } return; }, - this.egw.lang("Your mail quota is %%1 full, you may not be able to send/receive further emails.\r\n"+ + this.egw.lang("Your mail quota is %1% full, you may not be able to send/receive further emails.\r\n"+ "Although cleaning up emails in trash or junk folder might help you to get some free space back.\r\n"+ "If that didn't help, please ask administrator for more quota.", _data.data.quotainpercent), this.egw.lang("Mail cleanup"),