]> git.donarmstrong.com Git - roundcube.git/blob - program/steps/mail/check_recent.inc
Imported Upstream version 0.1
[roundcube.git] / program / steps / mail / check_recent.inc
1 <?php
2
3 /*
4  +-----------------------------------------------------------------------+
5  | program/steps/mail/check_recent.inc                                   |
6  |                                                                       |
7  | This file is part of the RoundCube Webmail client                     |
8  | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 |
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();
23
24 foreach ($a_mailboxes as $mbox_name)
25   {
26   if ($mbox_name == $IMAP->get_mailbox_name())
27     {
28     if ($recent_count = $IMAP->messagecount(NULL, 'RECENT', TRUE))
29       {
30       // refresh saved search set
31       if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && $IMAP->search_set)
32         $_SESSION['search'][$search_request] = $IMAP->refresh_search();
33         
34       $count_all = $IMAP->messagecount(NULL, 'ALL', TRUE);
35       $unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE);
36
37       $OUTPUT->set_env('messagecount', $IMAP->messagecount());
38       $OUTPUT->command('set_unread_count', $mbox_name, $unread_count, ($mbox_name == 'INBOX'));
39       $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text());
40       $OUTPUT->command('set_quota', $IMAP->get_quota());
41
42       // add new message headers to list
43       $a_headers = array();
44       for ($i=$recent_count, $id=$count_all-$recent_count+1; $i>0; $i--, $id++)
45         {
46         // skip message if it does not match the current search
47         if (!$IMAP->in_searchset($id))
48           continue;
49         
50         $header = $IMAP->get_headers($id, NULL, FALSE);
51         if ($header->recent)
52           $a_headers[] = $header;
53         }
54
55       rcmail_js_message_list($a_headers, TRUE);
56       }
57     }
58   else
59     {
60     if ($IMAP->messagecount($mbox_name, 'RECENT'))
61       $OUTPUT->command('set_unread_count', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'));
62     }
63   }
64
65 $OUTPUT->send();
66
67 ?>