From f1114237556d32bb217c5dcbb0aa7db2d081608b Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 15 Mar 2013 05:41:09 -0400
Subject: [PATCH] Fix storing 'safe' flag on a message. The key for session value should include folder name. A message with the same UID may exist in another folder.

---
 program/lib/Roundcube/rcube_message.php |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/program/lib/Roundcube/rcube_message.php b/program/lib/Roundcube/rcube_message.php
index 7d58a8e..42d7b9b 100644
--- a/program/lib/Roundcube/rcube_message.php
+++ b/program/lib/Roundcube/rcube_message.php
@@ -93,7 +93,7 @@
         $this->subject = $this->mime->decode_mime_string($this->headers->subject);
         list(, $this->sender) = each($this->mime->decode_address_list($this->headers->from, 1));
 
-        $this->set_safe((intval($_GET['_safe']) || $_SESSION['safe_messages'][$uid]));
+        $this->set_safe((intval($_GET['_safe']) || $_SESSION['safe_messages'][$this->folder.':'.$uid]));
         $this->opt = array(
             'safe' => $this->is_safe,
             'prefer_html' => $this->app->config->get('prefer_html'),
@@ -144,8 +144,7 @@
      */
     public function set_safe($safe = true)
     {
-        $this->is_safe = $safe;
-        $_SESSION['safe_messages'][$this->uid] = $this->is_safe;
+        $_SESSION['safe_messages'][$this->folder.':'.$this->uid] = $this->is_safe = $safe;
     }
 
 
@@ -206,10 +205,10 @@
     function has_html_part($enriched = false)
     {
         // check all message parts
-        foreach ($this->parts as $part) {
+        foreach ($this->mime_parts as $part) {
             if ($part->mimetype == 'text/html' || ($enriched && $part->mimetype == 'text/enriched')) {
-                // Skip if part is an attachment
-                if ($this->is_attachment($part)) {
+                // Skip if part is an attachment, don't use is_attachment() here
+                if ($part->filename) {
                     continue;
                 }
 
@@ -246,10 +245,10 @@
     function has_text_part()
     {
         // check all message parts
-        foreach ($this->parts as $part) {
+        foreach ($this->mime_parts as $part) {
             if ($part->mimetype == 'text/plain') {
-                // Skip if part is an attachment
-                if ($this->is_attachment($part)) {
+                // Skip if part is an attachment, don't use is_attachment() here
+                if ($part->filename) {
                     continue;
                 }
 

--
Gitblit v1.9.1