]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
we can retrieve system tags now
authorChristian Weiske <cweiske@cweiske.de>
Fri, 5 Aug 2011 04:33:40 +0000 (06:33 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Fri, 5 Aug 2011 04:33:40 +0000 (06:33 +0200)
src/SemanticScuttle/Service/Bookmark2Tag.php
tests/Bookmark2TagTest.php

index 914abc6155234f940c20796569d038ac55452286..3e5c533ec56dc0830faf6be280171545ffd556f8 100644 (file)
@@ -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(
index 4d95d69e7a12ce45f0423d228e43088ce32ffb1a..1367a0eb0d10dc0056058ebc3bb1fb677064e794 100644 (file)
@@ -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
      *