4 +-----------------------------------------------------------------------+
5 | program/steps/mail/pagenav.inc |
7 | This file is part of the Roundcube Webmail client |
8 | Copyright (C) 2005-2009, The Roundcube Dev Team |
9 | Licensed under the GNU GPL |
12 | Updates message page navigation controls |
14 +-----------------------------------------------------------------------+
15 | Author: Aleksander Machniak <alec@alec.pl> |
16 +-----------------------------------------------------------------------+
18 $Id: show.inc 4176 2010-11-04 09:59:55Z alec $
22 $uid = get_input_value('_uid', RCUBE_INPUT_GET);
24 // Select mailbox first, for better performance
25 $mbox_name = $IMAP->get_mailbox_name();
26 $IMAP->select_mailbox($mbox_name);
28 // Get messages count (only messages, no threads here)
29 $cnt = $IMAP->messagecount(NULL, 'ALL');
31 if ($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] == 'DESC'
32 && empty($_REQUEST['_search']) && !$CONFIG['skip_deleted'] && !$IMAP->threading
34 // this assumes that we are sorted by date_DESC
35 $seq = $IMAP->get_id($uid);
38 $prev = $IMAP->get_uid($seq + 1);
39 $first = $IMAP->get_uid($cnt);
40 $next = $IMAP->get_uid($seq - 1);
41 $last = $IMAP->get_uid(1);
44 // Only if we use custom sorting
45 $a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']);
47 $index = array_search($IMAP->get_id($uid), $a_msg_index);
49 $count = count($a_msg_index);
50 $prev = isset($a_msg_index[$index-1]) ? $IMAP->get_uid($a_msg_index[$index-1]) : -1;
51 $first = $count > 1 ? $IMAP->get_uid($a_msg_index[0]) : -1;
52 $next = isset($a_msg_index[$index+1]) ? $IMAP->get_uid($a_msg_index[$index+1]) : -1;
53 $last = $count > 1 ? $IMAP->get_uid($a_msg_index[$count-1]) : -1;
56 // Set UIDs and activate navigation buttons
58 $OUTPUT->set_env('prev_uid', $prev);
59 $OUTPUT->command('enable_command', 'previousmessage', 'firstmessage', true);
62 $OUTPUT->set_env('next_uid', $next);
63 $OUTPUT->command('enable_command', 'nextmessage', 'lastmessage', true);
66 $OUTPUT->set_env('first_uid', $first);
68 $OUTPUT->set_env('last_uid', $last);
70 // Don't need a real messages count value
71 $OUTPUT->set_env('messagecount', 1);
74 $OUTPUT->command('set_rowcount', rcube_label(array(
75 'name' => 'messagenrof',
76 'vars' => array('nr' => $index+1, 'count' => $cnt)