source: subversion/branches/devel-threads/program/steps/mail/list.inc @ 3120

Last change on this file since 3120 was 3120, checked in by alec, 4 years ago
  • use underlined subject only if thread is collapsed
  • remove index_sort from settings
  • move some functions in app.js into matching sections
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
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
22if (!$OUTPUT->ajax_call) {
23  return;
24}
25
26// is there a sort type for this request?
27if ($sort = get_input_value('_sort', RCUBE_INPUT_GET))
28{
29  // yes, so set the sort vars
30  list($sort_col, $sort_order) = explode('_', $sort);
31
32  // set session vars for sort (so next page and task switch know how to sort)
33  $save_arr = array();
34  $_SESSION['sort_col'] = $save_arr['message_sort_col'] = $sort_col;
35  $_SESSION['sort_order'] = $save_arr['message_sort_order'] = $sort_order;
36 
37  $RCMAIL->user->save_prefs($save_arr);
38}
39else
40{
41  // use session settings if set, defaults if not
42  $sort_col   = isset($_SESSION['sort_col'])   ? $_SESSION['sort_col']   : $CONFIG['message_sort_col'];
43  $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
44}
45
46$mbox_name = $IMAP->get_mailbox_name();
47
48// initialize searching result if search_filter is used
49if ($_SESSION['search_filter'] && $_SESSION['search_filter'] != 'ALL')
50{
51  $search_request = md5($mbox_name.$_SESSION['search_filter']);
52  $IMAP->search($mbox_name, $_SESSION['search_filter'], RCMAIL_CHARSET, $sort_col);
53  $_SESSION['search'][$search_request] = $IMAP->get_search_set();
54  $OUTPUT->set_env('search_request', $search_request);
55}
56
57// fetch message headers
58if ($count = $IMAP->messagecount($mbox_name, $IMAP->threading ? 'THREADS' : 'ALL', !empty($_REQUEST['_refresh'])))
59  $a_headers = $IMAP->list_headers($mbox_name, NULL, $sort_col, $sort_order);
60
61// update mailboxlist
62rcmail_send_unread_count($mbox_name, !empty($_REQUEST['_refresh']));
63
64// update message count display
65$pages = ceil($count/$IMAP->page_size);
66$OUTPUT->set_env('messagecount', $count);
67$OUTPUT->set_env('pagecount', $pages);
68$OUTPUT->set_env('threading', (bool) $IMAP->threading);
69$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count));
70$OUTPUT->command('set_mailboxname', rcmail_get_mailbox_name_text());
71
72// add message rows
73if (isset($a_headers) && count($a_headers))
74{
75  rcmail_js_message_list($a_headers);
76  if ($search_request)
77    $OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $count));
78}
79else if ($search_request)
80  $OUTPUT->show_message('searchnomatch', 'notice');
81else
82  $OUTPUT->show_message('nomessagesfound', 'notice');
83
84// deal with threaded view
85if ($IMAP->threading) {
86  switch ($RCMAIL->config->get('autoexpand_threads')) {
87    case 2:
88      $OUTPUT->command('expand_unread');
89      break;
90    case 1:
91      $OUTPUT->command('message_list.expand_all');
92      break;
93    case 0:
94    default:
95      break;
96  }
97}
98
99// send response
100$OUTPUT->send();
101
102?>
Note: See TracBrowser for help on using the repository browser.