From 4775d7bf5adfcc3bd965f2190505f7e543557c39 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 1 Aug 2011 18:25:14 +0200 Subject: Fix bug #3376618: Broken tag completion for private bookmarks --- src/SemanticScuttle/Service/Bookmark2Tag.php | 29 +++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/SemanticScuttle/Service/Bookmark2Tag.php b/src/SemanticScuttle/Service/Bookmark2Tag.php index 04ee43d..914abc6 100644 --- a/src/SemanticScuttle/Service/Bookmark2Tag.php +++ b/src/SemanticScuttle/Service/Bookmark2Tag.php @@ -552,13 +552,6 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService $user = null, $limit = 30, $logged_on_user = null, $days = null, $beginsWith = null ) { - // Only count the tags that are visible to the current user. - if (($user != $logged_on_user) || is_null($user) || ($user === false)) { - $privacy = ' AND B.bStatus = 0'; - } else { - $privacy = ''; - } - $query = 'SELECT' . ' T.tag, COUNT(T.bId) AS bCount' . ' FROM ' @@ -566,20 +559,30 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService . ', ' . $GLOBALS['tableprefix'] . 'bookmarks AS B' . ' WHERE'; - if (is_null($user) || ($user === false)) { + if (is_null($user) || $user === false) { $query .= ' B.bId = T.bId AND B.bStatus = 0'; } else if (is_array($user)) { $query .= ' (1 = 0'; //tricks foreach ($user as $u) { - if (is_numeric($u)) { - $query .= ' OR B.uId = ' . $this->db->sql_escape($u) - . ' AND B.bId = T.bId'; + if (!is_numeric($u)) { + continue; + } + $query .= ' OR (' + . ' B.uId = ' . $this->db->sql_escape($u) + . ' AND B.bId = T.bId'; + if ($u !== $logged_on_user) { + //public bookmarks of others + $query .= ' AND B.bStatus = 0'; } + $query .= ')'; } - $query .= ' )' . $privacy; + $query .= ' )'; } else { $query .= ' B.uId = ' . $this->db->sql_escape($user) - . ' AND B.bId = T.bId' . $privacy; + . ' AND B.bId = T.bId'; + if ($user !== $logged_on_user) { + $query .= ' AND B.bStatus = 0'; + } } if (is_int($days)) { -- cgit v1.2.3