thomascube
2008-09-18 7dfb1fba5001299300736e6b5d95d9400575e3e7
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
f3b659 22 // is there a sort type for this request?
b3ce79 23 if ($sort = get_input_value('_sort', RCUBE_INPUT_GET))
f11541 24 {
f3b659 25   // yes, so set the sort vars
T 26   list($sort_col, $sort_order) = explode('_', $sort);
27
28   // set session vars for sort (so next page and task switch know how to sort)
94e4be 29   $save_arr = array();
T 30   $_SESSION['sort_col'] = $save_arr['message_sort_col'] = $sort_col;
31   $_SESSION['sort_order'] = $save_arr['message_sort_order'] = $sort_order;
32   
33   $RCMAIL->user->save_prefs($save_arr);
f11541 34 }
f3b659 35 else
f11541 36 {
b076a4 37   // use session settings if set, defaults if not
T 38   $sort_col   = isset($_SESSION['sort_col'])   ? $_SESSION['sort_col']   : $CONFIG['message_sort_col'];
39   $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
f11541 40 }
4647e1 41
06895c 42 $mbox_name = $IMAP->get_mailbox_name();
04c618 43
T 44 // fetch message headers
110748 45 if ($IMAP->messagecount($mbox_name, 'ALL', !empty($_REQUEST['_refresh'])))
04c618 46   $a_headers = $IMAP->list_headers($mbox_name, NULL, $sort_col, $sort_order);
4647e1 47
110748 48 $count = $IMAP->messagecount($mbox_name);
06895c 49 $unseen = $IMAP->messagecount($mbox_name, 'UNSEEN', !empty($_REQUEST['_refresh']));
f3b659 50
4e17e6 51 // update message count display
T 52 $pages = ceil($count/$IMAP->page_size);
f11541 53 $OUTPUT->set_env('messagecount', $count);
T 54 $OUTPUT->set_env('pagecount', $pages);
55 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count));
ac5d15 56 $OUTPUT->command('set_mailboxname', rcmail_get_mailbox_name_text());
T 57
4e17e6 58
T 59
60 // add message rows
4647e1 61 if (isset($a_headers) && count($a_headers))
f11541 62   rcmail_js_message_list($a_headers);
5eee00 63 else
T 64   $OUTPUT->show_message('nomessagesfound', 'notice');
4e17e6 65   
cf1f0f 66 // update mailboxlist
T 67 $OUTPUT->command('set_unread_count', $mbox_name, $unseen, ($mbox_name == 'INBOX'));
68
4e17e6 69 // send response
f11541 70 $OUTPUT->send();
4e17e6 71
5349b7 72 ?>