diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-02-13 22:52:54 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-02-13 22:52:54 +0000 |
commit | 49f59ef89ee36eda39b32247bd583c92475c0fc4 (patch) | |
tree | e4eed31dedaf7a301fba83993e41a139d2c25224 /engine/lib/entities.php | |
parent | e0431dfd7d0043551db9696cf5cb5a01ff30214c (diff) | |
download | elgg-49f59ef89ee36eda39b32247bd583c92475c0fc4.tar.gz elgg-49f59ef89ee36eda39b32247bd583c92475c0fc4.tar.bz2 |
Cleaned up tag searching so you can search on a specific tag. Useful in search so a tag in "Things I like" won't match a tag in "Things I hate."
git-svn-id: http://code.elgg.org/elgg/trunk@3938 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/entities.php')
-rw-r--r-- | engine/lib/entities.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php index eb98d5949..712404179 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -1122,17 +1122,26 @@ abstract class ElggEntity implements } /** - * Returns tags for this entity using registered tag metadata names. + * Returns tags for this entity. * + * @param array $tag_names Optionally restrict by tag metadata names. * @return array */ - public function getTags() { + public function getTags($tag_names = NULL) { global $CONFIG; + if ($tag_names && !is_array($tag_names)) { + $tag_names = array($tag_names); + } + $valid_tags = elgg_get_registered_tag_metadata_names(); $entity_tags = array(); foreach ($valid_tags as $tag_name) { + if (is_array($tag_names) && !in_array($tag_name, $tag_names)) { + continue; + } + if ($tags = $this->$tag_name) { // if a single tag, metadata returns a string. // if multiple tags, metadata returns an array. |