From 5203848b12ccda0009409e08165bfa2d9d34a837 Mon Sep 17 00:00:00 2001 From: Mark Pemberton Date: Thu, 19 May 2011 19:40:22 -0400 Subject: revert getBookmarks() back to original --- src/SemanticScuttle/Service/Bookmark.php | 50 ++++++++++++-------------------- 1 file changed, 19 insertions(+), 31 deletions(-) (limited to 'src/SemanticScuttle/Service/Bookmark.php') diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php index 232f9d0..17ab7ba 100644 --- a/src/SemanticScuttle/Service/Bookmark.php +++ b/src/SemanticScuttle/Service/Bookmark.php @@ -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 -- cgit v1.2.3