| 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-2007, 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 | $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 ($IMAP->messagecount($mbox_name, 'ALL', !empty($_REQUEST['_refresh']))) |
|---|
| 44 | $a_headers = $IMAP->list_headers($mbox_name, NULL, $sort_col, $sort_order); |
|---|
| 45 | |
|---|
| 46 | $count = $IMAP->messagecount($mbox_name); |
|---|
| 47 | $unseen = $IMAP->messagecount($mbox_name, 'UNSEEN', !empty($_REQUEST['_refresh'])); |
|---|
| 48 | |
|---|
| 49 | // update message count display |
|---|
| 50 | $pages = ceil($count/$IMAP->page_size); |
|---|
| 51 | $OUTPUT->set_env('messagecount', $count); |
|---|
| 52 | $OUTPUT->set_env('pagecount', $pages); |
|---|
| 53 | $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count)); |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | // add message rows |
|---|
| 57 | if (isset($a_headers) && count($a_headers)) |
|---|
| 58 | rcmail_js_message_list($a_headers); |
|---|
| 59 | else |
|---|
| 60 | $OUTPUT->show_message('nomessagesfound', 'notice'); |
|---|
| 61 | |
|---|
| 62 | // update mailboxlist |
|---|
| 63 | $OUTPUT->command('set_unread_count', $mbox_name, $unseen, ($mbox_name == 'INBOX')); |
|---|
| 64 | |
|---|
| 65 | // send response |
|---|
| 66 | $OUTPUT->send(); |
|---|
| 67 | |
|---|
| 68 | ?> |
|---|