4 +-----------------------------------------------------------------------+
5 | program/steps/mail/check_recent.inc |
7 | This file is part of the RoundCube Webmail client |
8 | Copyright (C) 2005-2009, 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 233 2006-06-26 17:31:20Z richs $
22 $a_mailboxes = $IMAP->list_mailboxes();
23 $check_all = (bool)$RCMAIL->config->get('check_all_folders');
25 foreach ($a_mailboxes as $mbox_name) {
26 if ($mbox_name == $IMAP->get_mailbox_name()) {
27 if ($recent_count = $IMAP->messagecount(NULL, 'RECENT', TRUE)) {
28 // refresh saved search set
29 if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && isset($_SESSION['search'][$search_request])) {
30 $_SESSION['search'][$search_request] = $IMAP->refresh_search();
31 $all_count = $IMAP->messagecount();
33 $all_count = $IMAP->messagecount(NULL, 'ALL', TRUE);
36 $unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE);
37 $_SESSION['unseen_count'][$mbox_name] = $unread_count;
39 $OUTPUT->set_env('messagecount', $all_count);
40 $OUTPUT->set_env('pagesize', $IMAP->page_size);
41 $OUTPUT->set_env('pagecount', ceil($all_count/$IMAP->page_size));
42 $OUTPUT->command('set_unread_count', $mbox_name, $unread_count, ($mbox_name == 'INBOX'));
43 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($all_count));
45 if (rcmail::get_instance()->config->get('focus_on_new_message',true))
46 $OUTPUT->command('new_message_focus');
48 if (!empty($_GET['_quota']))
49 $OUTPUT->command('set_quota', rcmail_quota_content($IMAP->get_quota()));
51 // trigger plugin hook
52 $RCMAIL->plugins->exec_hook('new_messages', array('mailbox' => $mbox_name, 'count' => $unread_count));
54 // "No-list" mode, don't get messages
55 if (empty($_GET['_list']))
58 // use SEARCH/SORT to find recent messages
59 $search_str = 'RECENT';
61 $search_str .= ' '.$IMAP->search_string;
63 $result = $IMAP->search($mbox_name, $search_str, NULL, 'date');
67 $result_h = $IMAP->list_headers($mbox_name, 1, 'date', 'DESC');
69 rcmail_js_message_list($result_h, true, false);
73 rcmail_send_unread_count($mbox_name, true);
76 else if ($check_all) {
77 rcmail_send_unread_count($mbox_name, true);