source: github/program/steps/mail/check_recent.inc @ 7c9d922

HEADcourier-fixdev-browser-capabilitiespdorelease-0.6release-0.7release-0.8
Last change on this file since 7c9d922 was 7c9d922, checked in by thomascube <thomas@…>, 3 years ago

New recent check based on UIDs

  • Property mode set to 100644
File size: 3.2 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-2010, 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$
19
20*/
21
22$a_mailboxes = $IMAP->list_mailboxes();
23$check_all = !empty($_GET['_refresh']) || (bool)$RCMAIL->config->get('check_all_folders');
24
25// check recent/unseen counts for all mailboxes
26foreach ($a_mailboxes as $mbox_name) {
27  if ($mbox_name == $IMAP->get_mailbox_name()) {
28    if ($recents = $IMAP->recent_uids($mbox_name)) {
29      // refresh saved search set
30      if (($search_request = get_input_value('_search', RCUBE_INPUT_GPC)) && isset($_SESSION['search'][$search_request])) {
31        $_SESSION['search'][$search_request] = $IMAP->refresh_search();
32      }
33     
34      // get overall message count; allow caching because rcube_imap::recent_uids() did a refresh
35      $all_count = $IMAP->messagecount();
36     
37      $unread_count = $IMAP->messagecount(NULL, 'UNSEEN', TRUE);
38      $_SESSION['unseen_count'][$mbox_name] = $unread_count;
39
40      $OUTPUT->set_env('messagecount', $all_count);
41      $OUTPUT->set_env('pagesize', $IMAP->page_size);
42      $OUTPUT->set_env('pagecount', ceil($all_count/$IMAP->page_size));
43      $OUTPUT->command('set_unread_count', $mbox_name, $unread_count, ($mbox_name == 'INBOX'));
44      $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($all_count));
45
46      if ($RCMAIL->config->get('focus_on_new_message',true))
47        $OUTPUT->command('new_message_focus');
48
49      if (!empty($_GET['_quota']))
50        $OUTPUT->command('set_quota', rcmail_quota_content());
51
52      // trigger plugin hook
53      $RCMAIL->plugins->exec_hook('new_messages', array('mailbox' => $mbox_name, 'count' => count($recents)));
54
55      // "No-list" mode, don't get messages
56      if (empty($_GET['_list']))
57        continue;
58
59      // use SEARCH/SORT to find recent messages
60      $search_str = 'UID '.min($recents).':'.max($recents);
61      if ($search_request)
62        $search_str .= ' '.$IMAP->search_string;
63
64      if ($IMAP->search($mbox_name, $search_str, NULL, 'date')) {
65        // get the headers and add them to the list
66        $result_h = $IMAP->list_headers($mbox_name, 1, 'date', 'DESC');
67        rcmail_js_message_list($result_h, true, false);
68      }
69    }
70    else {
71      rcmail_send_unread_count($mbox_name, true);
72    }
73  }
74  else if ($check_all) {
75    rcmail_send_unread_count($mbox_name, true);
76  }
77}
78
79$OUTPUT->send();
80
81?>
Note: See TracBrowser for help on using the repository browser.