0
|
1 <?php
|
|
2
|
|
3 /**
|
|
4 +-----------------------------------------------------------------------+
|
|
5 | program/steps/mail/list.inc |
|
|
6 | |
|
|
7 | This file is part of the Roundcube Webmail client |
|
|
8 | Copyright (C) 2005-2014, 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 | Send message list to client (as remote response) |
|
|
16 | |
|
|
17 +-----------------------------------------------------------------------+
|
|
18 | Author: Thomas Bruederli <roundcube@gmail.com> |
|
|
19 +-----------------------------------------------------------------------+
|
|
20 */
|
|
21
|
|
22 if (!$OUTPUT->ajax_call) {
|
|
23 return;
|
|
24 }
|
|
25
|
|
26 $save_arr = array();
|
|
27 $dont_override = (array) $RCMAIL->config->get('dont_override');
|
|
28
|
|
29 // is there a sort type for this request?
|
|
30 if ($sort = rcube_utils::get_input_value('_sort', rcube_utils::INPUT_GET)) {
|
|
31 // yes, so set the sort vars
|
|
32 list($sort_col, $sort_order) = explode('_', $sort);
|
|
33
|
|
34 // set session vars for sort (so next page and task switch know how to sort)
|
|
35 if (!in_array('message_sort_col', $dont_override)) {
|
|
36 $_SESSION['sort_col'] = $save_arr['message_sort_col'] = $sort_col;
|
|
37 }
|
|
38 if (!in_array('message_sort_order', $dont_override)) {
|
|
39 $_SESSION['sort_order'] = $save_arr['message_sort_order'] = $sort_order;
|
|
40 }
|
|
41 }
|
|
42
|
|
43 // register layout change
|
|
44 if ($layout = rcube_utils::get_input_value('_layout', rcube_utils::INPUT_GET)) {
|
|
45 $OUTPUT->set_env('layout', $layout);
|
|
46 $save_arr['layout'] = $layout;
|
|
47 // force header replace on layout change
|
|
48 $cols = $_SESSION['list_attrib']['columns'];
|
|
49 }
|
|
50 // is there a set of columns for this request?
|
|
51 else if ($cols = rcube_utils::get_input_value('_cols', rcube_utils::INPUT_GET)) {
|
|
52 $_SESSION['list_attrib']['columns'] = explode(',', $cols);
|
|
53 if (!in_array('list_cols', $dont_override)) {
|
|
54 $save_arr['list_cols'] = explode(',', $cols);
|
|
55 }
|
|
56 }
|
|
57
|
|
58 if (!empty($save_arr)) {
|
|
59 $RCMAIL->user->save_prefs($save_arr);
|
|
60 }
|
|
61
|
|
62 $mbox_name = $RCMAIL->storage->get_folder();
|
|
63 $threading = (bool) $RCMAIL->storage->get_threading();
|
|
64
|
|
65 // Synchronize mailbox cache, handle flag changes
|
|
66 $RCMAIL->storage->folder_sync($mbox_name);
|
|
67
|
|
68 // fetch message headers
|
|
69 if ($count = $RCMAIL->storage->count($mbox_name, $threading ? 'THREADS' : 'ALL', !empty($_REQUEST['_refresh']))) {
|
|
70 $a_headers = $RCMAIL->storage->list_messages($mbox_name, NULL, rcmail_sort_column(), rcmail_sort_order());
|
|
71 }
|
|
72
|
|
73 // update search set (possible change of threading mode)
|
|
74 if (!empty($_REQUEST['_search']) && isset($_SESSION['search'])
|
|
75 && $_SESSION['search_request'] == $_REQUEST['_search']
|
|
76 ) {
|
|
77 $search_request = $_REQUEST['_search'];
|
|
78 $_SESSION['search'] = $RCMAIL->storage->get_search_set();
|
|
79 }
|
|
80 // remove old search data
|
|
81 else if (empty($_REQUEST['_search']) && isset($_SESSION['search'])) {
|
|
82 $RCMAIL->session->remove('search');
|
|
83 }
|
|
84
|
|
85 rcmail_list_pagetitle();
|
|
86
|
|
87 // update mailboxlist
|
|
88 if (empty($search_request)) {
|
|
89 rcmail_send_unread_count($mbox_name, !empty($_REQUEST['_refresh']), empty($a_headers) ? 0 : null);
|
|
90 }
|
|
91
|
|
92 // update message count display
|
|
93 $pages = ceil($count/$RCMAIL->storage->get_pagesize());
|
|
94 $page = $count ? $RCMAIL->storage->get_page() : 1;
|
|
95 $exists = $RCMAIL->storage->count($mbox_name, 'EXISTS', true);
|
|
96
|
|
97 $OUTPUT->set_env('messagecount', $count);
|
|
98 $OUTPUT->set_env('pagecount', $pages);
|
|
99 $OUTPUT->set_env('threading', $threading);
|
|
100 $OUTPUT->set_env('current_page', $page);
|
|
101 $OUTPUT->set_env('exists', $exists);
|
|
102 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count), $mbox_name);
|
|
103
|
|
104 // remove old message rows if commanded by the client
|
|
105 if (!empty($_REQUEST['_clear'])) {
|
|
106 $OUTPUT->command('clear_message_list');
|
|
107 }
|
|
108
|
|
109 // add message rows
|
|
110 rcmail_js_message_list($a_headers, false, $cols);
|
|
111
|
|
112 if (isset($a_headers) && count($a_headers)) {
|
|
113 if ($search_request) {
|
|
114 $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count));
|
|
115 }
|
|
116
|
|
117 // remember last HIGHESTMODSEQ value (if supported)
|
|
118 // we need it for flag updates in check-recent
|
|
119 $data = $RCMAIL->storage->folder_data($mbox_name);
|
|
120 if (!empty($data['HIGHESTMODSEQ'])) {
|
|
121 $_SESSION['list_mod_seq'] = $data['HIGHESTMODSEQ'];
|
|
122 }
|
|
123 }
|
|
124 else {
|
|
125 // handle IMAP errors (e.g. #1486905)
|
|
126 if ($err_code = $RCMAIL->storage->get_error_code()) {
|
|
127 $RCMAIL->display_server_error();
|
|
128 }
|
|
129 else if ($search_request) {
|
|
130 $OUTPUT->show_message('searchnomatch', 'notice');
|
|
131 }
|
|
132 else {
|
|
133 $OUTPUT->show_message('nomessagesfound', 'notice');
|
|
134 }
|
|
135 }
|
|
136
|
|
137 // set trash folder state
|
|
138 if ($mbox_name === $RCMAIL->config->get('trash_mbox')) {
|
|
139 $OUTPUT->command('set_trash_count', $exists);
|
|
140 }
|
|
141
|
|
142 if ($page == 1) {
|
|
143 $OUTPUT->command('set_quota', $RCMAIL->quota_content(null, $multifolder ? 'INBOX' : $mbox_name));
|
|
144 }
|
|
145
|
|
146 // send response
|
|
147 $OUTPUT->send();
|