From fc52af24f1418d6590a2d37a0d8cc31b123e38f6 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Tue, 19 Aug 2014 12:08:35 -0400
Subject: [PATCH] Fix merge error that disabled contact drag'n'drop

---
 program/steps/addressbook/show.inc |   55 +++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/program/steps/addressbook/show.inc b/program/steps/addressbook/show.inc
index f810a1e..dd9ddce 100644
--- a/program/steps/addressbook/show.inc
+++ b/program/steps/addressbook/show.inc
@@ -5,8 +5,11 @@
  | program/steps/addressbook/show.inc                                    |
  |                                                                       |
  | This file is part of the Roundcube Webmail client                     |
- | Copyright (C) 2005-2009, The Roundcube Dev Team                       |
- | Licensed under the GNU GPL                                            |
+ | Copyright (C) 2005-2012, The Roundcube Dev Team                       |
+ |                                                                       |
+ | Licensed under the GNU General Public License version 3 or            |
+ | any later version with exceptions for skins & plugins.                |
+ | See the README file for a full license statement.                     |
  |                                                                       |
  | PURPOSE:                                                              |
  |   Show contact details                                                |
@@ -14,15 +17,12 @@
  +-----------------------------------------------------------------------+
  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
  +-----------------------------------------------------------------------+
-
- $Id$
-
 */
 
 // Get contact ID and source ID from request
 $cids   = rcmail_get_cids();
 $source = key($cids);
-$cid    = array_shift($cids[$source]);
+$cid    = $cids ? array_shift($cids[$source]) : null;
 
 // Initialize addressbook source
 $CONTACTS  = rcmail_contact_source($source, true);
@@ -30,7 +30,9 @@
 
 // read contact record
 if ($cid && ($record = $CONTACTS->get_record($cid, true))) {
+    $OUTPUT->set_env('readonly', $CONTACTS->readonly || $record['readonly']);
     $OUTPUT->set_env('cid', $record['ID']);
+    $OUTPUT->set_env('compose_extwin', $RCMAIL->config->get('compose_extwin',false));
 }
 
 // get address book name (for display)
@@ -38,6 +40,19 @@
 
 // return raw photo of the given contact
 if ($RCMAIL->action == 'photo') {
+    // search for contact first
+    if (!$record && ($email = get_input_value('_email', RCUBE_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');
+            while ($result && ($record = $result->iterate())) {
+                if ($record['photo'])
+                    break 2;
+            }
+        }
+    }
+
+    // read the referenced file
     if (($file_id = get_input_value('_photo', RCUBE_INPUT_GPC)) && ($tempfile = $_SESSION['contacts']['files'][$file_id])) {
         $tempfile = $RCMAIL->plugins->exec_hook('attachment_display', $tempfile);
         if ($tempfile['status']) {
@@ -53,8 +68,25 @@
             $data = base64_decode($data, true);
     }
 
+    // let plugins do fancy things with contact photos
+    $plugin = $RCMAIL->plugins->exec_hook('contact_photo', array('record' => $record, 'email' => $email, 'data' => $data));
+
+    // redirect to url provided by a plugin
+    if ($plugin['url'])
+        $RCMAIL->output->redirect($plugin['url']);
+    else
+        $data = $plugin['data'];
+
+    // deliver alt image
+    if (!$data && ($alt_img = get_input_value('_alt', RCUBE_INPUT_GPC)) && is_file($alt_img))
+        $data = file_get_contents($alt_img);
+
+    // cache for one day if requested by email
+    if (!$cid && $email)
+        $RCMAIL->output->future_expire_header(86400);
+
     header('Content-Type: ' . rc_image_content_type($data));
-    echo $data ? $data : file_get_contents('program/blank.gif');
+    echo $data ? $data : file_get_contents('program/resources/blank.gif');
     exit;
 }
 
@@ -102,7 +134,7 @@
 
     $form = array(
         'contact' => array(
-            'name'    => rcube_label('contactproperties'),
+            'name'    => rcube_label('properties'),
             'content' => array(
               'email' => array('size' => $i_size, 'render_func' => 'rcmail_render_email_value'),
               'phone' => array('size' => $i_size),
@@ -177,9 +209,8 @@
         return '';
     }
 
-    $table = new html_table(array('cols' => 2, 'cellspacing' => 0, 'border' => 0));
-
-    $members = $CONTACTS->get_record_groups($contact_id);
+    $members  = $CONTACTS->get_record_groups($contact_id);
+    $table    = new html_table(array('cols' => 2, 'cellspacing' => 0, 'border' => 0));
     $checkbox = new html_checkbox(array('name' => '_gid[]',
         'class' => 'groupmember', 'disabled' => $CONTACTS->readonly));
 
@@ -191,7 +222,7 @@
     }
 
     $hiddenfields = new html_hiddenfield(array('name' => '_source', 'value' => get_input_value('_source', RCUBE_INPUT_GPC)));
-    $hiddenfields->add(array('name' => '_cid', 'value' => $record['ID']));
+    $hiddenfields->add(array('name' => '_cid', 'value' => $contact_id));
 
     $form_start = $RCMAIL->output->request_form(array(
         'name' => "form", 'method' => "post",

--
Gitblit v1.9.1