4 +-----------------------------------------------------------------------+
5 | program/steps/mail/list.inc |
7 | This file is part of the RoundCube Webmail client |
8 | Copyright (C) 2005, RoundCube Dev. - Switzerland |
9 | Licensed under the GNU GPL |
12 | Send message list to client (as remote response) |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
18 $Id: list.inc 232 2006-05-18 15:46:50Z cmcnulty $
22 $REMOTE_REQUEST = TRUE;
25 $sort = isset($_GET['_sort']) ? $_GET['_sort'] : false;
27 // is there a sort type for this request?
30 // yes, so set the sort vars
31 list($sort_col, $sort_order) = explode('_', $sort);
33 // set session vars for sort (so next page and task switch know how to sort)
34 $_SESSION['sort_col'] = $sort_col;
35 $_SESSION['sort_order'] = $sort_order;
39 // use session settings if set, defaults if not
40 $sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col'];
41 $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
45 // we have a saved search request
46 if (!empty($_GET['_search']) && isset($_SESSION['search'][$_GET['_search']]))
48 $a_msgs = split(',', $_SESSION['search'][$_GET['_search']]);
49 $a_headers = $IMAP->list_header_set($mbox_name, $a_msgs, NULL, $sort_col, $sort_order);
50 $count = count($a_msgs);
54 if ($count = $IMAP->messagecount())
55 $a_headers = $IMAP->list_headers($mbox_name, NULL, $sort_col, $sort_order);
58 $unseen = $IMAP->messagecount($mbox_name, 'UNSEEN', !empty($_GET['_refresh']) ? TRUE : FALSE);
60 // update message count display
61 $pages = ceil($count/$IMAP->page_size);
62 $commands = sprintf("this.set_env('messagecount', %d);\n", $count);
63 $commands .= sprintf("this.set_env('pagecount', %d);\n", $pages);
64 $commands .= sprintf("this.set_rowcount('%s');\n", rcmail_get_messagecount_text($count));
67 $mbox_name = $IMAP->get_mailbox_name();
68 $commands .= sprintf("this.set_unread_count('%s', %d);\n", addslashes($mbox_name), $unseen);
72 if (isset($a_headers) && count($a_headers))
73 $commands .= rcmail_js_message_list($a_headers);
77 rcube_remote_response($commands);