0
|
1 <?php
|
|
2
|
|
3 /**
|
|
4 +-----------------------------------------------------------------------+
|
|
5 | program/steps/mail/getunread.inc |
|
|
6 | |
|
|
7 | This file is part of the Roundcube Webmail client |
|
|
8 | Copyright (C) 2005-2013, The Roundcube Dev Team |
|
|
9 | |
|
|
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. |
|
|
13 | |
|
|
14 | PURPOSE: |
|
|
15 | Check all mailboxes for unread messages and update GUI |
|
|
16 | |
|
|
17 +-----------------------------------------------------------------------+
|
|
18 | Author: Thomas Bruederli <roundcube@gmail.com> |
|
|
19 +-----------------------------------------------------------------------+
|
|
20 */
|
|
21
|
|
22 $a_folders = $RCMAIL->storage->list_folders_subscribed('', '*', 'mail');
|
|
23
|
|
24 if (!empty($a_folders)) {
|
|
25 $current = $RCMAIL->storage->get_folder();
|
|
26 $inbox = ($current == 'INBOX');
|
|
27 $trash = $RCMAIL->config->get('trash_mbox');
|
|
28 $check_all = (bool)$RCMAIL->config->get('check_all_folders');
|
|
29
|
|
30 foreach ($a_folders as $mbox) {
|
|
31 $unseen_old = rcmail_get_unseen_count($mbox);
|
|
32
|
|
33 if (!$check_all && $unseen_old !== null && $mbox != $current) {
|
|
34 $unseen = $unseen_old;
|
|
35 }
|
|
36 else {
|
|
37 $unseen = $RCMAIL->storage->count($mbox, 'UNSEEN', $unseen_old === null);
|
|
38 }
|
|
39
|
|
40 // call it always for current folder, so it can update counter
|
|
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 }
|
|
53 }
|
|
54 }
|
|
55
|
|
56 $OUTPUT->send();
|