From 574e9aefd04a6ea75f53d20756edb6a04a31ba2b Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 30 Mar 2013 15:46:49 -0400 Subject: Fixes #5304 handling metadata arrays in search for user profile data --- mod/search/search_hooks.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'mod/search/search_hooks.php') diff --git a/mod/search/search_hooks.php b/mod/search/search_hooks.php index 47351fb8a..92c6d700a 100644 --- a/mod/search/search_hooks.php +++ b/mod/search/search_hooks.php @@ -178,11 +178,20 @@ function search_users_hook($hook, $type, $value, $params) { $entity->setVolatileData('search_matched_title', $title); $matched = ''; - foreach ($profile_fields as $md) { - $text = $entity->$md; - if (stristr($text, $query)) { - $matched .= elgg_echo("profile:{$md}") . ': ' - . search_get_highlighted_relevant_substrings($text, $query); + foreach ($profile_fields as $md_name) { + $metadata = $entity->$md_name; + if (is_array($metadata)) { + foreach ($metadata as $text) { + if (stristr($text, $query)) { + $matched .= elgg_echo("profile:{$md_name}") . ': ' + . search_get_highlighted_relevant_substrings($text, $query); + } + } + } else { + if (stristr($metadata, $query)) { + $matched .= elgg_echo("profile:{$md_name}") . ': ' + . search_get_highlighted_relevant_substrings($metadata, $query); + } } } -- cgit v1.2.3