[dev] [patch] Turba search api without email addresses
Jason M. Felice
jfelice at cronosys.com
Thu Aug 7 09:57:50 PDT 2003
Turba's "search" api does not return entries without email addresses. I'm
not sure what this might break (it looks like IMP calls it), but this patch
will return records with no email addresses.
It's also not certain if the old code was trying to prevent records w/out
email addresses from getting through, or if it just assumed that all records
had email addresses.
--
Jason M. Felice
Cronosys, LLC <http://www.cronosys.com/>
216.221.4600 x302
-------------- next part --------------
Index: turba/lib/api.php
===================================================================
RCS file: /repository/turba/lib/api.php,v
retrieving revision 1.55
diff -u -r1.55 api.php
--- turba/lib/api.php 15 May 2003 17:18:40 -0000 1.55
+++ turba/lib/api.php 7 Aug 2003 16:51:00 -0000
@@ -193,15 +193,29 @@
if (!$ob->isGroup()) {
/* Not a group. */
$att = $ob->getAttributes();
+
+ $email = null;
foreach ($att as $key => $value) {
if (!empty($value) && isset($attributes[$key]) &&
- $attributes[$key]['type'] == 'email' &&
- empty($seen[$name][trim(String::lower($att['name'])) . trim(String::lower($value))])) {
-
- $results[$name][] = array('name' => $att['name'], 'email' => $value, '__type' => 'Contact', 'id' => $att['__key'], 'source' => $source);
- $seen[$name][trim(String::lower($att['name'])) . trim(String::lower($value))] = true;
+ $attributes[$key]['type'] == 'email') {
+ $email = $value;
+ break;
}
}
+ if (!is_null($email)) {
+ $seen_key = trim(String::lower($att['name'])).'/'.trim(String::lower($email));
+ if (!empty($seen[$seen_key])) {
+ continue;
+ }
+ $seen[$seen_key] = true;
+ }
+ $results[$name][] = array(
+ 'name' => $att['name'],
+ 'email' => $email,
+ '__type' => 'Contact',
+ 'id' => $att['__key'],
+ 'source' => $source
+ );
} else {
/* Is a distribution list. */
$listatt = $ob->getAttributes();
More information about the dev
mailing list