Thomas Bruederli
2014-01-16 2baeac116abef9d5bcb748c687577d16dce868a0
commit | author | age
15a9d1 1 <?php
T 2
3 /*
4  +-----------------------------------------------------------------------+
5  | program/steps/mail/getunread.inc                                      |
6  |                                                                       |
e019f2 7  | This file is part of the Roundcube Webmail client                     |
c97625 8  | Copyright (C) 2005-2013, The Roundcube Dev Team                       |
7fe381 9  |                                                                       |
T 10  | Licensed under the GNU General Public License version 3 or            |
11  | any later version with exceptions for skins & plugins.                |
12  | See the README file for a full license statement.                     |
15a9d1 13  |                                                                       |
T 14  | PURPOSE:                                                              |
15  |   Check all mailboxes for unread messages and update GUI              |
16  |                                                                       |
17  +-----------------------------------------------------------------------+
18  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
19  +-----------------------------------------------------------------------+
20 */
21
c321a9 22 $a_folders = $RCMAIL->storage->list_folders_subscribed('', '*', 'mail');
15a9d1 23
c97625 24 if (!empty($a_folders)) {
da5fa2 25     $current   = $RCMAIL->storage->get_folder();
AM 26     $inbox     = ($current == 'INBOX');
27     $trash     = $RCMAIL->config->get('trash_mbox');
28     $check_all = (bool)$RCMAIL->config->get('check_all_folders');
70ee70 29
da5fa2 30     foreach ($a_folders as $mbox) {
AM 31         $unseen_old = rcmail_get_unseen_count($mbox);
78925f 32
da5fa2 33         if (!$check_all && $unseen_old !== null && $mbox != $current) {
AM 34             $unseen = $unseen_old;
35         }
36         else {
37             $unseen = $RCMAIL->storage->count($mbox, 'UNSEEN', $unseen_old === null);
38         }
b46edc 39
da5fa2 40         // call it always for current folder, so it can update counter
AM 41         // after possible message status change when opening a message
42         // not in preview frame
43         if ($unseen || $unseen_old === null || $mbox == $current) {
44             $OUTPUT->command('set_unread_count', $mbox, $unseen, $inbox && $mbox_row == 'INBOX');
45         }
46
47         rcmail_set_unseen_count($mbox, $unseen);
48
49         // set trash folder state
50         if ($mbox === $trash) {
51             $OUTPUT->command('set_trash_count', $RCMAIL->storage->count($mbox, 'EXISTS'));
52         }
78925f 53     }
f11541 54 }
15a9d1 55
f11541 56 $OUTPUT->send();