summaryrefslogtreecommitdiff
path: root/src/SemanticScuttle/Service/Bookmark.php
diff options
context:
space:
mode:
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-26 18:52:02 +0000
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-26 18:52:02 +0000
commit44fd0e29f4d856058f3bac3a3581d00919420169 (patch)
tree5f3752a8210bc6bc22ef6a36fa782d65e3603bf8 /src/SemanticScuttle/Service/Bookmark.php
parent0af3f228ac507c55a2c864aecf41ee82b2af9c5b (diff)
downloadsemanticscuttle-44fd0e29f4d856058f3bac3a3581d00919420169.tar.gz
semanticscuttle-44fd0e29f4d856058f3bac3a3581d00919420169.tar.bz2
introduce voting config value and provide current user voting status in getBookmarks()
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@431 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'src/SemanticScuttle/Service/Bookmark.php')
-rw-r--r--src/SemanticScuttle/Service/Bookmark.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php
index a48624b..34a819c 100644
--- a/src/SemanticScuttle/Service/Bookmark.php
+++ b/src/SemanticScuttle/Service/Bookmark.php
@@ -432,6 +432,10 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
* - if the $user is set and IS the logged-in user, then
* get all bookmarks.
*
+ * In case voting is enabled and a user is logged in,
+ * each bookmark array contains two additional keys:
+ * 'hasVoted' and 'vote'.
+ *
* @param integer $start Page number
* @param integer $perpage Number of bookmarks per page
* @param integer $user User ID
@@ -601,6 +605,18 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
if ($hash) {
$query_4 .= ' AND B.bHash = "'. $hash .'"';
}
+
+ //Voting system
+ if ($GLOBALS['enableVoting'] && $userservice->isLoggedOn()) {
+ $currentuser = $userservice->getCurrentUser();
+ $vs = SemanticScuttle_Service_Factory::get('Vote');
+ $query_1 .= ', !ISNULL(V.bId) as hasVoted, V.vote as vote';
+ $query_2 .= ' LEFT JOIN ' . $vs->getTableName() . ' AS V'
+ . ' ON B.bId = V.bId'
+ . ' AND V.uId = ' . (int)$currentuser['uId'];
+ }
+
+
$query = $query_1 . $query_2 . $query_3 . $query_4 . $query_5;
if (!($dbresult = & $this->db->sql_query_limit($query, intval($perpage), intval($start)))) {