| 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$ |
|---|
| 19 | |
|---|
| 20 | */ |
|---|
| 21 | |
|---|
| 22 | $REMOTE_REQUEST = TRUE; |
|---|
| 23 | $OUTPUT_TYPE = 'js'; |
|---|
| 24 | |
|---|
| 25 | $unseen = $IMAP->messagecount($mbox, 'UNSEEN', !empty($_GET['_refresh']) ? TRUE : FALSE); |
|---|
| 26 | $count = $IMAP->messagecount(); |
|---|
| 27 | |
|---|
| 28 | // is there a sort type for this request? |
|---|
| 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 |
|---|
| 39 | { |
|---|
| 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']; |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | // update message count display |
|---|
| 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(); |
|---|
| 54 | $commands .= sprintf("this.set_unread_count('%s', %d);\n", addslashes($mbox), $unseen); |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | // add message rows |
|---|
| 58 | if ($count) |
|---|
| 59 | { |
|---|
| 60 | $a_headers = $IMAP->list_headers($mbox, null, $sort_col, $sort_order); |
|---|
| 61 | $commands .= rcmail_js_message_list($a_headers); |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | // send response |
|---|
| 66 | rcube_remote_response($commands); |
|---|
| 67 | |
|---|
| 68 | exit; |
|---|
| 69 | ?> |
|---|