forked from extern/egroupware
* Mail: Implement quota limit warning dialog
This commit is contained in:
parent
4e88e33e5a
commit
2b6da19330
@ -2453,44 +2453,46 @@ $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 $_usage int
|
* @param int $_usage
|
||||||
* @param $_limit int
|
* @param int $_limit
|
||||||
* @return array - info used for quota array(class=>string,text=>string,$percent=>string)
|
* @return array returns an array of info used for quota
|
||||||
|
* array(
|
||||||
|
* class => string,
|
||||||
|
* text => string,
|
||||||
|
* $percent=> string
|
||||||
|
* )
|
||||||
*/
|
*/
|
||||||
function quotaDisplay($_usage, $_limit)
|
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);
|
||||||
|
|
||||||
if($_limit == 0) {
|
if ($_limit > 0)
|
||||||
$quotaPercent=100;
|
{
|
||||||
} else {
|
$text = $usage .'/'.$limit;
|
||||||
$quotaPercent=round(($_usage*100)/$_limit);
|
switch ($percent)
|
||||||
|
{
|
||||||
|
case 90:
|
||||||
|
$class ='mail-index_QuotaRed';
|
||||||
|
break;
|
||||||
|
case 80:
|
||||||
|
$class ='mail-index_QuotaYellow';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$class ='mail-index_QuotaGreen';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
$quotaLimit=Mail::show_readable_size($_limit*1024);
|
{
|
||||||
$quotaUsage=Mail::show_readable_size($_usage*1024);
|
$text = $usage;
|
||||||
|
$class ='mail-index_QuotaGreen';
|
||||||
|
|
||||||
if($quotaPercent > 90 && $_limit>0) {
|
|
||||||
$quotaBG='mail-index_QuotaRed';
|
|
||||||
} elseif($quotaPercent > 80 && $_limit>0) {
|
|
||||||
$quotaBG='mail-index_QuotaYellow';
|
|
||||||
} else {
|
|
||||||
$quotaBG='mail-index_QuotaGreen';
|
|
||||||
}
|
}
|
||||||
|
return array (
|
||||||
if($_limit > 0) {
|
'class' => $class,
|
||||||
$quotaText = $quotaUsage .'/'.$quotaLimit;
|
'text' => lang('Quota: %1',$text),
|
||||||
} else {
|
'percent' => $percent
|
||||||
$quotaText = $quotaUsage;
|
);
|
||||||
}
|
|
||||||
|
|
||||||
if($quotaPercent > 50) {
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
$quota['class'] = $quotaBG;
|
|
||||||
$quota['text'] = lang('Quota: %1',$quotaText);
|
|
||||||
$quota['percent'] = (string)round(($_usage*100)/$_limit);
|
|
||||||
return $quota;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -4449,13 +4451,15 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ajax_refreshQuotaDisplay - its called via json, so the function must start with ajax (or the class-name must contain ajax)
|
* This function asks quota from IMAP server and makes the
|
||||||
|
* result as JSON response to send it to mail_sendQuotaDisplay
|
||||||
|
* function in client side.
|
||||||
|
*
|
||||||
|
* @param string $icServerID = null
|
||||||
*
|
*
|
||||||
* @return nothing
|
|
||||||
*/
|
*/
|
||||||
function ajax_refreshQuotaDisplay($icServerID=null)
|
function ajax_refreshQuotaDisplay($icServerID=null)
|
||||||
{
|
{
|
||||||
//error_log(__METHOD__.__LINE__.array2string($icServerID));
|
|
||||||
Api\Translation::add_app('mail');
|
Api\Translation::add_app('mail');
|
||||||
if (is_null($icServerID)) $icServerID = $this->mail_bo->profileID;
|
if (is_null($icServerID)) $icServerID = $this->mail_bo->profileID;
|
||||||
$rememberServerID = $this->mail_bo->profileID;
|
$rememberServerID = $this->mail_bo->profileID;
|
||||||
@ -4463,7 +4467,6 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
|
|||||||
{
|
{
|
||||||
if ($icServerID && $icServerID != $this->mail_bo->profileID)
|
if ($icServerID && $icServerID != $this->mail_bo->profileID)
|
||||||
{
|
{
|
||||||
//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
|
|
||||||
$this->changeProfile($icServerID);
|
$this->changeProfile($icServerID);
|
||||||
}
|
}
|
||||||
$quota = $this->mail_bo->getQuotaRoot();
|
$quota = $this->mail_bo->getQuotaRoot();
|
||||||
@ -4475,23 +4478,28 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
|
|||||||
|
|
||||||
if($quota !== false && $quota['limit'] != 'NOT SET') {
|
if($quota !== false && $quota['limit'] != 'NOT SET') {
|
||||||
$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
|
$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
|
||||||
$content['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
|
$content = array (
|
||||||
$content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent'];
|
'quota' => $quotainfo['text'],
|
||||||
$content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
|
'quotainpercent' => '99',//(string)$quotainfo['percent'],
|
||||||
$content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
|
'quotaclass' => $quotainfo['class'],
|
||||||
} else {
|
'quotanotsupported' => "",
|
||||||
$content['quota'] = $sel_options[self::$nm_index]['quota'] = lang("Quota not provided by server");
|
'profileid' => $icServerID
|
||||||
$content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = "mail_DisplayNone";
|
);
|
||||||
$content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone";
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$content = array (
|
||||||
|
'quota' => lang("Quota not provided by server"),
|
||||||
|
'quotaclass' => "mail_DisplayNone",
|
||||||
|
'quotanotsupported' => "mail_DisplayNone"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if ($rememberServerID != $this->mail_bo->profileID)
|
if ($rememberServerID != $this->mail_bo->profileID)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//error_log(__METHOD__.__LINE__.' change Profile back to where we came from ->'.$rememberServerID);
|
|
||||||
$this->changeProfile($rememberServerID);
|
$this->changeProfile($rememberServerID);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
//error_log(__METHOD__.__LINE__." ".$e->getMessage());
|
|
||||||
unset($e);
|
unset($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1232,6 +1232,28 @@ 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)
|
||||||
|
{
|
||||||
|
var self = this;
|
||||||
|
var buttons = [
|
||||||
|
{text: this.egw.lang("Empty Trash and Junk"), id: "cleanup", class: "ui-priority-primary", default: true, image:"delete"},
|
||||||
|
{text: this.egw.lang("Cancel"), id:"cancel"}
|
||||||
|
];
|
||||||
|
var server = [{iface:{id: _data.data.profileid+'::'}}];
|
||||||
|
et2_dialog.show_dialog(function(_button_id) {
|
||||||
|
if (_button_id == "cleanup")
|
||||||
|
{
|
||||||
|
self.mail_emptySpam (null, server);
|
||||||
|
self.mail_emptyTrash (null, server);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
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"),
|
||||||
|
'', buttons, et2_dialog.WARNING_MESSAGE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user