| | |
| | | | program/steps/mail/show.inc | |
| | | | | |
| | | | This file is part of the Roundcube Webmail client | |
| | | | Copyright (C) 2005-2009, Roundcube Dev. - Switzerland | |
| | | | Copyright (C) 2005-2009, The Roundcube Dev Team | |
| | | | Licensed under the GNU GPL | |
| | | | | |
| | | | PURPOSE: | |
| | |
| | | $OUTPUT->set_env('display_next', true); |
| | | if ($MESSAGE->headers->others['list-post']) |
| | | $OUTPUT->set_env('list_post', true); |
| | | if ($CONFIG['forward_attachment']) |
| | | $OUTPUT->set_env('forward_attachment', true); |
| | | |
| | | if (!$OUTPUT->ajax_call) |
| | | $OUTPUT->add_label('checkingmail', 'deletemessage', 'movemessagetotrash', |
| | |
| | | $OUTPUT->set_env('mdn_request', true); |
| | | } |
| | | } |
| | | |
| | | // 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, |
| | |
| | | if ($MESSAGE && $MESSAGE->headers && !$MESSAGE->headers->seen && |
| | | ($RCMAIL->action == 'show' || ($RCMAIL->action == 'preview' && intval($CONFIG['preview_pane_mark_read']) == 0))) |
| | | { |
| | | if ($IMAP->set_flag($MESSAGE->uid, 'SEEN') && $_SESSION['unseen_count'][$mbox_name]) |
| | | $_SESSION['unseen_count'][$mbox_name] -= 1; |
| | | if ($IMAP->set_flag($MESSAGE->uid, 'SEEN')) { |
| | | if ($count = rcmail_get_unseen_count($mbox_name)) { |
| | | rcmail_set_unseen_count($mbox_name, $count - 1); |
| | | } |
| | | } |
| | | } |
| | | |
| | | exit; |