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) { |
609d39
|
37 |
$is_current = $mbox_name == $current; |
A |
38 |
if ($is_current) { |
|
39 |
// Synchronize mailbox cache, handle flag changes |
|
40 |
$IMAP->mailbox_sync($mbox_name); |
|
41 |
} |
|
42 |
|
|
43 |
// Get mailbox status |
47672b
|
44 |
$status = $IMAP->mailbox_status($mbox_name); |
c8c1e0
|
45 |
|
47672b
|
46 |
if ($status & 1) { |
T |
47 |
// trigger plugin hook |
609d39
|
48 |
$RCMAIL->plugins->exec_hook('new_messages', |
A |
49 |
array('mailbox' => $mbox_name, 'is_current' => $is_current)); |
47672b
|
50 |
} |
c8c1e0
|
51 |
|
636bd7
|
52 |
rcmail_send_unread_count($mbox_name, true, null, |
A |
53 |
(!$is_current && ($status & 1)) ? 'recent' : ''); |
47672b
|
54 |
|
609d39
|
55 |
if ($status && $is_current) { |
488074
|
56 |
// refresh saved search set |
A |
57 |
$search_request = get_input_value('_search', RCUBE_INPUT_GPC); |
f6aac3
|
58 |
if ($search_request && isset($_SESSION['search']) |
A |
59 |
&& $_SESSION['search_request'] == $search_request |
|
60 |
) { |
|
61 |
$_SESSION['search'] = $IMAP->refresh_search(); |
f52c93
|
62 |
} |
488074
|
63 |
|
A |
64 |
if (!empty($_GET['_quota'])) |
|
65 |
$OUTPUT->command('set_quota', rcmail_quota_content()); |
|
66 |
|
|
67 |
// "No-list" mode, don't get messages |
|
68 |
if (empty($_GET['_list'])) |
|
69 |
continue; |
|
70 |
|
|
71 |
// get overall message count; allow caching because rcube_imap::mailbox_status() did a refresh |
|
72 |
$all_count = $IMAP->messagecount(null, $IMAP->threading ? 'THREADS' : 'ALL'); |
|
73 |
|
|
74 |
// check current page if we're not on the first page |
|
75 |
if ($all_count && $IMAP->list_page > 1) { |
|
76 |
$remaining = $all_count - $IMAP->page_size * ($IMAP->list_page - 1); |
|
77 |
if ($remaining <= 0) { |
|
78 |
$IMAP->set_page($IMAP->list_page-1); |
|
79 |
$_SESSION['page'] = $IMAP->list_page; |
|
80 |
} |
|
81 |
} |
|
82 |
|
|
83 |
$OUTPUT->set_env('messagecount', $all_count); |
|
84 |
$OUTPUT->set_env('pagecount', ceil($all_count/$IMAP->page_size)); |
bba252
|
85 |
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($all_count), $mbox_name); |
488074
|
86 |
$OUTPUT->set_env('current_page', $all_count ? $IMAP->list_page : 1); |
A |
87 |
|
|
88 |
// remove old rows (and clear selection if new list is empty) |
|
89 |
$OUTPUT->command('message_list.clear', $all_count ? false : true); |
|
90 |
|
|
91 |
if ($all_count) { |
|
92 |
$a_headers = $IMAP->list_headers($mbox_name, null, $_SESSION['sort_col'], $_SESSION['sort_order']); |
|
93 |
// add message rows |
e99d21
|
94 |
rcmail_js_message_list($a_headers, false); |
488074
|
95 |
// remove messages that don't exists from list selection array |
A |
96 |
$OUTPUT->command('update_selection'); |
|
97 |
} |
78925f
|
98 |
} |
2fd975
|
99 |
} |
15a9d1
|
100 |
|
06c01d
|
101 |
$RCMAIL->plugins->exec_hook('keep_alive', array()); |
T |
102 |
|
f11541
|
103 |
$OUTPUT->send(); |