[jan] Fix searching for fields matching an email address if using 'emails'
authorJan Schneider <jan@horde.org>
Tue, 28 Dec 2010 17:33:45 +0000 (18:33 +0100)
committerJan Schneider <jan@horde.org>
Tue, 28 Dec 2010 17:33:45 +0000 (18:33 +0100)
      attribute instead of 'email' (Bug #9472).

turba/docs/CHANGES
turba/lib/Api.php

index 546d8df..27309c9 100644 (file)
@@ -16,6 +16,8 @@ v3.0-git
 v2.3.6-cvs
 ----------
 
+[jan] Fix searching for fields matching an email address if using 'emails'
+      attribute instead of 'email' (Bug #9472).
 [jan] Use personal address books first if determining the default one (Valentin
       Vidic, Request #9367).
 [jan] Use name format preference not only for paging, but for sorting too
index de667c3..461bc91 100644 (file)
@@ -1655,8 +1655,16 @@ class Turba_Api extends Horde_Registry_Api
             }
 
             $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source);
+            $criterium = array('email' => $address);
+            if (!isset($driver->map['email'])) {
+                if (isset($driver->map['emails'])) {
+                    $criterium = array('emails' => $address);
+                } else {
+                    continue;
+                }
+            }
 
-            $list = $driver->search(array('email' => $address), null, 'AND', array(), $strict ? array('email') : array());
+            $list = $driver->search($criterium, null, 'AND', array(), $strict ? array('email') : array());
             if (!($list instanceof Turba_List)) {
                 continue;
             }