yllar
2006-12-11 df8e8ec9eee72743d0f14a8409aacf66c4a80d89
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                     |
8  | Copyright (C) 2005, RoundCube Dev. - Switzerland                      |
9  | Licensed under the GNU GPL                                            |
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
22 $REMOTE_REQUEST = TRUE;
23
c8c1e0 24 $a_mailboxes = $IMAP->list_mailboxes();
S 25
26 foreach ($a_mailboxes as $mbox_name)
15a9d1 27   {
c8c1e0 28   if ($mbox_name == $IMAP->get_mailbox_name())
S 29     {
30     if ($recent_count = $IMAP->messagecount(NULL, 'RECENT', TRUE))
31       {
32       $count = $IMAP->messagecount();
33       $unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE);
34
25d8ba 35       $commands .= sprintf("this.set_unread_count('%s', %d);\n", addslashes($mbox_name), $unread_count);
c8c1e0 36       $commands .= sprintf("this.set_env('messagecount', %d);\n", $count);
S 37       $commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text());
38       $commands .= sprintf("this.set_quota('%s');\n", $IMAP->get_quota());
39
40       // add new message headers to list
41       $a_headers = array();
42       for ($i=$recent_count, $id=$count-$recent_count+1; $i>0; $i--, $id++)
c4e7e4 43         {
T 44         $header = $IMAP->get_headers($id, NULL, FALSE);
45         if ($header->recent)
46           $a_headers[] = $header;
47         }
c8c1e0 48
S 49       $commands .= rcmail_js_message_list($a_headers, TRUE);
50       }
51     }
52   else
53     {
54     if ($IMAP->messagecount($mbox_name, 'RECENT'))
55       $commands .= sprintf("this.set_unread_count('%s', %d);\n", addslashes($mbox_name), $IMAP->messagecount($mbox_name, 'UNSEEN'));
56     }
15a9d1 57   }
T 58
59 rcube_remote_response($commands);
58e360 60 ?>