diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-06-07 07:20:01 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-06-07 07:20:01 +0000 |
commit | af2ff07a8174ac2796fa45337bcc5c70d870e0b1 (patch) | |
tree | 9ebaecb008ef72d3b07cc1984de6e8249a13719a /lib | |
parent | 96334a0e8c1c59077e6f9c067dbdee14f6b07be7 (diff) | |
download | ampache-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')
-rw-r--r-- | lib/class/artist.class.php | 39 | ||||
-rw-r--r-- | lib/class/rating.class.php | 39 | ||||
-rw-r--r-- | lib/rss.php | 10 |
3 files changed, 34 insertions, 54 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; diff --git a/lib/rss.php b/lib/rss.php index 0252aa6a..9801f092 100644 --- a/lib/rss.php +++ b/lib/rss.php @@ -28,9 +28,8 @@ function show_RSS ($type = 'artist',$username = 0) { header ("Content-Type: application/xml"); - $dbh = dbh(); - $web_path = conf('web_path'); - $rss_main_title = conf('rss_main_title'); + $web_path = Config::get('web_path'); + $rss_main_title = "Ampache :: Pour l'Amour de la Musique - RSS"; $rss_latestartist_title = "Ampache Latest Artists"; $rss_latestalbum_title = "Ampache Latest Albums"; @@ -39,9 +38,6 @@ function show_RSS ($type = 'artist',$username = 0) { $rss_popularsong_title = "Ampache Most Popular Songs"; $rss_recentlyplayed_title = "Ampache Recently Played"; - $rss_main_description = conf('rss_main_description'); - $rss_main_copyright = conf('rss_main_copyright'); - $rss_description = conf('rss_song_description'); $today = date("d-m-Y"); echo "<rss version=\"2.0\">\n"; @@ -57,7 +53,7 @@ switch ($type) { " WHERE object_type='album' AND date >= '$date'" . " GROUP BY object_id ORDER BY `count` DESC LIMIT 10"; - $db_result = mysql_query($sql, $dbh); + $db_result = Dba::query($sql); echo " <channel>\n <title>$rss_popularalbum_title</title>\n"; echo " <link>$web_path</link>\n <description>$rss_main_description</description>\n"; |