From 330a10b95294bcc082b880f30d9548891d63a1b0 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Tue, 15 Jun 2010 06:15:41 -0400
Subject: [PATCH] - remove debug code

---
 program/steps/mail/func.inc |   45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 44 insertions(+), 1 deletions(-)

diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index d1850d6..a63b509 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -964,6 +964,11 @@
         if (!isset($part->body))
           $part->body = $MESSAGE->get_part_content($part->mime_id);
 
+        // message is cached but not exists (#1485443), or other error
+        if ($part->body === false) {
+          rcmail_message_error($MESSAGE->uid);
+        }
+
         // re-format format=flowed content
         if ($part->ctype_secondary == "plain" && $part->ctype_parameters['format'] == "flowed")
           $part->body = rcube_message::unfold_flowed($part->body);
@@ -1473,7 +1478,7 @@
 
     // compose headers array
     $headers = array(
-      'Date' => date('r'),
+      'Date' => rcmail_user_date(),
       'From' => $sender,
       'To'   => $message->headers->mdn_to,
       'Subject' => rcube_label('receiptread') . ': ' . $message->subject,
@@ -1518,6 +1523,29 @@
   return false;
 }
 
+// Returns RFC2822 formatted current date in user's timezone
+function rcmail_user_date()
+{
+  global $CONFIG;
+
+  // get user's timezone
+  if ($CONFIG['timezone'] === 'auto') {
+    $tz = isset($_SESSION['timezone']) ? $_SESSION['timezone'] : date('Z')/3600;
+  }
+  else {
+    $tz = $CONFIG['timezone'];
+    if ($CONFIG['dst_active'])
+      $tz++;
+  }
+
+  $date = time() + $tz * 60 * 60;
+  $date = gmdate('r', $date);
+  $date = preg_replace('/[+-][0-9]{4}$/', sprintf('%+05d', $tz * 100), $date);
+
+  return $date;
+}
+
+
 function rcmail_search_filter($attrib)
 {
   global $OUTPUT, $CONFIG;
@@ -1550,6 +1578,21 @@
   return $out;
 }
 
+function rcmail_message_error($uid=null)
+{
+  global $RCMAIL;
+
+  // Set env variables for messageerror.html template
+  if ($RCMAIL->action == 'show') {
+    $mbox_name = $RCMAIL->imap->get_mailbox_name();
+    $RCMAIL->output->set_env('mailbox', $mbox_name);
+    $RCMAIL->output->set_env('uid', null);
+  }
+  // display error message
+  $RCMAIL->output->show_message('messageopenerror', 'error');
+  // ... display message error page
+  $RCMAIL->output->send('messageerror');
+}
 
 // register UI objects
 $OUTPUT->add_handlers(array(

--
Gitblit v1.9.1