plugins/libkolab

Aleksander Machniak machniak at kolabsys.com
Tue Jul 2 10:54:46 CEST 2013


 plugins/libkolab/lib/kolab_storage_folder.php |   24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

New commits:
commit 2cbe93a0c982bc76c78a6a4e0727b929a858cac3
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Tue Jul 2 10:54:32 2013 +0200

    Fix saving empty attachments

diff --git a/plugins/libkolab/lib/kolab_storage_folder.php b/plugins/libkolab/lib/kolab_storage_folder.php
index 97b256e..5809ebc 100644
--- a/plugins/libkolab/lib/kolab_storage_folder.php
+++ b/plugins/libkolab/lib/kolab_storage_folder.php
@@ -983,7 +983,16 @@ class kolab_storage_folder
             // without writting full message content to a temporary file but
             // directly to IMAP, see rcube_imap_generic::append().
             // I.e. use file handles where possible
-            if (!empty($att['content'])) {
+            if (!empty($att['path'])) {
+                if ($is_file && $binary) {
+                    $files[] = fopen($att['path'], 'r');
+                    $mime->addAttachment($marker, $att['mimetype'], $name, false, $encoding, 'attachment', '', '', '', null, null, '', RCUBE_CHARSET, $headers);
+                }
+                else {
+                    $mime->addAttachment($att['path'], $att['mimetype'], $name, true, $encoding, 'attachment', '', '', '', null, null, '', RCUBE_CHARSET, $headers);
+                }
+            }
+            else {
                 if (is_resource($att['content']) && $is_file && $binary) {
                     $files[] = $att['content'];
                     $mime->addAttachment($marker, $att['mimetype'], $name, false, $encoding, 'attachment', '', '', '', null, null, '', RCUBE_CHARSET, $headers);
@@ -995,20 +1004,9 @@ class kolab_storage_folder
                     }
                     $mime->addAttachment($att['content'], $att['mimetype'], $name, false, $encoding, 'attachment', '', '', '', null, null, '', RCUBE_CHARSET, $headers);
                 }
-                $part_id++;
-            }
-            else if (!empty($att['path'])) {
-                if ($is_file && $binary) {
-                    $files[] = fopen($att['path'], 'r');
-                    $mime->addAttachment($marker, $att['mimetype'], $name, false, $encoding, 'attachment', '', '', '', null, null, '', RCUBE_CHARSET, $headers);
-                }
-                else {
-                    $mime->addAttachment($att['path'], $att['mimetype'], $name, true, $encoding, 'attachment', '', '', '', null, null, '', RCUBE_CHARSET, $headers);
-                }
-                $part_id++;
             }
 
-            $object['_attachments'][$key]['id'] = $part_id;
+            $object['_attachments'][$key]['id'] = ++$part_id;
         }
 
         if (!$is_file || !empty($files)) {





More information about the commits mailing list