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