From bc92ca56ef6c51393d2782b7654eaa162dfc2e10 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Mon, 30 Jul 2012 07:20:56 -0400
Subject: [PATCH] Fixes after default->classic switch

---
 program/include/rcube_ldap.php |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/program/include/rcube_ldap.php b/program/include/rcube_ldap.php
index d3067e1..3a7fc18 100644
--- a/program/include/rcube_ldap.php
+++ b/program/include/rcube_ldap.php
@@ -1,4 +1,5 @@
 <?php
+
 /*
  +-----------------------------------------------------------------------+
  | program/include/rcube_ldap.php                                        |
@@ -19,9 +20,6 @@
  |         Andreas Dick <andudi (at) gmx (dot) ch>                       |
  |         Aleksander Machniak <machniak@kolabsys.com>                   |
  +-----------------------------------------------------------------------+
-
- $Id$
-
 */
 
 
@@ -131,7 +129,7 @@
         if ($this->fieldmap['street'] && $this->fieldmap['locality']) {
             $this->coltypes['address'] = array(
                'limit'    => max(1, $this->coltypes['locality']['limit'] + $this->coltypes['address']['limit']),
-               'subtypes' => array_merge((array)$this->coltypes['address']['subtypes'], $this->coltypes['locality']['subtypes']),
+               'subtypes' => array_merge((array)$this->coltypes['address']['subtypes'], (array)$this->coltypes['locality']['subtypes']),
                'childs' => array(),
                ) + (array)$this->coltypes['address'];
 
@@ -143,7 +141,14 @@
             }
         }
         else if ($this->coltypes['address']) {
-            $this->coltypes['address'] = array('type' => 'textarea', 'childs' => null, 'limit' => 1, 'size' => 40);
+            $this->coltypes['address'] += array('type' => 'textarea', 'childs' => null, 'size' => 40);
+
+            // 'serialized' means the UI has to present a composite address field
+            if ($this->coltypes['address']['serialized']) {
+                $childprop = array('type' => 'text');
+                $this->coltypes['address']['type'] = 'composite';
+                $this->coltypes['address']['childs'] = array('street' => $childprop, 'locality' => $childprop, 'zipcode' => $childprop, 'country' => $childprop);
+            }
         }
 
         // make sure 'required_fields' is an array
@@ -762,7 +767,9 @@
         }
 
         // use VLV pseudo-search for autocompletion
-        if ($this->prop['vlv_search'] && $this->conn && join(',', (array)$fields) == 'email,name')
+        $rcmail = rcmail::get_instance();
+
+        if ($this->prop['vlv_search'] && $this->conn && join(',', (array)$fields) == join(',', $rcmail->config->get('contactlist_fields')))
         {
             // add general filter to query
             if (!empty($this->prop['filter']) && empty($this->filter))
@@ -1186,8 +1193,11 @@
                     else if ($val == '') {
                         // Field supplied is empty, verify that it is not required.
                         if (!in_array($fld, $this->prop['required_fields'])) {
-                            // It is not, safe to clear.
-                            $deletedata[$fld] = $old_data[$fld];
+                            // ...It is not, safe to clear.
+                            // #1488420: Workaround "ldap_mod_del(): Modify: Inappropriate matching in..."
+                            // jpegPhoto attribute require an array() here. It looks to me that it works for other attribs too
+                            $deletedata[$fld] = array();
+                            //$deletedata[$fld] = $old_data[$fld];
                         }
                     }
                     else {

--
Gitblit v1.9.1