4 +-----------------------------------------------------------------------+
5 | program/steps/mail/check_recent.inc |
7 | This file is part of the Roundcube Webmail client |
8 | Copyright (C) 2005-2010, Roundcube Dev. - Switzerland |
9 | Licensed under the GNU GPL |
12 | Check for recent messages, in all mailboxes |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
18 $Id: check_recent.inc 4084 2010-10-13 19:15:51Z alec $
22 $current = $IMAP->get_mailbox_name();
23 $check_all = !empty($_GET['_refresh']) || (bool)$RCMAIL->config->get('check_all_folders');
25 // list of folders to check
27 $a_mailboxes = $IMAP->list_mailboxes();
30 $a_mailboxes = (array) $current;
31 if ($a_mailboxes[0] != 'INBOX')
32 $a_mailboxes[] = 'INBOX';
35 // check recent/unseen counts
36 foreach ($a_mailboxes as $mbox_name) {
37 if ($mbox_name == $current && ($status = $IMAP->mailbox_status($mbox_name))) {
39 rcmail_send_unread_count($mbox_name, true);
41 // refresh saved search set
42 $search_request = get_input_value('_search', RCUBE_INPUT_GPC);
43 if ($search_request && isset($_SESSION['search'])
44 && $_SESSION['search_request'] == $search_request
46 $_SESSION['search'] = $IMAP->refresh_search();
49 if (!empty($_GET['_quota']))
50 $OUTPUT->command('set_quota', rcmail_quota_content());
52 // "No-list" mode, don't get messages
53 if (empty($_GET['_list']))
56 // get overall message count; allow caching because rcube_imap::mailbox_status() did a refresh
57 $all_count = $IMAP->messagecount(null, $IMAP->threading ? 'THREADS' : 'ALL');
59 // check current page if we're not on the first page
60 if ($all_count && $IMAP->list_page > 1) {
61 $remaining = $all_count - $IMAP->page_size * ($IMAP->list_page - 1);
62 if ($remaining <= 0) {
63 $IMAP->set_page($IMAP->list_page-1);
64 $_SESSION['page'] = $IMAP->list_page;
68 $OUTPUT->set_env('messagecount', $all_count);
69 $OUTPUT->set_env('pagecount', ceil($all_count/$IMAP->page_size));
70 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($all_count));
71 $OUTPUT->set_env('current_page', $all_count ? $IMAP->list_page : 1);
74 if ($RCMAIL->config->get('focus_on_new_message', true))
75 $OUTPUT->command('new_message_focus');
76 // trigger plugin hook
77 $RCMAIL->plugins->exec_hook('new_messages', array('mailbox' => $mbox_name));
80 // remove old rows (and clear selection if new list is empty)
81 $OUTPUT->command('message_list.clear', $all_count ? false : true);
84 $a_headers = $IMAP->list_headers($mbox_name, null, $_SESSION['sort_col'], $_SESSION['sort_order']);
86 rcmail_js_message_list($a_headers, false);
87 // remove messages that don't exists from list selection array
88 $OUTPUT->command('update_selection');
92 rcmail_send_unread_count($mbox_name, true);