Skip to content

Commit

Permalink
Bug #12480: Don't do email filter on name if name is not part of the …
Browse files Browse the repository at this point in the history
…search result
  • Loading branch information
slusarz committed Aug 7, 2014
1 parent 999fe46 commit 8c16e12
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions turba/lib/Api.php
Expand Up @@ -1267,20 +1267,26 @@ public function search($names = null, array $opts = array())
($attributes[$key]['type'] == 'email')) {
$e_val = $ob->getValue($key);

/* Ticket #12480: Don't return email if it
* doesn't contain the search string, since
* an entry can contain multiple e-mail
* fields. Return all e-mails if it
* occurs in the name. */
if (!isset($tname)) {
$tname = Horde_String_Transliterate::toAscii($name);
}
if (!isset($tdisplay_name)) {
$tdisplay_name = Horde_String_Transliterate::toAscii($display_name);
if (strlen($trimname)) {
/* Ticket #12480: Don't return email if it
* doesn't contain the search string, since
* an entry can contain multiple e-mail
* fields. Return all e-mails if it
* occurs in the name. */
if (!isset($tname)) {
$tname = Horde_String_Transliterate::toAscii($name);
}
if (!isset($tdisplay_name)) {
$tdisplay_name = Horde_String_Transliterate::toAscii($display_name);
}

$add = ((Horde_String::ipos(Horde_String_Transliterate::toAscii($e_val), $tname) !== false) ||
(Horde_String::ipos($tdisplay_name, $tname) !== false));
} else {
$add = true;
}

if ((Horde_String::ipos($tdisplay_name, $tname) !== false) ||
(Horde_String::ipos(Horde_String_Transliterate::toAscii($e_val), $tname) !== false)) {
if ($add) {
// Multiple addresses support
$email->add($rfc822->parseAddressList($e_val, array(
'limit' => (isset($attributes[$key]['params']) && is_array($attributes[$key]['params']) && !empty($attributes[$key]['params']['allow_multi'])) ? 0 : 1
Expand Down

0 comments on commit 8c16e12

Please sign in to comment.