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

Last change on this file since 3306 was 3306, checked in by thomasb, 3 years ago

New recent check based on UIDs

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