diff options
author | alecpl <alec@alec.pl> | 2009-12-13 18:28:47 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2009-12-13 18:28:47 +0000 |
commit | 5b3ed54e84590bdb6efbfe3c79c5e0129486ef1a (patch) | |
tree | 5aa23740755d2865e3b05dd51b14d23db62bafba | |
parent | 317a7d9f677b50db12c5988f38abb10ade0634a5 (diff) |
- Plugin API: added 'quota' hook
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | program/steps/mail/check_recent.inc | 2 | ||||
-rw-r--r-- | program/steps/mail/func.inc | 27 | ||||
-rw-r--r-- | program/steps/mail/move_del.inc | 2 |
4 files changed, 18 insertions, 14 deletions
@@ -1,6 +1,7 @@ CHANGELOG RoundCube Webmail =========================== +- Plugin API: added 'quota' hook - Fix parsing conditional comments in HTML messages (#1486350) - Use built-in json_encode() for proper JSON format in AJAX replies - Allow setting only selected params in 'message_compose' hook (#1486312) diff --git a/program/steps/mail/check_recent.inc b/program/steps/mail/check_recent.inc index 094c429d4..4b8427358 100644 --- a/program/steps/mail/check_recent.inc +++ b/program/steps/mail/check_recent.inc @@ -46,7 +46,7 @@ foreach ($a_mailboxes as $mbox_name) { $OUTPUT->command('new_message_focus'); if (!empty($_GET['_quota'])) - $OUTPUT->command('set_quota', rcmail_quota_content($IMAP->get_quota())); + $OUTPUT->command('set_quota', rcmail_quota_content()); // trigger plugin hook $RCMAIL->plugins->exec_hook('new_messages', array('mailbox' => $mbox_name, 'count' => $unread_count)); diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index b874817ff..52b371999 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -515,7 +515,7 @@ function rcmail_quota_display($attrib) $OUTPUT->add_gui_object('quotadisplay', $attrib['id']); - $quota = rcmail_quota_content(NULL, $attrib); + $quota = rcmail_quota_content($attrib); if (is_array($quota)) { $OUTPUT->add_script('$(document).ready(function(){ @@ -527,30 +527,33 @@ function rcmail_quota_display($attrib) } -function rcmail_quota_content($quota=NULL, $attrib=NULL) +function rcmail_quota_content($attrib=NULL) { - global $IMAP, $COMM_PATH, $RCMAIL; + global $COMM_PATH, $RCMAIL; $display = isset($_SESSION['quota_display']) ? $_SESSION['quota_display'] : ''; - if (empty($quota)) { - if (!$IMAP->get_capability('QUOTA')) - return rcube_label('unknown'); - else - $quota = $IMAP->get_quota(); - } + $quota = $RCMAIL->imap->get_quota(); + $quota = $RCMAIL->plugins->exec_hook('quota', $quota); + + if (!isset($quota['used']) || !isset($quota['total'])) + return rcube_label('unknown'); - if ($quota && !($quota['total']==0 && $RCMAIL->config->get('quota_zero_as_unlimited'))) + if (!($quota['total']==0 && $RCMAIL->config->get('quota_zero_as_unlimited'))) { + if (!isset($quota['percent'])) + $quota['percent'] = min(100, round(($quota['used']/max(1,$quota['total']))*100)); + $quota_result = sprintf('%s / %s (%.0f%%)', show_bytes($quota['used'] * 1024), show_bytes($quota['total'] * 1024), $quota['percent']); if ($display == 'image') { - $quota_result = array( + $quota_result = array( 'percent' => $quota['percent'], 'title' => $quota_result, ); + if ($attrib['width']) $quota_result['width'] = $attrib['width']; if ($attrib['height']) @@ -733,7 +736,7 @@ function rcmail_wash_html($html, $p = array(), $cid_replaces) $html = $washer->wash($html); $REMOTE_OBJECTS = $washer->extlinks; - + return $html; } diff --git a/program/steps/mail/move_del.inc b/program/steps/mail/move_del.inc index 30102d9d5..2895867e3 100644 --- a/program/steps/mail/move_del.inc +++ b/program/steps/mail/move_del.inc @@ -113,7 +113,7 @@ else rcmail_send_unread_count($target, true); } - $OUTPUT->command('set_quota', rcmail_quota_content($IMAP->get_quota())); + $OUTPUT->command('set_quota', rcmail_quota_content()); $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count)); // add new rows from next page (if any) |