alecpl
2010-03-18 15e00bdf5002844841cc76e4d699157a475b0211
commit | author | age
4e17e6 1 <?php
T 2
3 /*
4  +-----------------------------------------------------------------------+
5  | program/steps/mail/list.inc                                           |
6  |                                                                       |
7  | This file is part of the RoundCube Webmail client                     |
5349b7 8  | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 |
30233b 9  | Licensed under the GNU GPL                                            |
4e17e6 10  |                                                                       |
T 11  | PURPOSE:                                                              |
12  |   Send message list to client (as remote response)                    |
13  |                                                                       |
14  +-----------------------------------------------------------------------+
15  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16  +-----------------------------------------------------------------------+
17
18  $Id$
19
20 */
21
6491ed 22 if (!$OUTPUT->ajax_call) {
A 23   return;
24 }
25
f3b659 26 // is there a sort type for this request?
b3ce79 27 if ($sort = get_input_value('_sort', RCUBE_INPUT_GET))
f11541 28 {
f3b659 29   // yes, so set the sort vars
T 30   list($sort_col, $sort_order) = explode('_', $sort);
31
32   // set session vars for sort (so next page and task switch know how to sort)
94e4be 33   $save_arr = array();
T 34   $_SESSION['sort_col'] = $save_arr['message_sort_col'] = $sort_col;
35   $_SESSION['sort_order'] = $save_arr['message_sort_order'] = $sort_order;
f11541 36 }
f3b659 37 else
f11541 38 {
b076a4 39   // use session settings if set, defaults if not
T 40   $sort_col   = isset($_SESSION['sort_col'])   ? $_SESSION['sort_col']   : $CONFIG['message_sort_col'];
41   $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
f11541 42 }
f52c93 43
T 44 // is there a set of columns for this request?
45 if ($cols = get_input_value('_cols', RCUBE_INPUT_GET))
46 {
47   $save_arr = array();
48   $_SESSION['list_columns'] = $save_arr['list_cols'] = explode(',', $cols);
49 }
50
51 if ($save_arr)  
52   $RCMAIL->user->save_prefs($save_arr);
4647e1 53
06895c 54 $mbox_name = $IMAP->get_mailbox_name();
04c618 55
e538b3 56 // initialize searching result if search_filter is used
A 57 if ($_SESSION['search_filter'] && $_SESSION['search_filter'] != 'ALL')
58 {
59   $search_request = md5($mbox_name.$_SESSION['search_filter']);
60   $IMAP->search($mbox_name, $_SESSION['search_filter'], RCMAIL_CHARSET, $sort_col);
61   $_SESSION['search'][$search_request] = $IMAP->get_search_set();
62   $OUTPUT->set_env('search_request', $search_request);
63 }
64
04c618 65 // fetch message headers
f52c93 66 if ($count = $IMAP->messagecount($mbox_name, $IMAP->threading ? 'THREADS' : 'ALL', !empty($_REQUEST['_refresh'])))
04c618 67   $a_headers = $IMAP->list_headers($mbox_name, NULL, $sort_col, $sort_order);
f52c93 68
T 69 // update search set (possible change of threading mode)
70 if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']]))
71   $_SESSION['search'][$_REQUEST['_search']] = $IMAP->get_search_set();
4647e1 72
cbeea3 73 // update mailboxlist
A 74 rcmail_send_unread_count($mbox_name, !empty($_REQUEST['_refresh']));
f3b659 75
4e17e6 76 // update message count display
T 77 $pages = ceil($count/$IMAP->page_size);
f11541 78 $OUTPUT->set_env('messagecount', $count);
T 79 $OUTPUT->set_env('pagecount', $pages);
f52c93 80 $OUTPUT->set_env('threading', (bool) $IMAP->threading);
f11541 81 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count));
ac5d15 82 $OUTPUT->command('set_mailboxname', rcmail_get_mailbox_name_text());
4e17e6 83
T 84 // add message rows
f52c93 85 rcmail_js_message_list($a_headers, FALSE, TRUE, (bool) $cols);
4647e1 86 if (isset($a_headers) && count($a_headers))
3414c5 87 {
A 88   if ($search_request)
89     $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count));
90 }
91 else if ($search_request)
92   $OUTPUT->show_message('searchnomatch', 'notice');
5eee00 93 else
T 94   $OUTPUT->show_message('nomessagesfound', 'notice');
cf1f0f 95
4e17e6 96 // send response
f11541 97 $OUTPUT->send();
4e17e6 98
5349b7 99 ?>