thomascube
2006-01-13 be2380fb47b05a222ec5b22deff36d5156a8c943
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                     |
8  | Copyright (C) 2005, 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
22 $REMOTE_REQUEST = TRUE;
cd900d 23 $OUTPUT_TYPE = 'js';
4e17e6 24
cd900d 25 $unseen = $IMAP->messagecount($mbox, 'UNSEEN', !empty($_GET['_refresh']) ? TRUE : FALSE);
4e17e6 26 $count = $IMAP->messagecount();
T 27
f3b659 28 // is there a sort type for this request?
T 29 if ($sort = isset($_GET['_sort']) ? $_GET['_sort'] : false)
30   {
31   // yes, so set the sort vars
32   list($sort_col, $sort_order) = explode('_', $sort);
33
34   // set session vars for sort (so next page and task switch know how to sort)
35   $_SESSION['sort_col'] = $sort_col;
36   $_SESSION['sort_order'] = $sort_order;
37   }
38 else
b076a4 39   {        
T 40   // use session settings if set, defaults if not
41   $sort_col   = isset($_SESSION['sort_col'])   ? $_SESSION['sort_col']   : $CONFIG['message_sort_col'];
42   $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
f3b659 43   }
T 44   
45
4e17e6 46 // update message count display
T 47 $pages = ceil($count/$IMAP->page_size);
48 $commands = sprintf("this.set_env('messagecount', %d);\n", $count);
49 $commands .= sprintf("this.set_env('pagecount', %d);\n", $pages);
50 $commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text());
51
52 // update mailboxlist
53 $mbox = $IMAP->get_mailbox_name();
cd900d 54 $commands .= sprintf("this.set_unread_count('%s', %d);\n", addslashes($mbox), $unseen);
4e17e6 55
T 56
57 // add message rows
58 if ($count)
59   {
f3b659 60   $a_headers = $IMAP->list_headers($mbox, null, $sort_col, $sort_order);
4e17e6 61   $commands .= rcmail_js_message_list($a_headers);
T 62   }
63
64   
65 // send response
66 rcube_remote_response($commands);
67
68 exit;
69 ?>