svncommit
2007-10-15 97a656643866f16289264954be961aa3f314ac20
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                     |
f11541 8  | Copyright (C) 2005-2007, 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();
S 23
24 foreach ($a_mailboxes as $mbox_name)
15a9d1 25   {
c8c1e0 26   if ($mbox_name == $IMAP->get_mailbox_name())
S 27     {
28     if ($recent_count = $IMAP->messagecount(NULL, 'RECENT', TRUE))
29       {
d70dde 30       $count = $IMAP->messagecount(NULL, 'ALL', TRUE);
c8c1e0 31       $unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE);
S 32
f11541 33       $OUTPUT->set_env('messagecount', $count);
5eee00 34       $OUTPUT->command('set_unread_count', $mbox_name, $unread_count, true);
f11541 35       $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text());
T 36       $OUTPUT->command('set_quota', $IMAP->get_quota());
c8c1e0 37
S 38       // add new message headers to list
39       $a_headers = array();
40       for ($i=$recent_count, $id=$count-$recent_count+1; $i>0; $i--, $id++)
c4e7e4 41         {
T 42         $header = $IMAP->get_headers($id, NULL, FALSE);
43         if ($header->recent)
44           $a_headers[] = $header;
45         }
c8c1e0 46
f11541 47       rcmail_js_message_list($a_headers, TRUE);
c8c1e0 48       }
S 49     }
50   else
51     {
52     if ($IMAP->messagecount($mbox_name, 'RECENT'))
f11541 53       $OUTPUT->command('set_unread_count', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'));
c8c1e0 54     }
15a9d1 55   }
T 56
f11541 57 $OUTPUT->send();
T 58
58e360 59 ?>