aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-02-13 22:52:54 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-02-13 22:52:54 +0000
commit49f59ef89ee36eda39b32247bd583c92475c0fc4 (patch)
treee4eed31dedaf7a301fba83993e41a139d2c25224 /engine
parente0431dfd7d0043551db9696cf5cb5a01ff30214c (diff)
downloadelgg-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')
-rw-r--r--engine/lib/entities.php13
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.