Mercurial > hg > rc2
annotate program/steps/mail/list.inc @ 8:bf99236cc5cd default tip
try to recover from upgrade fail
author | Charlie Root |
---|---|
date | Sat, 29 Dec 2018 07:07:34 -0500 |
parents | 1ab920879b88 |
children |
rev | line source |
---|---|
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']))) { | |
3 | 70 $sort_col = rcmail_sort_column(); |
4
1ab920879b88
do date sort if sorting on dates, to get sub-threads in date order. See also thunderbird-labels.php:407 et seq.
Charlie Root
parents:
3
diff
changeset
|
71 $a_headers = $RCMAIL->storage->list_messages($mbox_name, NULL,($sort_col == 'dates')? 'date' : $sort_col , rcmail_sort_order()); |
0 | 72 } |
3 | 73 #rcube::write_log('mail',"list fetch: $count ".count($a_headers)); |
0 | 74 // update search set (possible change of threading mode) |
75 if (!empty($_REQUEST['_search']) && isset($_SESSION['search']) | |
76 && $_SESSION['search_request'] == $_REQUEST['_search'] | |
77 ) { | |
78 $search_request = $_REQUEST['_search']; | |
79 $_SESSION['search'] = $RCMAIL->storage->get_search_set(); | |
80 } | |
81 // remove old search data | |
82 else if (empty($_REQUEST['_search']) && isset($_SESSION['search'])) { | |
83 $RCMAIL->session->remove('search'); | |
84 } | |
85 | |
86 rcmail_list_pagetitle(); | |
87 | |
88 // update mailboxlist | |
89 if (empty($search_request)) { | |
90 rcmail_send_unread_count($mbox_name, !empty($_REQUEST['_refresh']), empty($a_headers) ? 0 : null); | |
91 } | |
92 | |
93 // update message count display | |
94 $pages = ceil($count/$RCMAIL->storage->get_pagesize()); | |
95 $page = $count ? $RCMAIL->storage->get_page() : 1; | |
96 $exists = $RCMAIL->storage->count($mbox_name, 'EXISTS', true); | |
97 | |
98 $OUTPUT->set_env('messagecount', $count); | |
99 $OUTPUT->set_env('pagecount', $pages); | |
100 $OUTPUT->set_env('threading', $threading); | |
101 $OUTPUT->set_env('current_page', $page); | |
102 $OUTPUT->set_env('exists', $exists); | |
103 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count), $mbox_name); | |
104 | |
105 // remove old message rows if commanded by the client | |
106 if (!empty($_REQUEST['_clear'])) { | |
107 $OUTPUT->command('clear_message_list'); | |
108 } | |
109 | |
110 // add message rows | |
111 rcmail_js_message_list($a_headers, false, $cols); | |
112 | |
113 if (isset($a_headers) && count($a_headers)) { | |
114 if ($search_request) { | |
115 $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count)); | |
116 } | |
117 | |
118 // remember last HIGHESTMODSEQ value (if supported) | |
119 // we need it for flag updates in check-recent | |
120 $data = $RCMAIL->storage->folder_data($mbox_name); | |
121 if (!empty($data['HIGHESTMODSEQ'])) { | |
122 $_SESSION['list_mod_seq'] = $data['HIGHESTMODSEQ']; | |
123 } | |
124 } | |
125 else { | |
126 // handle IMAP errors (e.g. #1486905) | |
127 if ($err_code = $RCMAIL->storage->get_error_code()) { | |
128 $RCMAIL->display_server_error(); | |
129 } | |
130 else if ($search_request) { | |
131 $OUTPUT->show_message('searchnomatch', 'notice'); | |
132 } | |
133 else { | |
134 $OUTPUT->show_message('nomessagesfound', 'notice'); | |
135 } | |
136 } | |
137 | |
138 // set trash folder state | |
139 if ($mbox_name === $RCMAIL->config->get('trash_mbox')) { | |
140 $OUTPUT->command('set_trash_count', $exists); | |
141 } | |
142 | |
143 if ($page == 1) { | |
144 $OUTPUT->command('set_quota', $RCMAIL->quota_content(null, $multifolder ? 'INBOX' : $mbox_name)); | |
145 } | |
146 | |
147 // send response | |
148 $OUTPUT->send(); |