From 3ebac0167bf20104fb7a2a55934765117760264c Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Mon, 18 Aug 2014 03:53:18 -0400
Subject: [PATCH] Only add zen-mode text labels in compose step

---
 program/lib/Roundcube/rcube_ldap_generic.php |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/program/lib/Roundcube/rcube_ldap_generic.php b/program/lib/Roundcube/rcube_ldap_generic.php
index a88e53c..9823dbb 100644
--- a/program/lib/Roundcube/rcube_ldap_generic.php
+++ b/program/lib/Roundcube/rcube_ldap_generic.php
@@ -267,6 +267,43 @@
 
         return false;
     }
+
+    /**
+     * Turn an LDAP entry into a regular PHP array with attributes as keys.
+     *
+     * @param array $entry Attributes array as retrieved from ldap_get_attributes() or ldap_get_entries()
+     *
+     * @return array Hash array with attributes as keys
+     */
+    public static function normalize_entry($entry)
+    {
+        if (!isset($entry['count'])) {
+            return $entry;
+        }
+
+        $rec = array();
+
+        for ($i=0; $i < $entry['count']; $i++) {
+            $attr = $entry[$i];
+            if ($entry[$attr]['count'] == 1) {
+                switch ($attr) {
+                    case 'objectclass':
+                        $rec[$attr] = array(strtolower($entry[$attr][0]));
+                        break;
+                    default:
+                        $rec[$attr] = $entry[$attr][0];
+                        break;
+                }
+            }
+            else {
+                for ($j=0; $j < $entry[$attr]['count']; $j++) {
+                    $rec[$attr][$j] = $entry[$attr][$j];
+                }
+            }
+        }
+
+        return $rec;
+    }
 }
 
 // for backward compat.

--
Gitblit v1.9.1