summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-11-12 20:10:22 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-11-12 20:10:22 +0000
commit85a3474424ec5ea06be2f0f27198c9ba7f739af9 (patch)
tree6c33ccb31e1baff46c83ccbe393382e55c5cbcb6 /lib
parent229ae80fc9b3ae7157ff216330575efae5ec80b5 (diff)
downloadampache-85a3474424ec5ea06be2f0f27198c9ba7f739af9.tar.gz
ampache-85a3474424ec5ea06be2f0f27198c9ba7f739af9.tar.bz2
ampache-85a3474424ec5ea06be2f0f27198c9ba7f739af9.zip
added ability to vote songs up and down in democratic play and fixed a problem with ajax not resetting the gettext() and not having a user or session
Diffstat (limited to 'lib')
-rw-r--r--lib/class/tmp_playlist.class.php20
-rw-r--r--lib/init.php8
2 files changed, 27 insertions, 1 deletions
diff --git a/lib/class/tmp_playlist.class.php b/lib/class/tmp_playlist.class.php
index 656ad44b..a262f3e8 100644
--- a/lib/class/tmp_playlist.class.php
+++ b/lib/class/tmp_playlist.class.php
@@ -376,6 +376,26 @@ class tmpPlaylist {
} // vote_active
/**
+ * remove_vote
+ * This is called to remove a vote by a user for an object, it uses the object_id
+ * As that's what we'll have most the time, no need to check if they've got an existing
+ * vote for this, just remove anything that is there
+ */
+ function remove_vote($object_id) {
+
+ $object_id = sql_escape($object_id);
+ $user_id = sql_escape($GLOBALS['user']->id);
+
+ $sql = "DELETE FROM user_vote USING user_vote INNER JOIN tmp_playlist_data ON tmp_playlist_data.id=user_vote.object_id " .
+ "WHERE user='$user_id' AND tmp_playlist_data.object_id='$object_id' " .
+ "AND tmp_playlist_data.tmp_playlist='" . sql_escape($this->id) . "'";
+ $db_results = mysql_query($sql,dbh());
+
+ return true;
+
+ } // remove_vote
+
+ /**
* delete_track
* This deletes a track and any assoicated votes, we only check for
* votes if it's vote playlist, id is a object_id
diff --git a/lib/init.php b/lib/init.php
index 47c55ad3..b6826943 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -289,7 +289,13 @@ elseif (!conf('use_auth')) {
set_theme();
}
else {
- $user = new user();
+ if (isset($_REQUEST['sessid'])) {
+ $results = vauth_get_session($_REQUEST['sessid']);
+ session_id(scrub_in($_REQUEST['sessid']));
+ session_start();
+ }
+ $user = new user($results['username']);
+ init_preferences();
}