revert getBookmarks() back to original

This commit is contained in:
Mark Pemberton 2011-05-19 19:40:22 -04:00
parent 1c6ff8cea6
commit 5203848b12
2 changed files with 20 additions and 31 deletions

View file

@ -718,7 +718,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
// All public bookmarks, user's own bookmarks // All public bookmarks, user's own bookmarks
// and any shared with user // and any shared with user
$privacy = ' AND ((B.bStatus = 0) OR (B.uId = '. $sId .')'; $privacy = ' AND ((B.bStatus = 0) OR (B.uId = '. $sId .')';
$watchnames = $userservice->getWatchNames($sId); $watchnames = $userservice->getWatchNames($sId, true);
foreach ($watchnames as $watchuser) { foreach ($watchnames as $watchuser) {
$privacy .= ' OR (U.username = "'. $watchuser .'" AND B.bStatus = 1)'; $privacy .= ' OR (U.username = "'. $watchuser .'" AND B.bStatus = 1)';
} }
@ -728,16 +728,15 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
$privacy = ' AND B.bStatus = 0'; $privacy = ' AND B.bStatus = 0';
} }
$tagcount = 0;
// Set up the tags, if need be. // 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)); $tags = explode('+', trim($tags));
}
$tagcount = count($tags); $tagcount = count($tags);
for ($i = 0; $i < $tagcount; $i ++) { for ($i = 0; $i < $tagcount; $i ++) {
$tags[$i] = trim($tags[$i]); $tags[$i] = trim($tags[$i]);
} }
}
// Set up the SQL query. // Set up the SQL query.
$query_1 = 'SELECT DISTINCT '; $query_1 = 'SELECT DISTINCT ';
@ -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. // Handle the parts of the query that depend on any tags that are present.
$query_4 = ''; $query_4 = '';
if ($tagcount > 0) { for ($i = 0; $i < $tagcount; $i ++) {
$query_2 .= ', '. $b2tservice->getTableName() .' AS T0'; $query_2 .= ', '. $b2tservice->getTableName() .' AS T'. $i;
$query_4 .= ' AND ('; $query_4 .= ' AND (';
$tagArray = array();
for ($i = 0; $i < $tagcount; $i ++) {
$tmpTag = $this->db->sql_escape($tags[$i]);
$allLinkedTags = $tag2tagservice->getAllLinkedTags( $allLinkedTags = $tag2tagservice->getAllLinkedTags(
$tmpTag, '>', $user $this->db->sql_escape($tags[$i]), '>', $user
); );
while (is_array($allLinkedTags) && count($allLinkedTags)>0) { while (is_array($allLinkedTags) && count($allLinkedTags)>0) {
$tmpValue = array_pop($allLinkedTags); $query_4 .= ' T'. $i .'.tag = "'. array_pop($allLinkedTags) .'"';
if (in_array($tmpValue, $tagArray) == false) { $query_4 .= ' OR';
$tagArray[] = $tmpValue;
}
} }
if (in_array($tmpTag, $tagArray) == false) { $query_4 .= ' T'. $i .'.tag = "'. $this->db->sql_escape($tags[$i]) .'"';
$tagArray[] = $tmpTag;
} $query_4 .= ') AND T'. $i .'.bId = B.bId';
} //die($query_4);
// loop through array of possible tags
foreach ($tagArray as $k => $v) {
$query_4 .= ' T0.tag = "'. $v .'" OR';
}
$query_4 = substr($query_4,0,-3);
$query_4 .= ') AND T0.bId = B.bId';
} }
// Search terms // Search terms

View file

@ -332,6 +332,7 @@ class Tag2TagTest extends TestBase
$this->assertSame('B3', $results['bookmarks'][0]['bTitle']); $this->assertSame('B3', $results['bookmarks'][0]['bTitle']);
$results = $bs->getBookmarks(0, NULL, 1, 'aa+ee'); $results = $bs->getBookmarks(0, NULL, 1, 'aa+ee');
$this->assertSame(1, intval($results['total'])); $this->assertSame(1, intval($results['total']));
$this->assertSame('B2', $results['bookmarks'][0]['bTitle']); $this->assertSame('B2', $results['bookmarks'][0]['bTitle']);