]> git.donarmstrong.com Git - roundcube.git/blob - program/steps/mail/list.inc
Imported Upstream version 0.1~rc1~dfsg
[roundcube.git] / program / steps / mail / list.inc
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, RoundCube Dev. - Switzerland                      |
9  | Licensed under the GNU GPL                                            |
10  |                                                                       |
11  | PURPOSE:                                                              |
12  |   Send message list to client (as remote response)                    |
13  |                                                                       |
14  +-----------------------------------------------------------------------+
15  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16  +-----------------------------------------------------------------------+
17
18  $Id: list.inc 575 2007-05-18 12:35:28Z thomasb $
19
20 */
21
22 $OUTPUT_TYPE = 'js';
23 // is there a sort type for this request?
24 if ($sort = get_input_value('_sort', RCUBE_INPUT_GET))
25 {
26   // yes, so set the sort vars
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;
32 }
33 else
34 {
35   // use session settings if set, defaults if not
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'];
38 }
39
40 $mbox_name = $IMAP->get_mailbox_name();
41
42 // fetch message headers
43 if ($count = $IMAP->messagecount($mbox_name, 'ALL', !empty($_REQUEST['_refresh'])))
44   $a_headers = $IMAP->list_headers($mbox_name, NULL, $sort_col, $sort_order);
45
46 $unseen = $IMAP->messagecount($mbox_name, 'UNSEEN', !empty($_REQUEST['_refresh']));
47
48 // update message count display
49 $pages = ceil($count/$IMAP->page_size);
50 $OUTPUT->set_env('messagecount', $count);
51 $OUTPUT->set_env('pagecount', $pages);
52 $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count));
53
54 // update mailboxlist
55 $OUTPUT->command('set_unread_count', $mbox_name, $unseen);
56
57
58 // add message rows
59 if (isset($a_headers) && count($a_headers))
60   rcmail_js_message_list($a_headers);
61
62   
63 // send response
64 $OUTPUT->send();
65
66 ?>