From a3644638aaf0418598196a870204e0b632a4c8ad Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Fri, 17 Apr 2015 06:28:40 -0400
Subject: [PATCH] Allow preference sections to define CSS class names

---
 program/steps/addressbook/photo.inc |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/program/steps/addressbook/photo.inc b/program/steps/addressbook/photo.inc
index 658027d..962ca31 100644
--- a/program/steps/addressbook/photo.inc
+++ b/program/steps/addressbook/photo.inc
@@ -26,7 +26,7 @@
 $cid    = $cids ? array_shift($cids[$source]) : null;
 
 // read the referenced file
-if (($file_id = get_input_value('_photo', RCUBE_INPUT_GPC)) && ($tempfile = $_SESSION['contacts']['files'][$file_id])) {
+if (($file_id = rcube_utils::get_input_value('_photo', rcube_utils::INPUT_GPC)) && ($tempfile = $_SESSION['contacts']['files'][$file_id])) {
     $tempfile = $RCMAIL->plugins->exec_hook('attachment_display', $tempfile);
     if ($tempfile['status']) {
         if ($tempfile['data'])
@@ -37,7 +37,7 @@
 }
 else {
     // by email, search for contact first
-    if ($email = get_input_value('_email', RCUBE_INPUT_GPC)) {
+    if ($email = rcube_utils::get_input_value('_email', rcube_utils::INPUT_GPC)) {
         foreach ($RCMAIL->get_address_sources() as $s) {
             $abook = $RCMAIL->get_address_book($s['id']);
             $result = $abook->search(array('email'), $email, 1, true, true, 'photo');
@@ -72,12 +72,16 @@
 if ($plugin['url']) {
     $RCMAIL->output->redirect($plugin['url']);
 }
-else {
-    $data = $plugin['data'];
+
+$data = $plugin['data'];
+
+// detect if photo data is an URL
+if (strlen($data) < 1024 && filter_var($data, FILTER_VALIDATE_URL)) {
+    $RCMAIL->output->redirect($data);
 }
 
 // deliver alt image
-if (!$data && ($alt_img = get_input_value('_alt', RCUBE_INPUT_GPC)) && is_file($alt_img)) {
+if (!$data && ($alt_img = rcube_utils::get_input_value('_alt', rcube_utils::INPUT_GPC)) && is_file($alt_img)) {
     $data = file_get_contents($alt_img);
 }
 
@@ -86,6 +90,12 @@
     $RCMAIL->output->future_expire_header(86400);
 }
 
-header('Content-Type: ' . rc_image_content_type($data));
-echo $data ? $data : file_get_contents('program/resources/blank.gif');
+if ($data) {
+    header('Content-Type: ' . rcube_mime::image_content_type($data));
+    echo $data;
+}
+else {
+    header('Content-Type: image/gif');
+    echo base64_decode(rcmail_output::BLANK_GIF);
+}
 exit;

--
Gitblit v1.9.1