diff options
author | Christian Weiske <cweiske@cweiske.de> | 2011-08-05 06:33:40 +0200 |
---|---|---|
committer | Christian Weiske <cweiske@cweiske.de> | 2011-08-05 06:33:40 +0200 |
commit | c1528d1c5bf82d1a637fa6ac8b245e2a565f5f59 (patch) | |
tree | e61199ff7d63094498f3184ddeff67a68f9f1671 | |
parent | 587674b35567caac15984ddf6c204ab32304684a (diff) | |
download | semanticscuttle-c1528d1c5bf82d1a637fa6ac8b245e2a565f5f59.tar.gz semanticscuttle-c1528d1c5bf82d1a637fa6ac8b245e2a565f5f59.tar.bz2 |
we can retrieve system tags now
-rw-r--r-- | src/SemanticScuttle/Service/Bookmark2Tag.php | 11 | ||||
-rw-r--r-- | tests/Bookmark2TagTest.php | 11 |
2 files changed, 18 insertions, 4 deletions
diff --git a/src/SemanticScuttle/Service/Bookmark2Tag.php b/src/SemanticScuttle/Service/Bookmark2Tag.php index 914abc6..3e5c533 100644 --- a/src/SemanticScuttle/Service/Bookmark2Tag.php +++ b/src/SemanticScuttle/Service/Bookmark2Tag.php @@ -271,10 +271,11 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService * Retrieves all tags for a given bookmark except system tags. * * @param integer $bookmarkid ID of the bookmark + * @param boolean $systemTags Return "system:*" tags or not * * @return array Array of tags */ - public function getTagsForBookmark($bookmarkid) + public function getTagsForBookmark($bookmarkid, $systemTags = false) { if (!is_numeric($bookmarkid)) { message_die( @@ -285,9 +286,11 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService } $query = 'SELECT tag FROM ' . $this->getTableName() - . ' WHERE bId = ' . intval($bookmarkid) - . ' AND LEFT(tag, 7) <> "system:"' - . ' ORDER BY id ASC'; + . ' WHERE bId = ' . intval($bookmarkid); + if (!$systemTags) { + $query .= ' AND LEFT(tag, 7) <> "system:"'; + } + $query .= ' ORDER BY id ASC'; if (!($dbresult = $this->db->sql_query($query))) { message_die( diff --git a/tests/Bookmark2TagTest.php b/tests/Bookmark2TagTest.php index 4d95d69..1367a0e 100644 --- a/tests/Bookmark2TagTest.php +++ b/tests/Bookmark2TagTest.php @@ -71,6 +71,17 @@ class Bookmark2TagTest extends TestBase + public function testAttachTagsWithoutTagsAddsSystemUnfiled() + { + $bid = $this->addBookmark(null, null, 0, array()); + $this->assertEquals( + array('system:unfiled'), + $this->b2ts->getTagsForBookmark($bid, true) + ); + } + + + /** * Test getTagsForBookmark() when the bookmark has no tags * |