diff options
author | alecpl <alec@alec.pl> | 2009-09-17 12:07:58 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2009-09-17 12:07:58 +0000 |
commit | 78925f8f1a9afb9475a9cf9ad1b35daade23da85 (patch) | |
tree | e17493f32eb5f11a6faa77ff64ef7f81a1e0c469 /program/steps | |
parent | 20e251599fa595102188bffb9fc5ffc4a1ca0166 (diff) |
- Fix incorrect count of new messages in folder list when using multiple IMAP clients (#1485995)
- Fix all folders checking for new messages with disabled caching (#1486128)
Diffstat (limited to 'program/steps')
-rw-r--r-- | program/steps/mail/check_recent.inc | 22 | ||||
-rw-r--r-- | program/steps/mail/folders.inc | 2 | ||||
-rw-r--r-- | program/steps/mail/getunread.inc | 11 | ||||
-rw-r--r-- | program/steps/mail/list.inc | 10 | ||||
-rw-r--r-- | program/steps/mail/mark.inc | 13 | ||||
-rw-r--r-- | program/steps/mail/move_del.inc | 14 |
6 files changed, 61 insertions, 11 deletions
diff --git a/program/steps/mail/check_recent.inc b/program/steps/mail/check_recent.inc index 78b7fbbdf..d091d611b 100644 --- a/program/steps/mail/check_recent.inc +++ b/program/steps/mail/check_recent.inc @@ -68,12 +68,30 @@ foreach ($a_mailboxes as $mbox_name) { rcmail_js_message_list($result_h, true, false); } } + else { + send_unread_count($mbox_name); + } } - else if ($unseen = $IMAP->messagecount($mbox_name, 'UNSEEN', $check_all)) { - $OUTPUT->command('set_unread_count', $mbox_name, $unseen); + else if ($check_all) { + send_unread_count($mbox_name); } } $OUTPUT->send(); + +function send_unread_count($mbox_name) +{ + global $RCMAIL; + + $old_unseen = $_SESSION['unseen_count'][$mbox_name]; + $unseen = $RCMAIL->imap->messagecount($mbox_name, 'UNSEEN', true); + + if ($unseen != $old_unseen) + $RCMAIL->output->command('set_unread_count', $mbox_name, $unseen, ($mbox_name == 'INBOX')); + + // @TODO: this data is doubled (session and cache tables) if caching is enabled + $_SESSION['unseen_count'][$mbox_name] = $unseen; +} + ?> diff --git a/program/steps/mail/folders.inc b/program/steps/mail/folders.inc index dc086b155..73d4ae8c4 100644 --- a/program/steps/mail/folders.inc +++ b/program/steps/mail/folders.inc @@ -60,6 +60,7 @@ else if ($RCMAIL->action=='purge' && ($mbox = get_input_value('_mbox', RCUBE_INP $OUTPUT->command('message_list.clear'); $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text()); $OUTPUT->command('set_unread_count', $mbox_name, 0); + $_SESSION['unseen_count'][$mbox_name] = 0; } else $commands = "// purged: $success"; @@ -67,4 +68,5 @@ else if ($RCMAIL->action=='purge' && ($mbox = get_input_value('_mbox', RCUBE_INP } $OUTPUT->send($commands); + ?> diff --git a/program/steps/mail/getunread.inc b/program/steps/mail/getunread.inc index 145930c49..bee2073e3 100644 --- a/program/steps/mail/getunread.inc +++ b/program/steps/mail/getunread.inc @@ -24,9 +24,16 @@ $a_folders = $IMAP->list_mailboxes(); if (!empty($a_folders)) { $inbox = ($IMAP->get_mailbox_name() == 'INBOX'); - foreach ($a_folders as $mbox_row) - $OUTPUT->command('set_unread_count', $mbox_row, $IMAP->messagecount($mbox_row, 'UNSEEN'), $inbox && $mbox_row == 'INBOX'); + foreach ($a_folders as $mbox_row) { + $unseen = $IMAP->messagecount($mbox_row, 'UNSEEN', !isset($_SESSION['unseen_count'][$mbox_row])); + $_SESSION['unseen_count'][$mbox_row] = $unseen; + + if ($unseen) { + $OUTPUT->command('set_unread_count', $mbox_row, $unseen, $inbox && $mbox_row == 'INBOX'); + } + } } $OUTPUT->send(); + ?> diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc index 8ba0dd017..a40fce679 100644 --- a/program/steps/mail/list.inc +++ b/program/steps/mail/list.inc @@ -60,7 +60,14 @@ if ($_SESSION['search_filter'] && $_SESSION['search_filter'] != 'ALL') if ($count = $IMAP->messagecount($mbox_name, 'ALL', !empty($_REQUEST['_refresh']))) $a_headers = $IMAP->list_headers($mbox_name, NULL, $sort_col, $sort_order); +// count UNSEEN messages... +$old_unseen = $_SESSION['unseen_count'][$mbox_name]; $unseen = $count ? $IMAP->messagecount($mbox_name, 'UNSEEN', !empty($_REQUEST['_refresh'])) : 0; +$_SESSION['unseen_count'][$mbox_name] = $unseen; + +// ...and update mailboxlist +if ($unseen != $old_unseen) + $OUTPUT->command('set_unread_count', $mbox_name, $unseen, ($mbox_name == 'INBOX')); // update message count display $pages = ceil($count/$IMAP->page_size); @@ -80,9 +87,6 @@ else if ($search_request) $OUTPUT->show_message('searchnomatch', 'notice'); else $OUTPUT->show_message('nomessagesfound', 'notice'); - -// update mailboxlist -$OUTPUT->command('set_unread_count', $mbox_name, $unseen, ($mbox_name == 'INBOX')); // send response $OUTPUT->send(); diff --git a/program/steps/mail/mark.inc b/program/steps/mail/mark.inc index c3ddf7b8c..c065b3f92 100644 --- a/program/steps/mail/mark.inc +++ b/program/steps/mail/mark.inc @@ -62,7 +62,12 @@ if (($uids = get_input_value('_uid', RCUBE_INPUT_POST)) && ($flag = get_input_va if ($flag == 'SEEN' || $flag == 'UNSEEN' || ($flag == 'DELETED' && !$CONFIG['skip_deleted'])) { $mbox_name = $IMAP->get_mailbox_name(); - $OUTPUT->command('set_unread_count', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'), ($mbox_name == 'INBOX')); + $unseen = $IMAP->messagecount($mbox_name, 'UNSEEN'); + $old_unseen = $_SESSION['unseen_count'][$mbox_name]; + if ($old_unseen != $unseen) { + $OUTPUT->command('set_unread_count', $mbox_name, $unseen, ($mbox_name == 'INBOX')); + $_SESSION['unseen_count'][$mbox_name] = $unseen; + } } else if ($flag == 'DELETED' && $CONFIG['skip_deleted']) { if ($_POST['_from'] == 'show') { @@ -96,7 +101,11 @@ if (($uids = get_input_value('_uid', RCUBE_INPUT_POST)) && ($flag = get_input_va // update mailboxlist $mbox = $IMAP->get_mailbox_name(); $unseen_count = $msg_count ? $IMAP->messagecount($mbox, 'UNSEEN') : 0; - $OUTPUT->command('set_unread_count', $mbox, $unseen_count, ($mbox == 'INBOX')); + $old_unseen = $_SESSION['unseen_count'][$mbox]; + if ($old_unseen != $unseen_count) { + $OUTPUT->command('set_unread_count', $mbox, $unseen_count, ($mbox == 'INBOX')); + $_SESSION['unseen_count'][$mbox] = $unseen_count; + } $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count)); // add new rows from next page (if any) diff --git a/program/steps/mail/move_del.inc b/program/steps/mail/move_del.inc index fbfbabf35..2a8cee633 100644 --- a/program/steps/mail/move_del.inc +++ b/program/steps/mail/move_del.inc @@ -102,10 +102,20 @@ else // update mailboxlist $mbox = $IMAP->get_mailbox_name(); $unseen_count = $msg_count ? $IMAP->messagecount($mbox, 'UNSEEN') : 0; - $OUTPUT->command('set_unread_count', $mbox, $unseen_count, ($mbox == 'INBOX')); + $old_unseen = $_SESSION['unseen_count'][$mbox]; + + if ($old_unseen != $unseen_count) { + $OUTPUT->command('set_unread_count', $mbox, $unseen_count, ($mbox == 'INBOX')); + $_SESSION['unseen_count'][$mbox] = $unseen_count; + } if ($RCMAIL->action=='moveto' && $target) { - $OUTPUT->command('set_unread_count', $target, $IMAP->messagecount($target, 'UNSEEN')); + $unseen_count = $IMAP->messagecount($target, 'UNSEEN', true); + $old_unseen = $_SESSION['unseen_count'][$target]; + if ($old_unseen != $unseen_count) { + $OUTPUT->command('set_unread_count', $target, $unseen_count); + $_SESSION['unseen_count'][$target] = $unseen_count; + } } $OUTPUT->command('set_quota', rcmail_quota_content($IMAP->get_quota())); |