summaryrefslogtreecommitdiffstats
path: root/lib/class/rating.class.php
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-02-11 06:13:21 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-02-11 06:13:21 +0000
commit949d7bb12fe9de9ccf3d2958bccde4354ab04d9b (patch)
tree7228810d63f0823b1557b4b33ecd29f1bf194328 /lib/class/rating.class.php
parent66de7ffff1c95e5bb415f1c3b56966f2d9916864 (diff)
downloadampache-949d7bb12fe9de9ccf3d2958bccde4354ab04d9b.tar.gz
ampache-949d7bb12fe9de9ccf3d2958bccde4354ab04d9b.tar.bz2
ampache-949d7bb12fe9de9ccf3d2958bccde4354ab04d9b.zip
* Fixed xmlrpc, hopefully
* Added min count filter to browse by artist * Fixed ratings to show yours, not average if rated * other misc fixes
Diffstat (limited to 'lib/class/rating.class.php')
-rw-r--r--lib/class/rating.class.php24
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php
index e79ea0ef..32a85253 100644
--- a/lib/class/rating.class.php
+++ b/lib/class/rating.class.php
@@ -1,13 +1,12 @@
<?php
/*
- Copyright (c) 2001 - 2006 Ampache.org
+ Copyright (c) 2001 - 2007 Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
+ modify it under the terms of the GNU General Public License v2
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -44,12 +43,15 @@ class Rating {
$this->id = intval($id);
$this->type = sql_escape($type);
- if (intval($id) > 1) {
+ // Check for the users rating
+ if ($rating = $this->get_user($GLOBALS['user']->id)) {
+ $this->rating = $rating;
+ }
+ else {
$this->get_average();
}
- else {
- $this->rating='0';
- }
+
+ return true;
} // Rating
@@ -58,11 +60,11 @@ class Rating {
* Get the user's rating this is based off the currently logged
* in user. It returns the value
*/
- function get_user($username) {
+ function get_user($user_id) {
- $username = sql_escape($username);
+ $user_id = sql_escape($user_id);
- $sql = "SELECT rating FROM ratings WHERE user='$username' AND object_id='$this->id' AND object_type='$this->type'";
+ $sql = "SELECT rating FROM ratings WHERE user='$user_id' AND object_id='$this->id' AND object_type='$this->type'";
$db_results = mysql_query($sql, dbh());
$results = mysql_fetch_assoc($db_results);