From 3cc1afa1c2f30bfebb30146795e50172947b4b5f Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sun, 29 Jun 2014 10:35:18 -0400
Subject: [PATCH] Support images in HTML signatures (#1488676) This enables image button and file browser in html editor for signatures

---
 program/steps/mail/attachments.inc |   63 +------------------------------
 1 files changed, 2 insertions(+), 61 deletions(-)

diff --git a/program/steps/mail/attachments.inc b/program/steps/mail/attachments.inc
index fd122c5..5eaa655 100644
--- a/program/steps/mail/attachments.inc
+++ b/program/steps/mail/attachments.inc
@@ -38,7 +38,7 @@
 
 
 // remove an attachment
-if ($RCMAIL->action=='remove-attachment') {
+if ($RCMAIL->action == 'remove-attachment') {
     $id = 'undefined';
 
     if (preg_match('/^rcmfile(\w+)$/', $_POST['_file'], $regs)) {
@@ -67,66 +67,7 @@
         $id = $regs[1];
     }
 
-    if ($attachment = $COMPOSE['attachments'][$id]) {
-        $attachment = $RCMAIL->plugins->exec_hook('attachment_display', $attachment);
-    }
-
-    if ($attachment['status']) {
-        if (empty($attachment['size'])) {
-            $attachment['size'] = $attachment['data'] ? strlen($attachment['data']) : @filesize($attachment['path']);
-        }
-
-        // generate image thumbnail for file browser in HTML editor
-        if (!empty($_GET['_thumbnail'])) {
-            $temp_dir       = $RCMAIL->config->get('temp_dir');
-            $thumbnail_size = 80;
-            list(,$ext)     = explode('/', $attachment['mimetype']);
-            $mimetype       = $attachment['mimetype'];
-            $file_ident     = $attachment['id'] . ':' . $attachment['mimetype'] . ':' . $attachment['size'];
-            $cache_basename = $temp_dir . '/' . md5($file_ident . ':' . $RCMAIL->user->ID . ':' . $thumbnail_size);
-            $cache_file     = $cache_basename . '.' . $ext;
-
-            // render thumbnail image if not done yet
-            if (!is_file($cache_file)) {
-                if (!$attachment['path']) {
-                    $orig_name = $filename = $cache_basename . '.orig.' . $ext;
-                    file_put_contents($orig_name, $attachment['data']);
-                }
-                else {
-                    $filename = $attachment['path'];
-                }
-
-                $image = new rcube_image($filename);
-                if ($imgtype = $image->resize($thumbnail_size, $cache_file, true)) {
-                    $mimetype = 'image/' . $imgtype;
-
-                    if ($orig_name) {
-                        unlink($orig_name);
-                    }
-                }
-            }
-
-            if (is_file($cache_file)) {
-                // cache for 1h
-                $RCMAIL->output->future_expire_header(3600);
-                header('Content-Type: ' . $mimetype);
-                header('Content-Length: ' . filesize($cache_file));
-
-                readfile($cache_file);
-                exit;
-            }
-        }
-
-        header('Content-Type: ' . $attachment['mimetype']);
-        header('Content-Length: ' . $attachment['size']);
-
-        if ($attachment['data']) {
-            echo $attachment['data'];
-        }
-        else if ($attachment['path']) {
-            readfile($attachment['path']);
-        }
-    }
+    $RCMAIL->display_uploaded_file($COMPOSE['attachments'][$id]);
 
     exit;
 }

--
Gitblit v1.9.1