| [267] | 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /* |
|---|
| 4 | +-----------------------------------------------------------------------+ |
|---|
| 5 | | program/steps/mail/check_recent.inc | |
|---|
| 6 | | | |
|---|
| 7 | | This file is part of the RoundCube Webmail client | |
|---|
| [2099] | 8 | | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | |
|---|
| [267] | 9 | | Licensed under the GNU GPL | |
|---|
| 10 | | | |
|---|
| 11 | | PURPOSE: | |
|---|
| 12 | | Check for recent messages, in all mailboxes | |
|---|
| 13 | | | |
|---|
| 14 | +-----------------------------------------------------------------------+ |
|---|
| 15 | | Author: Thomas Bruederli <roundcube@gmail.com> | |
|---|
| 16 | +-----------------------------------------------------------------------+ |
|---|
| 17 | |
|---|
| 18 | $Id: check_recent.inc 233 2006-06-26 17:31:20Z richs $ |
|---|
| 19 | |
|---|
| 20 | */ |
|---|
| 21 | |
|---|
| 22 | $a_mailboxes = $IMAP->list_mailboxes(); |
|---|
| [2099] | 23 | $check_all = (bool)$RCMAIL->config->get('check_all_folders'); |
|---|
| [267] | 24 | |
|---|
| [2099] | 25 | foreach ($a_mailboxes as $mbox_name) { |
|---|
| 26 | if ($mbox_name == $IMAP->get_mailbox_name()) { |
|---|
| 27 | if ($recent_count = $IMAP->messagecount(NULL, 'RECENT', TRUE)) { |
|---|
| [932] | 28 | // refresh saved search set |
|---|
| 29 | if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set) |
|---|
| 30 | $_SESSION['search'][$search_request] = $IMAP->refresh_search(); |
|---|
| 31 | |
|---|
| 32 | $count_all = $IMAP->messagecount(NULL, 'ALL', TRUE); |
|---|
| [267] | 33 | $unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE); |
|---|
| 34 | |
|---|
| [932] | 35 | $OUTPUT->set_env('messagecount', $IMAP->messagecount()); |
|---|
| [1819] | 36 | $OUTPUT->set_env('pagesize', $IMAP->page_size); |
|---|
| 37 | $OUTPUT->set_env('pagecount', ceil($IMAP->messagecount()/$IMAP->page_size)); |
|---|
| [1019] | 38 | $OUTPUT->command('set_unread_count', $mbox_name, $unread_count, ($mbox_name == 'INBOX')); |
|---|
| [543] | 39 | $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text()); |
|---|
| [1285] | 40 | $OUTPUT->command('set_quota', rcmail_quota_content($IMAP->get_quota())); |
|---|
| [267] | 41 | |
|---|
| [2003] | 42 | if (rcmail::get_instance()->config->get('focus_on_new_message',true)) |
|---|
| 43 | $OUTPUT->command('new_message_focus'); |
|---|
| 44 | |
|---|
| [267] | 45 | // add new message headers to list |
|---|
| 46 | $a_headers = array(); |
|---|
| [932] | 47 | for ($i=$recent_count, $id=$count_all-$recent_count+1; $i>0; $i--, $id++) |
|---|
| [2099] | 48 | { |
|---|
| [932] | 49 | // skip message if it does not match the current search |
|---|
| 50 | if (!$IMAP->in_searchset($id)) |
|---|
| 51 | continue; |
|---|
| 52 | |
|---|
| [291] | 53 | $header = $IMAP->get_headers($id, NULL, FALSE); |
|---|
| 54 | if ($header->recent) |
|---|
| 55 | $a_headers[] = $header; |
|---|
| [2099] | 56 | } |
|---|
| [267] | 57 | |
|---|
| [543] | 58 | rcmail_js_message_list($a_headers, TRUE); |
|---|
| [267] | 59 | } |
|---|
| 60 | } |
|---|
| [2099] | 61 | else if ($IMAP->messagecount($mbox_name, 'RECENT', $check_all)) { |
|---|
| 62 | $OUTPUT->command('set_unread_count', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN', $check_all)); |
|---|
| 63 | } |
|---|
| 64 | } |
|---|
| [267] | 65 | |
|---|
| [543] | 66 | $OUTPUT->send(); |
|---|
| 67 | |
|---|
| [267] | 68 | ?> |
|---|