diff options
Diffstat (limited to 'src/SemanticScuttle/Service')
-rw-r--r-- | src/SemanticScuttle/Service/Bookmark2Tag.php | 40 | ||||
-rw-r--r-- | src/SemanticScuttle/Service/Tag.php | 1 |
2 files changed, 24 insertions, 17 deletions
diff --git a/src/SemanticScuttle/Service/Bookmark2Tag.php b/src/SemanticScuttle/Service/Bookmark2Tag.php index 04ee43d..3e5c533 100644 --- a/src/SemanticScuttle/Service/Bookmark2Tag.php +++ b/src/SemanticScuttle/Service/Bookmark2Tag.php @@ -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( @@ -552,13 +555,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 +562,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)) { diff --git a/src/SemanticScuttle/Service/Tag.php b/src/SemanticScuttle/Service/Tag.php index 8325285..2476608 100644 --- a/src/SemanticScuttle/Service/Tag.php +++ b/src/SemanticScuttle/Service/Tag.php @@ -143,6 +143,7 @@ class SemanticScuttle_Service_Tag extends SemanticScuttle_DbService if(!is_array($tags)) { $tags = utf8_strtolower(trim($tags)); } else { + $tags = array_filter($tags);//remove empty values for($i=0; $i<count($tags); $i++) { $tags[$i] = utf8_strtolower(trim($tags[$i])); } |