source: subversion/trunk/roundcubemail/program/steps/mail/check_recent.inc @ 2099

Last change on this file since 2099 was 2099, checked in by thomasb, 4 years ago

Option to check for new mails in all folders (#1484374)

File size: 2.8 KB
Line 
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-2008, 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$check_all = (bool)$RCMAIL->config->get('check_all_folders');
24
25foreach ($a_mailboxes as $mbox_name) {
26  if ($mbox_name == $IMAP->get_mailbox_name()) {
27    if ($recent_count = $IMAP->messagecount(NULL, 'RECENT', TRUE)) {
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);
33      $unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE);
34
35      $OUTPUT->set_env('messagecount', $IMAP->messagecount());
36      $OUTPUT->set_env('pagesize', $IMAP->page_size);
37      $OUTPUT->set_env('pagecount', ceil($IMAP->messagecount()/$IMAP->page_size));
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', rcmail_quota_content($IMAP->get_quota()));
41
42      if (rcmail::get_instance()->config->get('focus_on_new_message',true))
43        $OUTPUT->command('new_message_focus');
44
45      // add new message headers to list
46      $a_headers = array();
47      for ($i=$recent_count, $id=$count_all-$recent_count+1; $i>0; $i--, $id++)
48      {
49        // skip message if it does not match the current search
50        if (!$IMAP->in_searchset($id))
51          continue;
52       
53        $header = $IMAP->get_headers($id, NULL, FALSE);
54        if ($header->recent)
55          $a_headers[] = $header;
56      }
57
58      rcmail_js_message_list($a_headers, TRUE);
59    }
60  }
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}
65
66$OUTPUT->send();
67
68?>
Note: See TracBrowser for help on using the repository browser.