summaryrefslogtreecommitdiffstats
path: root/lib/class
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-02-10 20:41:38 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-02-10 20:41:38 +0000
commitd407773cb2ab492d4d4f4814d3566737a5ccfb4a (patch)
treee7d4cb166ef1eb5fcc0101da3385c3d2702ba598 /lib/class
parentbdd6c2acd42b11f489ee6fd572d22d2e49843a79 (diff)
downloadampache-d407773cb2ab492d4d4f4814d3566737a5ccfb4a.tar.gz
ampache-d407773cb2ab492d4d4f4814d3566737a5ccfb4a.tar.bz2
ampache-d407773cb2ab492d4d4f4814d3566737a5ccfb4a.zip
fixed democratic play vote order and user preferences update
Diffstat (limited to 'lib/class')
-rw-r--r--lib/class/tmp_playlist.class.php10
-rw-r--r--lib/class/update.class.php2
-rw-r--r--lib/class/user.class.php15
3 files changed, 14 insertions, 13 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;
diff --git a/lib/class/update.class.php b/lib/class/update.class.php
index c2dd6c5f..9471eb71 100644
--- a/lib/class/update.class.php
+++ b/lib/class/update.class.php
@@ -2218,7 +2218,7 @@ class Update {
$db_results = mysql_query($sql,dbh());
// Now pull the access list users, alter table and then re-insert
- $sql = "SELETE DISTINCT(`user`) FROM `access_list`";
+ $sql = "SELECT DISTINCT(`user`) FROM `access_list`";
$db_results = mysql_query($sql,dbh());
while ($r = mysql_fetch_assoc($db_results)) {
diff --git a/lib/class/user.class.php b/lib/class/user.class.php
index 32c1e3d7..c03a3969 100644
--- a/lib/class/user.class.php
+++ b/lib/class/user.class.php
@@ -303,32 +303,31 @@ class User {
/**
* update_preference
- * //FIXME: Unused at this point, should be removed or used
* updates a single preference if the query fails
* it attempts to insert the preference instead
* @package User
* @catagory Class
* @todo Do a has_preference_access check
*/
- function update_preference($preference_id, $value, $username=0) {
+ function update_preference($preference_id, $value, $user_id=0) {
if (!has_preference_access(get_preference_name($preference_id))) {
return false;
}
- if (!$username) {
- $username = $this->username;
+ if (!$user_id) {
+ $user_id = $this->id;
}
- if (!conf('use_auth')) { $username = '-1'; }
+ if (!conf('use_auth')) { $user_id = '-1'; }
$value = sql_escape($value);
$preference_id = sql_escape($preference_id);
- $username = sql_escape($username);
+ $user_id = sql_escape($user_id);
- $sql = "UPDATE user_preference SET value='$value' WHERE user='$username' AND preference='$preference_id'";
+ $sql = "UPDATE user_preference SET value='$value' WHERE user='$user_id' AND preference='$preference_id'";
- $db_results = @mysql_query($sql, dbh());
+ $db_results = mysql_query($sql, dbh());
} // update_preference