aboutsummaryrefslogtreecommitdiff
path: root/mod/search/search_hooks.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/search/search_hooks.php')
-rw-r--r--mod/search/search_hooks.php19
1 files changed, 16 insertions, 3 deletions
diff --git a/mod/search/search_hooks.php b/mod/search/search_hooks.php
index 77ab5c6e3..a74b1c2b3 100644
--- a/mod/search/search_hooks.php
+++ b/mod/search/search_hooks.php
@@ -165,9 +165,22 @@ function search_users_hook($hook, $type, $value, $params) {
function search_tags_hook($hook, $type, $value, $params) {
global $CONFIG;
+ $valid_tags = elgg_get_registered_tag_metadata_names();
+
// @todo will need to split this up to support searching multiple tags at once.
$query = sanitise_string($params['query']);
- $params['metadata_name_value_pair'] = array ('name' => 'tags', 'value' => $query, 'case_sensitive' => FALSE);
+
+ $name_value_pairs = array();
+ foreach ($valid_tags as $tag_name) {
+ $name_value_pairs[] = array (
+ 'name' => $tag_name,
+ 'value' => $query,
+ 'case_sensitive' => FALSE
+ );
+ }
+
+ $params['metadata_name_value_pairs'] = $name_value_pairs;
+ $params['metadata_name_value_pairs_operator'] = 'OR';
$entities = elgg_get_entities_from_metadata($params);
$params['count'] = TRUE;
@@ -180,10 +193,10 @@ function search_tags_hook($hook, $type, $value, $params) {
// add the volatile data for why these entities have been returned.
foreach ($entities as $entity) {
- $tags = $entity->tags;
+ $tags = $entity->getTags();
if (is_array($tags)) {
- $tags = implode(', ', $entity->tags);
+ $tags = implode(', ', $tags);
}
// Nick told me my idea was dirty, so I'm hard coding the numbers.