From e70d6ea64e711096af36b1234f8545b870ea5f45 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Sat, 05 Apr 2008 08:49:21 -0400
Subject: [PATCH] Apply changes from trunk to 0.1-stable

---
 program/steps/mail/show.inc |   44 ++++++++++++++++++++++++++++++++------------
 1 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index 45d64b8..27d2660 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -5,7 +5,7 @@
  | program/steps/mail/show.inc                                           |
  |                                                                       |
  | This file is part of the RoundCube Webmail client                     |
- | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 |
+ | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                 |
  | Licensed under the GNU GPL                                            |
  |                                                                       |
  | PURPOSE:                                                              |
@@ -20,6 +20,7 @@
 */
 
 require_once('Mail/mimeDecode.php');
+require_once('lib/rc_mail_mime.inc');
 
 $PRINT_MODE = $_action=='print' ? TRUE : FALSE;
 
@@ -28,6 +29,10 @@
   {
   $MESSAGE = array('UID' => get_input_value('_uid', RCUBE_INPUT_GET));
   $MESSAGE['headers'] = $IMAP->get_headers($MESSAGE['UID']);
+  
+  // set message charset as default
+  if (!empty($MESSAGE['headers']->charset))
+    $IMAP->set_charset($MESSAGE['headers']->charset);
   
   // go back to list if message not found (wrong UID)
   if (!$MESSAGE['headers'])
@@ -41,12 +46,18 @@
       return;
       }
     }
+    
+  // check if safe flag is set
+  if ($MESSAGE['is_safe'] = intval($_GET['_safe']))
+    $_SESSION['safe_messages'][$MESSAGE['UID']] = true;
+  else if ($_SESSION['safe_messages'][$MESSAGE['UID']])
+    $MESSAGE['is_safe'] = 1;
 
   // calculate Etag for this request
-  $etag = md5($MESSAGE['UID'].$IMAP->get_mailbox_name().session_id().($PRINT_MODE?1:0));
+  $etag = md5($MESSAGE['UID'].$IMAP->get_mailbox_name().session_id().intval($MESSAGE['headers']->mdn_sent).intval($MESSAGE['is_safe']).intval($PRINT_MODE));
 
   // allow caching, unless remote images are present
-  if ((bool)get_input_value('_safe', RCUBE_INPUT_GET))
+  if ((bool)$MESSAGE['is_safe'])
     send_nocacheing_headers();
   else if (empty($CONFIG['devel_mode']))
     send_modified_header($_SESSION['login_time'], $etag);
@@ -57,7 +68,7 @@
   if ($MESSAGE['structure'] = $IMAP->get_structure($MESSAGE['UID']))
     list($MESSAGE['parts'], $MESSAGE['attachments']) = rcmail_parse_message(
       $MESSAGE['structure'],
-      array('safe' => intval($_GET['_safe']),
+      array('safe' => $MESSAGE['is_safe'],
             'prefer_html' => $CONFIG['prefer_html'],
             'get_url' => $GET_URL.'&_part=%s')
       );
@@ -71,19 +82,28 @@
 
   // give message uid to the client
   $OUTPUT->set_env('uid', $MESSAGE['UID']);
-  $OUTPUT->set_env('safemode', intval($_GET['_safe']));
+  $OUTPUT->set_env('safemode', $MESSAGE['is_safe']);
   
   // check for unset disposition notification
-  if ($MESSAGE['headers']->mdn_to && !$MESSAGE['headers']->mdn_sent)
+  if ($MESSAGE['headers']->mdn_to && !$MESSAGE['headers']->mdn_sent && $IMAP->get_mailbox_name() != $CONFIG['drafts_mbox'])
   {
-    rcube_add_label('mdnrequest');
-    $OUTPUT->set_env('mdn_request', true);
+    if (intval($CONFIG['mdn_requests']) === 1)
+    {
+      if (rcmail_send_mdn($MESSAGE['UID']))
+        $OUTPUT->show_message('receiptsent', 'confirmation');
+    }
+    else if (empty($CONFIG['mdn_requests']))
+    {
+      rcube_add_label('mdnrequest');
+      $OUTPUT->set_env('mdn_request', true);
+    }
   }
 
-  $next = $prev = -1;
+
+  $next = $prev = $first = $last = -1;
   // get previous, first, next and last message UID
-  if (!($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] == 'DESC') && 
-      $IMAP->get_capability('sort')) 
+  if ((!($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] == 'DESC') &&
+      $IMAP->get_capability('sort')) || !empty($_REQUEST['_search']))
     {
     // Only if we use custom sorting
     $a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']);
@@ -184,4 +204,4 @@
     parse_template('messagepreview');
 else
   parse_template('message');
-?>
\ No newline at end of file
+?>

--
Gitblit v1.9.1