Warn user about mail quota limit if it's 99% full and freespace is less than 50 mb

This commit is contained in:
Hadi Nategh 2017-03-13 10:49:32 +01:00
parent cc6f81a15e
commit 75b947b6c0
2 changed files with 15 additions and 12 deletions

View File

@ -2330,20 +2330,21 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
/** /**
* gather Info on how to display the quota info * gather Info on how to display the quota info
* *
* @param int $_usage * @param int $_usage amount of usage in Kb
* @param int $_limit * @param int $_limit amount of limit in Kb
* @return array returns an array of info used for quota * @return array returns an array of info used for quota
* array( * array(
* class => string, * class => string,
* text => string, * text => string,
* $percent=> string * percent => string,
* freespace => integer
* ) * )
*/ */
function quotaDisplay($_usage, $_limit) function quotaDisplay($_usage, $_limit)
{ {
$percent = $_limit == 0 ? 100 : round(($_usage*100)/$_limit); $percent = $_limit == 0 ? 100 : round(($_usage*100)/$_limit);
$limit=Mail::show_readable_size($_limit*1024); $limit = Mail::show_readable_size($_limit*1024);
$usage=Mail::show_readable_size($_usage*1024); $usage = Mail::show_readable_size($_usage*1024);
if ($_limit > 0) if ($_limit > 0)
{ {
@ -2368,7 +2369,8 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
return array ( return array (
'class' => $class, 'class' => $class,
'text' => lang('Quota: %1',$text), 'text' => lang('Quota: %1',$text),
'percent' => $percent 'percent' => $percent,
'freespace' => $_limit*1024 - $_usage*1024
); );
} }
@ -4333,7 +4335,8 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
'quotainpercent' => (string)$quotainfo['percent'], 'quotainpercent' => (string)$quotainfo['percent'],
'quotaclass' => $quotainfo['class'], 'quotaclass' => $quotainfo['class'],
'quotanotsupported' => "", 'quotanotsupported' => "",
'profileid' => $icServerID 'profileid' => $icServerID,
'quotawarning' => ($quotainfo['freespace']/pow(1024, 2)) < 50 && $quotainfo['percent'] >= 99 ? true : false
); );
} }
else else
@ -5094,4 +5097,4 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
$response->data($res); $response->data($res);
} }
} }
} }

View File

@ -1139,7 +1139,7 @@ app.classes.mail = AppJS.extend(
quotabox.set_class(_data.data.quotaclass); quotabox.set_class(_data.data.quotaclass);
quotabox.set_value(_data.data.quotainpercent); quotabox.set_value(_data.data.quotainpercent);
quotabox.set_label(_data.data.quota); quotabox.set_label(_data.data.quota);
if (parseInt(_data.data.quotainpercent) >= 99) if (_data.data.quotawarning)
{ {
var self = this; var self = this;
var buttons = [ var buttons = [
@ -1155,7 +1155,7 @@ app.classes.mail = AppJS.extend(
} }
return; 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"+ "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), "If that didn't help, please ask administrator for more quota.", _data.data.quotainpercent),
this.egw.lang("Mail cleanup"), this.egw.lang("Mail cleanup"),