svncommit
2007-10-15 97a656643866f16289264954be961aa3f314ac20
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
06895c 43 if ($count = $IMAP->messagecount($mbox_name, 'ALL', !empty($_REQUEST['_refresh'])))
04c618 44   $a_headers = $IMAP->list_headers($mbox_name, NULL, $sort_col, $sort_order);
4647e1 45
06895c 46 $unseen = $IMAP->messagecount($mbox_name, 'UNSEEN', !empty($_REQUEST['_refresh']));
f3b659 47
4e17e6 48 // update message count display
T 49 $pages = ceil($count/$IMAP->page_size);
f11541 50 $OUTPUT->set_env('messagecount', $count);
T 51 $OUTPUT->set_env('pagecount', $pages);
52 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count));
4e17e6 53
T 54 // update mailboxlist
06895c 55 $OUTPUT->command('set_unread_count', $mbox_name, $unseen);
4e17e6 56
T 57
58 // add message rows
4647e1 59 if (isset($a_headers) && count($a_headers))
f11541 60   rcmail_js_message_list($a_headers);
5eee00 61 else
T 62   $OUTPUT->show_message('nomessagesfound', 'notice');
4e17e6 63   
T 64 // send response
f11541 65 $OUTPUT->send();
4e17e6 66
5349b7 67 ?>