diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-02-10 20:41:38 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-02-10 20:41:38 +0000 |
commit | d407773cb2ab492d4d4f4814d3566737a5ccfb4a (patch) | |
tree | e7d4cb166ef1eb5fcc0101da3385c3d2702ba598 /lib/class/tmp_playlist.class.php | |
parent | bdd6c2acd42b11f489ee6fd572d22d2e49843a79 (diff) | |
download | ampache-d407773cb2ab492d4d4f4814d3566737a5ccfb4a.tar.gz ampache-d407773cb2ab492d4d4f4814d3566737a5ccfb4a.tar.bz2 ampache-d407773cb2ab492d4d4f4814d3566737a5ccfb4a.zip |
fixed democratic play vote order and user preferences update
Diffstat (limited to 'lib/class/tmp_playlist.class.php')
-rw-r--r-- | lib/class/tmp_playlist.class.php | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/class/tmp_playlist.class.php b/lib/class/tmp_playlist.class.php index b024c454..08e1d30f 100644 --- a/lib/class/tmp_playlist.class.php +++ b/lib/class/tmp_playlist.class.php @@ -86,7 +86,7 @@ class tmpPlaylist { $order = 'ORDER BY id ASC'; if ($this->type == 'vote') { - $order = "GROUP BY tmp_playlist_data.id ORDER BY `count` DESC"; + $order = "GROUP BY tmp_playlist_data.id ORDER BY `count` ,user_vote.date DESC"; $vote_select = ", COUNT(user_vote.user) AS `count`"; $vote_join = "LEFT JOIN user_vote ON user_vote.object_id=tmp_playlist_data.id"; } @@ -94,6 +94,7 @@ class tmpPlaylist { /* Select all objects from this playlist */ $sql = "SELECT tmp_playlist_data.id, tmp_playlist_data.object_id $vote_select FROM tmp_playlist_data $vote_join " . "WHERE tmp_playlist_data.tmp_playlist='" . sql_escape($this->id) . "' $order"; + debug_event('foo',$sql,'1'); $db_results = mysql_query($sql, dbh()); /* Define the array */ @@ -123,7 +124,7 @@ class tmpPlaylist { if ($this->type == 'vote') { /* Add conditions for voting */ $vote_select = ", COUNT(user_vote.user) AS `count`"; - $order = " GROUP BY tmp_playlist_data.id ORDER BY `count` DESC"; + $order = " GROUP BY tmp_playlist_data.id ORDER BY `count`, user_vote.date DESC"; $vote_join = "LEFT JOIN user_vote ON user_vote.object_id=tmp_playlist_data.id"; } @@ -326,8 +327,9 @@ class tmpPlaylist { } /* Vote! */ - $sql = "INSERT INTO user_vote (`user`,`object_id`) " . - "VALUES ('" . sql_escape($GLOBALS['user']->id) . "','" . $results['id'] . "')"; + $time = time(); + $sql = "INSERT INTO user_vote (`user`,`object_id`,`date`) " . + "VALUES ('" . sql_escape($GLOBALS['user']->id) . "','" . $results['id'] . "','$time')"; $db_results = mysql_query($sql, dbh()); return true; |