thomascube
2009-03-10 75a09466ac6843b9dd861976105c1fc3177cb208
commit | author | age
15a9d1 1 <?php
T 2
3 /*
4  +-----------------------------------------------------------------------+
5  | program/steps/mail/check_recent.inc                                   |
6  |                                                                       |
7  | This file is part of the RoundCube Webmail client                     |
cbbef3 8  | Copyright (C) 2005-2009, RoundCube Dev. - Switzerland                 |
15a9d1 9  | Licensed under the GNU GPL                                            |
T 10  |                                                                       |
11  | PURPOSE:                                                              |
c8c1e0 12  |   Check for recent messages, in all mailboxes                         |
15a9d1 13  |                                                                       |
T 14  +-----------------------------------------------------------------------+
15  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16  +-----------------------------------------------------------------------+
17
c8c1e0 18  $Id: check_recent.inc 233 2006-06-26 17:31:20Z richs $
15a9d1 19
T 20 */
21
c8c1e0 22 $a_mailboxes = $IMAP->list_mailboxes();
2fd975 23 $check_all = (bool)$RCMAIL->config->get('check_all_folders');
c8c1e0 24
2fd975 25 foreach ($a_mailboxes as $mbox_name) {
T 26   if ($mbox_name == $IMAP->get_mailbox_name()) {
27     if ($recent_count = $IMAP->messagecount(NULL, 'RECENT', TRUE)) {
110748 28       // refresh saved search set
2e1809 29       if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && isset($_SESSION['search'][$search_request])) {
110748 30         $_SESSION['search'][$search_request] = $IMAP->refresh_search();
2e1809 31     $all_count = $IMAP->messagecount();
A 32       } else {
33         $all_count = $IMAP->messagecount(NULL, 'ALL', TRUE);
34       }
35       
c8c1e0 36       $unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE);
S 37
2e1809 38       $OUTPUT->set_env('messagecount', $all_count);
095d05 39       $OUTPUT->set_env('pagesize', $IMAP->page_size);
2e1809 40       $OUTPUT->set_env('pagecount', ceil($all_count/$IMAP->page_size));
cf1f0f 41       $OUTPUT->command('set_unread_count', $mbox_name, $unread_count, ($mbox_name == 'INBOX'));
2e1809 42       $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($all_count));
c8c1e0 43
06343d 44       if (rcmail::get_instance()->config->get('focus_on_new_message',true))
A 45         $OUTPUT->command('new_message_focus');
46
2e1809 47       if (!empty($_GET['_quota']))
A 48         $OUTPUT->command('set_quota', rcmail_quota_content($IMAP->get_quota()));
c8c1e0 49
2e1809 50       // "No-list" mode, don't get messages
A 51       if (empty($_GET['_list']))
52         continue;
53
54       // use SEARCH/SORT to find recent messages
55       $search_str = 'RECENT';
56       if ($search_request)
57         $search_str .= ' '.$IMAP->search_string;
58
59       $result = $IMAP->search($mbox_name, $search_str, NULL, 'date');
60
61       if ($result) {
62         // get the headers
63         $result_h = $IMAP->list_headers($mbox_name, 1, 'date', 'DESC');
64         // add to the list
65     rcmail_js_message_list($result_h, TRUE);
66       }
c8c1e0 67     }
15a9d1 68   }
75a094 69   else if ($unseen = $IMAP->messagecount($mbox_name, 'UNSEEN', $check_all)) {
T 70     $OUTPUT->command('set_unread_count', $mbox_name, $unseen);
2fd975 71   }
T 72 }
15a9d1 73
f11541 74 $OUTPUT->send();
T 75
58e360 76 ?>