From 0b36d151572e050b51d82e7429fee847ebb33e22 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Thu, 20 Nov 2014 06:03:22 -0500
Subject: [PATCH] Add method to display operation (uploading) progress in UI message

---
 program/lib/Roundcube/rcube_imap_cache.php |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/program/lib/Roundcube/rcube_imap_cache.php b/program/lib/Roundcube/rcube_imap_cache.php
index 5191321..81df076 100644
--- a/program/lib/Roundcube/rcube_imap_cache.php
+++ b/program/lib/Roundcube/rcube_imap_cache.php
@@ -562,6 +562,8 @@
             }
         }
 
+        $binary_check = $this->db->db_provider == 'oracle' ? "BITAND(`flags`, %d)" : "(`flags` & %d)";
+
         $this->db->query(
             "UPDATE {$this->messages_table}"
             ." SET `expires` = ". ($this->ttl ? $this->db->now($this->ttl) : 'NULL')
@@ -569,7 +571,7 @@
             ." WHERE `user_id` = ?"
                 ." AND `mailbox` = ?"
                 .(!empty($uids) ? " AND `uid` IN (".$this->db->array2list($uids, 'integer').")" : "")
-                ." AND (`flags` & $idx) ".($enabled ? "= 0" : "= $idx"),
+                ." AND " . sprintf($binary_check, $idx) . ($enabled ? " = 0" : " = $idx"),
             $this->userid, $mailbox);
     }
 
@@ -1243,13 +1245,15 @@
     private function message_object_prepare(&$msg, &$size = 0)
     {
         // Remove body too big
-        if ($msg->body && ($length = strlen($msg->body))) {
-            $size += $length;
+        if (isset($msg->body)) {
+            $length = strlen($msg->body);
 
-            if ($size > $this->threshold * 1024) {
-                $size -= $length;
+            if ($msg->body_modified || $size + $length > $this->threshold * 1024) {
                 unset($msg->body);
             }
+            else {
+                $size += $length;
+            }
         }
 
         // Fix mimetype which might be broken by some code when message is displayed

--
Gitblit v1.9.1