summaryrefslogtreecommitdiff
path: root/program/steps/mail/func.inc
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2008-04-11 16:53:59 +0000
committeralecpl <alec@alec.pl>2008-04-11 16:53:59 +0000
commit6d2714b3b3660f8a4efbb9c53e00b76245c2bcc2 (patch)
treef5193b8a3130b02ffec6718a6848456e7a1a722b /program/steps/mail/func.inc
parentfe6b7ae748f1065a9f6ece6f0cc26594b6d208c3 (diff)
#1484972: optimization: mark as read in one action with preview, deleted redundant quota reads
Diffstat (limited to 'program/steps/mail/func.inc')
-rw-r--r--program/steps/mail/func.inc31
1 files changed, 22 insertions, 9 deletions
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index af3618112..393fcaa10 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -408,30 +408,43 @@ function rcmail_quota_display($attrib)
if (!$attrib['id'])
$attrib['id'] = 'rcmquotadisplay';
+ if(isset($attrib['display']))
+ $_SESSION['quota_display'] = $attrib['display'];
+
$OUTPUT->add_gui_object('quotadisplay', $attrib['id']);
// allow the following attributes to be added to the <span> tag
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'display'));
$out = '<span' . $attrib_str . '>';
- $out .= rcmail_quota_content($attrib['display']);
+ $out .= rcmail_quota_content();
$out .= '</span>';
return $out;
}
-function rcmail_quota_content($display)
+function rcmail_quota_content($quota=NULL)
{
global $IMAP, $COMM_PATH;
- if (!$IMAP->get_capability('QUOTA'))
- $quota_text = rcube_label('unknown');
- else if ($quota = $IMAP->get_quota())
+ $display = isset($_SESSION['quota_display']) ? $_SESSION['quota_display'] : '';
+
+ if (is_array($quota) && !empty($quota['used']) && !empty($quota['total']))
+ {
+ if (!isset($quota['percent']))
+ $quota['percent'] = $quota['used'] / $quota['total'];
+ }
+ elseif (!$IMAP->get_capability('QUOTA'))
+ return rcube_label('unknown');
+ else
+ $quota = $IMAP->get_quota();
+
+ if ($quota)
{
- $quota_text = sprintf("%s / %s (%.0f%%)",
- show_bytes($quota["used"] * 1024),
- show_bytes($quota["total"] * 1024),
- $quota["percent"]);
+ $quota_text = sprintf('%s / %s (%.0f%%)',
+ show_bytes($quota['used'] * 1024),
+ show_bytes($quota['total'] * 1024),
+ $quota['percent']);
// show quota as image (by Brett Patterson)
if ($display == 'image' && function_exists('imagegif'))