]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
revert getBookmarks() back to original
authorMark Pemberton <mpemberton5@gmail.com>
Thu, 19 May 2011 23:40:22 +0000 (19:40 -0400)
committerMark Pemberton <mpemberton5@gmail.com>
Thu, 19 May 2011 23:40:22 +0000 (19:40 -0400)
src/SemanticScuttle/Service/Bookmark.php
tests/Tag2TagTest.php

index 232f9d0b9e155b30a36f0b76eafaf7382141dc5d..17ab7badcbd1df8dc56d9c9e6274a1f64006c00d 100644 (file)
@@ -718,7 +718,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
             // All public bookmarks, user's own bookmarks
             // and any shared with user
             $privacy = ' AND ((B.bStatus = 0) OR (B.uId = '. $sId .')';
-            $watchnames = $userservice->getWatchNames($sId);
+            $watchnames = $userservice->getWatchNames($sId, true);
             foreach ($watchnames as $watchuser) {
                 $privacy .= ' OR (U.username = "'. $watchuser .'" AND B.bStatus = 1)';
             }
@@ -728,15 +728,14 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
             $privacy = ' AND B.bStatus = 0';
         }
 
-        $tagcount = 0;
         // Set up the tags, if need be.
-        if (!is_array($tags) && !is_null($tags) && $tags<>"") {
+        if (!is_array($tags) && !is_null($tags)) {
             $tags = explode('+', trim($tags));
+        }
 
-            $tagcount = count($tags);
-            for ($i = 0; $i < $tagcount; $i ++) {
-                $tags[$i] = trim($tags[$i]);
-            }
+        $tagcount = count($tags);
+        for ($i = 0; $i < $tagcount; $i ++) {
+            $tags[$i] = trim($tags[$i]);
         }
 
         // Set up the SQL query.
@@ -821,34 +820,23 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
 
         // Handle the parts of the query that depend on any tags that are present.
         $query_4 = '';
-        if ($tagcount > 0) {
-            $query_2 .= ', '. $b2tservice->getTableName() .' AS T0';
+        for ($i = 0; $i < $tagcount; $i ++) {
+            $query_2 .= ', '. $b2tservice->getTableName() .' AS T'. $i;
             $query_4 .= ' AND (';
-            
-            $tagArray = array();
-            for ($i = 0; $i < $tagcount; $i ++) {
-                $tmpTag = $this->db->sql_escape($tags[$i]);
-                $allLinkedTags = $tag2tagservice->getAllLinkedTags(
-                    $tmpTag, '>', $user
-                );
 
-                while (is_array($allLinkedTags) && count($allLinkedTags)>0) {
-                    $tmpValue = array_pop($allLinkedTags);
-                    if (in_array($tmpValue, $tagArray) == false) {
-                        $tagArray[] = $tmpValue;
-                    }
-                }
+            $allLinkedTags = $tag2tagservice->getAllLinkedTags(
+                $this->db->sql_escape($tags[$i]), '>', $user
+            );
 
-                if (in_array($tmpTag, $tagArray) == false) {
-                    $tagArray[] = $tmpTag;
-                }
-            }
-            // loop through array of possible tags
-            foreach ($tagArray as $k => $v) {
-                $query_4 .= ' T0.tag = "'. $v .'" OR';
+            while (is_array($allLinkedTags) && count($allLinkedTags)>0) {
+                $query_4 .= ' T'. $i .'.tag = "'. array_pop($allLinkedTags) .'"';
+                $query_4 .= ' OR';
             }
-            $query_4 = substr($query_4,0,-3);
-            $query_4 .= ') AND T0.bId = B.bId';
+
+            $query_4 .= ' T'. $i .'.tag = "'. $this->db->sql_escape($tags[$i]) .'"';
+
+            $query_4 .= ') AND T'. $i .'.bId = B.bId';
+            //die($query_4);
         }
 
         // Search terms
index 0b73864c9b1e06faf9b4c16287a99d4b23d26b1e..58556f1ff308b1756aa1e43ee4c38b7384c2d1b4 100644 (file)
@@ -332,6 +332,7 @@ class Tag2TagTest extends TestBase
         $this->assertSame('B3', $results['bookmarks'][0]['bTitle']);
 
         $results = $bs->getBookmarks(0, NULL, 1, 'aa+ee');
+
         $this->assertSame(1, intval($results['total']));
         $this->assertSame('B2', $results['bookmarks'][0]['bTitle']);