summaryrefslogtreecommitdiffstats
path: root/lib/class
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-06-07 07:20:01 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-06-07 07:20:01 +0000
commitaf2ff07a8174ac2796fa45337bcc5c70d870e0b1 (patch)
tree9ebaecb008ef72d3b07cc1984de6e8249a13719a /lib/class
parent96334a0e8c1c59077e6f9c067dbdee14f6b07be7 (diff)
downloadampache-af2ff07a8174ac2796fa45337bcc5c70d870e0b1.tar.gz
ampache-af2ff07a8174ac2796fa45337bcc5c70d870e0b1.tar.bz2
ampache-af2ff07a8174ac2796fa45337bcc5c70d870e0b1.zip
- Fixed Ratings
- Tweaked RSS, still needs work - Show Single artist mostly finished
Diffstat (limited to 'lib/class')
-rw-r--r--lib/class/artist.class.php39
-rw-r--r--lib/class/rating.class.php39
2 files changed, 31 insertions, 47 deletions
diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php
index 7a07785d..7de2f62d 100644
--- a/lib/class/artist.class.php
+++ b/lib/class/artist.class.php
@@ -71,20 +71,21 @@ class Artist {
} // _get_info
- /*!
- @function get_albums
- @discussion gets the albums for this artist
- //FIXME: Appears to not be used?
- */
- function get_albums($sql) {
+ /**
+ * get_albums
+ * gets the album ids that this artist is a part
+ * of
+ */
+ public function get_albums() {
$results = array();
-// $sql = "SELECT DISTINCT(album.id) FROM song,album WHERE song.album=album.id AND song.artist='$this->id' ORDER BY album.name";
- $db_results = mysql_query($sql, dbh());
+ $sql = "SELECT `album`.`id` FROM album LEFT JOIN `song` ON `song`.`album`=`album`.`id` " .
+ "WHERE `song`.`artist`='$this->id' GROUP BY `album`.`id` ORDER BY `album`.`name`,`album`.`year`";
+ $db_results = Dba::query($sql);
- while ($r = mysql_fetch_object($db_results)) {
- $results[] = new Album($r->id);
+ while ($r = Dba::fetch_assoc($db_results)) {
+ $results[] = $r['id'];
}
return $results;
@@ -287,24 +288,6 @@ class Artist {
}
} // merge
-
- /*!
- @function show_albums
- @discussion displays the show albums by artist page
- */
- function show_albums($sql = 0) {
-
- /* Set Vars */
- $web_path = conf('web_path');
-
- $albums = $this->get_albums($sql);
- $this->format_artist();
- $artist = $this;
-
- require (conf('prefix') . "/templates/show_artist.inc");
-
- } // show_albums
-
/*!
@function get_similar_artists
@discussion returns an array of artist (id,name) arrays that are similar in name
diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php
index 43200f90..99fa7612 100644
--- a/lib/class/rating.class.php
+++ b/lib/class/rating.class.php
@@ -38,13 +38,13 @@ class Rating {
* This is run every time a new object is created, it requires
* the id and type of object that we need to pull the raiting for
*/
- function Rating($id,$type) {
+ public function __construct($id,$type) {
$this->id = intval($id);
$this->type = Dba::escape($type);
// Check for the users rating
- if ($rating = $this->get_user($GLOBALS['user']->id)) {
+ if ($rating == $this->get_user($GLOBALS['user']->id)) {
$this->rating = $rating;
}
else {
@@ -53,23 +53,23 @@ class Rating {
return true;
- } // Rating
+ } // Constructor
/**
* get_user
* Get the user's rating this is based off the currently logged
* in user. It returns the value
*/
- function get_user($user_id) {
+ public function get_user($user_id) {
$user_id = Dba::escape($user_id);
- $sql = "SELECT rating FROM ratings WHERE user='$user_id' AND object_id='$this->id' AND object_type='$this->type'";
+ $sql = "SELECT `user_rating` FROM `rating` WHERE `user`='$user_id' AND `object_id`='$this->id' AND `object_type`='$this->type'";
$db_results = Dba::query($sql);
$results = Dba::fetch_assoc($db_results);
-
- return $results['rating'];
+
+ return $results['user_rating'];
} // get_user
@@ -80,9 +80,9 @@ class Rating {
* is no personal rating, and used for random play mojo. It sets
* $this->average_rating and returns the value
*/
- function get_average() {
+ public function get_average() {
- $sql = "SELECT user_rating as rating FROM ratings WHERE object_id='$this->id' AND object_type='$this->type'";
+ $sql = "SELECT `user_rating` AS `rating` FROM `rating` WHERE `object_id`='$this->id' AND `object_type`='$this->type'";
$db_results = Dba::query($sql);
$i = 0;
@@ -113,22 +113,23 @@ class Rating {
* This uses the currently logged in user for the 'user' who is rating
* the object. Returns true on success, false on failure
*/
- function set_rating($score) {
+ public function set_rating($score) {
- $score = sql_escape($score);
+ $score = Dba::escape($score);
/* Check if it exists */
- $sql = "SELECT id FROM ratings WHERE object_id='$this->id' AND object_type='$this->type' AND `user`='" . sql_escape($GLOBALS['user']->username) . "'";
- $db_results = mysql_query($sql, dbh());
+ $sql = "SELECT `id` FROM `rating` WHERE `object_id`='$this->id' AND `object_type`='$this->type' " .
+ "AND `user`='" . Dba::escape($GLOBALS['user']->id) . "'";
+ $db_results = Dba::query($sql);
- if ($existing = mysql_fetch_assoc($db_results)) {
- $sql = "UPDATE ratings SET user_rating='$score' WHERE id='" . $existing['id'] . "'";
- $db_results = mysql_query($sql, dbh());
+ if ($existing = Dba::fetch_assoc($db_results)) {
+ $sql = "UPDATE `rating` SET `user_rating`='$score' WHERE `id`='" . $existing['id'] . "'";
+ $db_results = Dba::query($sql);
}
else {
- $sql = "INSERT INTO ratings (`object_id`,`object_type`,`user_rating`,`user`) VALUES " .
- " ('$this->id','$this->type','$score','" . sql_escape($GLOBALS['user']->username) . "')";
- $db_results = mysql_query($sql, dbh());
+ $sql = "INSERT INTO `rating` (`object_id`,`object_type`,`user_rating`,`user`) VALUES " .
+ " ('$this->id','$this->type','$score','" . $GLOBALS['user']->id . "')";
+ $db_results = Dba::query($sql);
}
return true;