From 6d2714b3b3660f8a4efbb9c53e00b76245c2bcc2 Mon Sep 17 00:00:00 2001 From: alecpl Date: Fri, 11 Apr 2008 16:53:59 +0000 Subject: #1484972: optimization: mark as read in one action with preview, deleted redundant quota reads --- program/steps/mail/func.inc | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'program/steps/mail/func.inc') 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 tag $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'display')); $out = ''; - $out .= rcmail_quota_content($attrib['display']); + $out .= rcmail_quota_content(); $out .= ''; 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')) -- cgit v1.2.3