summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
Diffstat (limited to 'program')
-rw-r--r--program/js/app.js21
-rw-r--r--program/steps/mail/func.inc17
-rw-r--r--program/steps/mail/pagenav.inc74
-rw-r--r--program/steps/mail/show.inc45
4 files changed, 92 insertions, 65 deletions
diff --git a/program/js/app.js b/program/js/app.js
index 30eaef526..13711ff97 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -210,11 +210,9 @@ function rcube_webmail()
this.enable_command(this.env.message_commands, this.env.uid);
this.enable_command('reply-list', this.env.list_post);
- if (this.env.next_uid) {
- this.enable_command('nextmessage', 'lastmessage', true);
- }
- if (this.env.prev_uid) {
- this.enable_command('previousmessage', 'firstmessage', true);
+ if (this.env.action == 'show') {
+ this.http_request('pagenav', '_uid='+this.env.uid+'&_mbox='+urlencode(this.env.mailbox),
+ this.display_message('', 'loading'));
}
if (this.env.blockedobjects) {
@@ -4595,10 +4593,15 @@ function rcube_webmail()
var date = new Date(),
id = type + date.getTime();
- // The same message of type 'loading' is already displayed
- if (type == 'loading' && this.messages[msg]) {
- this.messages[msg].elements.push(id);
- return id;
+ if (type == 'loading') {
+ if (!msg)
+ msg = this.get_label('loading');
+
+ // The same message of type 'loading' is already displayed
+ if (this.messages[msg]) {
+ this.messages[msg].elements.push(id);
+ return id;
+ }
}
var ref = this,
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 11df12845..1237c9214 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -423,14 +423,16 @@ function rcmail_messagecontent_frame($attrib)
function rcmail_messagecount_display($attrib)
{
- global $IMAP, $OUTPUT;
+ global $RCMAIL;
if (!$attrib['id'])
$attrib['id'] = 'rcmcountdisplay';
- $OUTPUT->add_gui_object('countdisplay', $attrib['id']);
+ $RCMAIL->output->add_gui_object('countdisplay', $attrib['id']);
+
+ $content = $RCMAIL->action != 'show' ? rcmail_get_messagecount_text() : rcube_label('loading');
- return html::span($attrib, rcmail_get_messagecount_text());
+ return html::span($attrib, $content);
}
@@ -495,14 +497,7 @@ function rcmail_quota_content($attrib=NULL)
function rcmail_get_messagecount_text($count=NULL, $page=NULL)
{
- global $RCMAIL, $IMAP, $MESSAGE;
-
- if (isset($MESSAGE->index))
- {
- return rcube_label(array('name' => 'messagenrof',
- 'vars' => array('nr' => $MESSAGE->index+1,
- 'count' => $count!==NULL ? $count : $IMAP->messagecount(NULL, 'ALL')))); // Only messages, no threads here
- }
+ global $RCMAIL, $IMAP;
if ($page===NULL)
$page = $IMAP->list_page;
diff --git a/program/steps/mail/pagenav.inc b/program/steps/mail/pagenav.inc
new file mode 100644
index 000000000..b62520fab
--- /dev/null
+++ b/program/steps/mail/pagenav.inc
@@ -0,0 +1,74 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/mail/pagenav.inc |
+ | |
+ | This file is part of the Roundcube Webmail client |
+ | Copyright (C) 2005-2009, Roundcube Dev. - Switzerland |
+ | Licensed under the GNU GPL |
+ | |
+ | PURPOSE: |
+ | Updates message page navigation controls |
+ | |
+ +-----------------------------------------------------------------------+
+ | Author: Aleksander Machniak <alec@alec.pl> |
+ +-----------------------------------------------------------------------+
+
+ $Id: show.inc 4176 2010-11-04 09:59:55Z alec $
+
+*/
+
+$uid = get_input_value('_uid', RCUBE_INPUT_GET);
+$cnt = $IMAP->messagecount(NULL, 'ALL'); // Only messages, no threads here
+
+if ($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] != 'DESC'
+ && empty($_REQUEST['_search']) && !$CONFIG['skip_deleted'] && !$IMAP->threading
+) {
+ // this assumes that we are sorted by date_DESC
+ $seq = $IMAP->get_id($uid);
+ $index = $cnt - $seq;
+
+ $prev = $IMAP->get_uid($seq + 1);
+ $first = $IMAP->get_uid($cnt);
+ $next = $IMAP->get_uid($seq - 1);
+ $last = $IMAP->get_uid(1);
+}
+else {
+ // Only if we use custom sorting
+ $a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']);
+
+ $index = array_search($IMAP->get_id($uid), $a_msg_index);
+
+ $count = count($a_msg_index);
+ $prev = isset($a_msg_index[$index-1]) ? $IMAP->get_uid($a_msg_index[$index-1]) : -1;
+ $first = $count > 1 ? $IMAP->get_uid($a_msg_index[0]) : -1;
+ $next = isset($a_msg_index[$index+1]) ? $IMAP->get_uid($a_msg_index[$index+1]) : -1;
+ $last = $count > 1 ? $IMAP->get_uid($a_msg_index[$count-1]) : -1;
+}
+
+// Set UIDs and activate navigation buttons
+if ($prev > 0) {
+ $OUTPUT->set_env('prev_uid', $prev);
+ $OUTPUT->command('enable_command', 'previousmessage', 'firstmessage', true);
+}
+if ($next > 0) {
+ $OUTPUT->set_env('next_uid', $next);
+ $OUTPUT->command('enable_command', 'nextmessage', 'lastmessage', true);
+}
+if ($first > 0)
+ $OUTPUT->set_env('first_uid', $first);
+if ($last > 0)
+ $OUTPUT->set_env('last_uid', $last);
+
+// Don't need a real messages count value
+$OUTPUT->set_env('messagecount', 1);
+
+// Set rowcount text
+$OUTPUT->command('set_rowcount', rcube_label(array(
+ 'name' => 'messagenrof',
+ 'vars' => array('nr' => $index+1, 'count' => $cnt)
+)));
+
+$OUTPUT->send();
+
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index 41b4bc614..e660207cd 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -94,51 +94,6 @@ if ($uid = get_input_value('_uid', RCUBE_INPUT_GET)) {
}
}
- // get previous, first, next and last message UID
- if ($RCMAIL->action != 'preview' && $RCMAIL->action != 'print')
- {
- $next = $prev = $first = $last = -1;
-
- if ($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] != 'DESC'
- && empty($_REQUEST['_search']) && !$CONFIG['skip_deleted'] && !$IMAP->threading)
- {
- // this assumes that we are sorted by date_DESC
- $cnt = $IMAP->messagecount();
- $seq = $IMAP->get_id($MESSAGE->uid);
- $MESSAGE->index = $cnt - $seq;
-
- $prev = $IMAP->get_uid($seq + 1);
- $first = $IMAP->get_uid($cnt);
- $next = $IMAP->get_uid($seq - 1);
- $last = $IMAP->get_uid(1);
- }
- else
- {
- // Only if we use custom sorting
- $a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']);
-
- $MESSAGE->index = array_search($IMAP->get_id($MESSAGE->uid), $a_msg_index);
-
- $count = count($a_msg_index);
- $prev = isset($a_msg_index[$MESSAGE->index-1]) ? $IMAP->get_uid($a_msg_index[$MESSAGE->index-1]) : -1;
- $first = $count > 1 ? $IMAP->get_uid($a_msg_index[0]) : -1;
- $next = isset($a_msg_index[$MESSAGE->index+1]) ? $IMAP->get_uid($a_msg_index[$MESSAGE->index+1]) : -1;
- $last = $count > 1 ? $IMAP->get_uid($a_msg_index[$count-1]) : -1;
- }
-
- if ($prev > 0)
- $OUTPUT->set_env('prev_uid', $prev);
- if ($first > 0)
- $OUTPUT->set_env('first_uid', $first);
- if ($next > 0)
- $OUTPUT->set_env('next_uid', $next);
- if ($last > 0)
- $OUTPUT->set_env('last_uid', $last);
-
- // Don't need a real messages count value
- $OUTPUT->set_env('messagecount', 1);
- }
-
if (!$MESSAGE->headers->seen && ($RCMAIL->action == 'show' || ($RCMAIL->action == 'preview' && intval($CONFIG['preview_pane_mark_read']) == 0)))
$RCMAIL->plugins->exec_hook('message_read', array('uid' => $MESSAGE->uid,
'mailbox' => $mbox_name, 'message' => $MESSAGE));