commit | author | age
|
15a9d1
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/steps/mail/check_recent.inc | |
|
6 |
| | |
e019f2
|
7 |
| This file is part of the Roundcube Webmail client | |
f5e7b3
|
8 |
| Copyright (C) 2005-2010, The Roundcube Dev Team | |
15a9d1
|
9 |
| Licensed under the GNU GPL | |
T |
10 |
| | |
|
11 |
| PURPOSE: | |
c8c1e0
|
12 |
| Check for recent messages, in all mailboxes | |
15a9d1
|
13 |
| | |
T |
14 |
+-----------------------------------------------------------------------+ |
|
15 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
16 |
+-----------------------------------------------------------------------+ |
|
17 |
|
580ff9
|
18 |
$Id$ |
15a9d1
|
19 |
|
T |
20 |
*/ |
|
21 |
|
488074
|
22 |
$current = $IMAP->get_mailbox_name(); |
7c9d92
|
23 |
$check_all = !empty($_GET['_refresh']) || (bool)$RCMAIL->config->get('check_all_folders'); |
5e9a56
|
24 |
|
7b7edc
|
25 |
// list of folders to check |
A |
26 |
if ($check_all) { |
94bdcc
|
27 |
$a_mailboxes = $IMAP->list_mailboxes('', '*', 'mail'); |
7b7edc
|
28 |
} |
A |
29 |
else { |
|
30 |
$a_mailboxes = (array) $current; |
|
31 |
if ($a_mailboxes[0] != 'INBOX') |
|
32 |
$a_mailboxes[] = 'INBOX'; |
|
33 |
} |
|
34 |
|
|
35 |
// check recent/unseen counts |
2fd975
|
36 |
foreach ($a_mailboxes as $mbox_name) { |
488074
|
37 |
if ($mbox_name == $current && ($status = $IMAP->mailbox_status($mbox_name))) { |
c8c1e0
|
38 |
|
488074
|
39 |
rcmail_send_unread_count($mbox_name, true); |
c8c1e0
|
40 |
|
488074
|
41 |
// refresh saved search set |
A |
42 |
$search_request = get_input_value('_search', RCUBE_INPUT_GPC); |
f6aac3
|
43 |
if ($search_request && isset($_SESSION['search']) |
A |
44 |
&& $_SESSION['search_request'] == $search_request |
|
45 |
) { |
|
46 |
$_SESSION['search'] = $IMAP->refresh_search(); |
f52c93
|
47 |
} |
488074
|
48 |
|
A |
49 |
if (!empty($_GET['_quota'])) |
|
50 |
$OUTPUT->command('set_quota', rcmail_quota_content()); |
|
51 |
|
|
52 |
// "No-list" mode, don't get messages |
|
53 |
if (empty($_GET['_list'])) |
|
54 |
continue; |
|
55 |
|
|
56 |
// get overall message count; allow caching because rcube_imap::mailbox_status() did a refresh |
|
57 |
$all_count = $IMAP->messagecount(null, $IMAP->threading ? 'THREADS' : 'ALL'); |
|
58 |
|
|
59 |
// check current page if we're not on the first page |
|
60 |
if ($all_count && $IMAP->list_page > 1) { |
|
61 |
$remaining = $all_count - $IMAP->page_size * ($IMAP->list_page - 1); |
|
62 |
if ($remaining <= 0) { |
|
63 |
$IMAP->set_page($IMAP->list_page-1); |
|
64 |
$_SESSION['page'] = $IMAP->list_page; |
|
65 |
} |
|
66 |
} |
|
67 |
|
|
68 |
$OUTPUT->set_env('messagecount', $all_count); |
|
69 |
$OUTPUT->set_env('pagecount', ceil($all_count/$IMAP->page_size)); |
|
70 |
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($all_count)); |
|
71 |
$OUTPUT->set_env('current_page', $all_count ? $IMAP->list_page : 1); |
|
72 |
|
|
73 |
if ($status & 1) { |
|
74 |
// trigger plugin hook |
|
75 |
$RCMAIL->plugins->exec_hook('new_messages', array('mailbox' => $mbox_name)); |
|
76 |
} |
|
77 |
|
|
78 |
// remove old rows (and clear selection if new list is empty) |
|
79 |
$OUTPUT->command('message_list.clear', $all_count ? false : true); |
|
80 |
|
|
81 |
if ($all_count) { |
|
82 |
$a_headers = $IMAP->list_headers($mbox_name, null, $_SESSION['sort_col'], $_SESSION['sort_order']); |
|
83 |
// add message rows |
e99d21
|
84 |
rcmail_js_message_list($a_headers, false); |
488074
|
85 |
// remove messages that don't exists from list selection array |
A |
86 |
$OUTPUT->command('update_selection'); |
|
87 |
} |
c8c1e0
|
88 |
} |
78925f
|
89 |
else { |
488074
|
90 |
rcmail_send_unread_count($mbox_name, true); |
78925f
|
91 |
} |
2fd975
|
92 |
} |
15a9d1
|
93 |
|
06c01d
|
94 |
$RCMAIL->plugins->exec_hook('keep_alive', array()); |
T |
95 |
|
f11541
|
96 |
$OUTPUT->send(); |