From b1f0846727331f58342e9cfdd02df03ea8f15181 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Fri, 07 Oct 2011 04:33:24 -0400
Subject: [PATCH] - Make sure LDAP name fields aren't arrays (#1488108)

---
 CHANGELOG                      |    1 +
 program/steps/mail/search.inc  |    2 +-
 program/include/rcube_ldap.php |    9 +++++++--
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index b4d1586..c3910f3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Make sure LDAP name fields aren't arrays (#1488108)
 - Fixed imap test to non-default port when using ssl (#1488118)
 - Force all files to be overwritten when updating (#1488117)
 - Fix issue where it wasn't possible to change list view mode in folder manager for INBOX (#1488107)
diff --git a/program/include/rcube_ldap.php b/program/include/rcube_ldap.php
index 55c8c15..a3f6dc5 100644
--- a/program/include/rcube_ldap.php
+++ b/program/include/rcube_ldap.php
@@ -72,7 +72,7 @@
     function __construct($p, $debug=false, $mail_domain=NULL)
     {
         $this->prop = $p;
-        
+
         if (isset($p['searchonly']))
             $this->searchonly = $p['searchonly'];
 
@@ -447,7 +447,7 @@
             $this->result->searchonly = true;
             return $this->result;
         }
-        
+
         // add general filter to query
         if (!empty($this->prop['filter']) && empty($this->filter))
         {
@@ -1031,6 +1031,11 @@
                 else
                     $out[$rf] = $value;
             }
+
+            // Make sure name fields aren't arrays (#1488108)
+            if (is_array($out[$rf]) && in_array($rf, array('name', 'surname', 'firstname', 'middlename', 'nickname'))) {
+                $out[$rf] = $out[$rf][0];
+            }
         }
 
         return $out;
diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc
index d34454f..2e7fd13 100644
--- a/program/steps/mail/search.inc
+++ b/program/steps/mail/search.inc
@@ -78,7 +78,7 @@
         case 'text': $subject['text'] = 'TEXT'; break;
         default:     $subject[$header] = 'HEADER '.strtoupper($header);
       }
-    
+
     // save search modifiers for the current folder to user prefs
     $search_mods = $RCMAIL->config->get('search_mods', $SEARCH_MODS_DEFAULT);
     $search_mods[$mbox] = array_fill_keys(array_keys($subject), 1);

--
Gitblit v1.9.1