summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdocs/CHANGELOG1
-rw-r--r--lib/class/album.class.php18
-rw-r--r--lib/class/artist.class.php26
-rw-r--r--stream.php20
-rw-r--r--templates/show_user_stats.inc.php6
5 files changed, 45 insertions, 26 deletions
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index 2e698669..94a87567 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -4,6 +4,7 @@
--------------------------------------------------------------------------
v.3.4-Alpha1
+ - Added Play links for Favorite Artists/Albums/Songs
- Fixed an issue with the random album selection that was causing
a full table scan, which could lead to poor performance
with large databases
diff --git a/lib/class/album.class.php b/lib/class/album.class.php
index 29dc9ee2..5e44af8b 100644
--- a/lib/class/album.class.php
+++ b/lib/class/album.class.php
@@ -93,20 +93,20 @@ class Album {
} // _get_info
- /*!
- @function get_songs
- @discussion gets the songs for this album
- */
- function get_songs($limit = 0) {
+ /**
+ * get_songs
+ * gets the songs for this album
+ */
+ public function get_songs($limit = 0) {
$results = array();
- $sql = "SELECT id FROM song WHERE album='$this->id' ORDER BY track, title";
+ $sql = "SELECT `id` FROM `song` WHERE `album`='$this->id' ORDER BY `track`, `title`";
if ($limit) { $sql .= " LIMIT $limit"; }
- $db_results = mysql_query($sql, dbh());
+ $db_results = Dba::query($sql);
- while ($r = mysql_fetch_object($db_results)) {
- $results[] = new Song($r->id);
+ while ($r = Dba::fetch_assoc($db_results)) {
+ $results[] = $r['id'];
}
return $results;
diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php
index 18fa31cf..0de280c0 100644
--- a/lib/class/artist.class.php
+++ b/lib/class/artist.class.php
@@ -25,11 +25,11 @@
class Artist {
/* Variables from DB */
- var $id;
- var $name;
- var $songs;
- var $albums;
- var $prefix;
+ public $id;
+ public $name;
+ public $songs;
+ public $albums;
+ public $prefix;
/**
* Artist
@@ -91,17 +91,17 @@ class Artist {
} // get_albums
- /*!
- @function get_songs
- @discussion gets the songs for this artist
- */
+ /**
+ * get_songs
+ * gets the songs for this artist
+ */
function get_songs() {
- $sql = "SELECT song.id FROM song WHERE song.artist='" . sql_escape($this->id) . "'";
- $db_results = mysql_query($sql, dbh());
+ $sql = "SELECT `song`.`id` FROM `song` WHERE `song`.`artist`='" . Dba::escape($this->id) . "'";
+ $db_results = Dba::query($sql);
- while ($r = mysql_fetch_assoc($db_results)) {
- $results[] = new Song($r['id']);
+ while ($r = Dba::fetch_assoc($db_results)) {
+ $results[] = $r['id'];
}
return $results;
diff --git a/stream.php b/stream.php
index 98c78c8c..c2ccedf8 100644
--- a/stream.php
+++ b/stream.php
@@ -19,7 +19,7 @@
*/
-require 'lib/init.php';
+require_once 'lib/init.php';
/* If we are running a demo, quick while you still can! */
if (Config::get('demo_mode') || !$GLOBALS['user']->has_access('25')) {
@@ -56,6 +56,24 @@ switch ($action) {
$tmp_playlist = new tmpPlaylist($_REQUEST['tmpplaylist_id']);
$song_ids = $tmp_playlist->get_items();
break;
+ case 'play_favorite':
+ $data = $GLOBALS['user']->get_favorites($_REQUEST['type']);
+ $song_ids = array();
+ switch ($_REQUEST['type']) {
+ case 'artist':
+ case 'album':
+ foreach ($data as $value) {
+ $songs = $value->get_songs();
+ $song_ids = array_merge($song_ids,$songs);
+ }
+ break;
+ case 'song':
+ foreach ($data as $value) {
+ $song_ids[] = $value->id;
+ }
+ break;
+ } // end switch on type
+ break;
case 'single_song':
$song_ids[] = scrub_in($_REQUEST['song_id']);
break;
diff --git a/templates/show_user_stats.inc.php b/templates/show_user_stats.inc.php
index 2e9e4f84..b9a9fd23 100644
--- a/templates/show_user_stats.inc.php
+++ b/templates/show_user_stats.inc.php
@@ -26,7 +26,7 @@
<?php
if (count($favorite_artists)) {
$items = $working_user->format_favorites($favorite_artists);
- $title = '<a href="' . Config::get('web_path') . '/stats.php?action=play_favorite&amp;type=artists">' .
+ $title = '<a href="' . Config::get('web_path') . '/stream.php?action=play_favorite&amp;type=artist">' .
get_user_icon('all') . '</a>&nbsp;' . _('Favorite Artists');
show_info_box($title,'artist',$items);
}
@@ -39,7 +39,7 @@
<?php
if (count($favorite_albums)) {
$items = $working_user->format_favorites($favorite_albums);
- $title = '<a href="' . Config::get('web_path') . '/stats.php?action=play_favorite&amp;type=albums">' .
+ $title = '<a href="' . Config::get('web_path') . '/stream.php?action=play_favorite&amp;type=album">' .
get_user_icon('all') . '</a>&nbsp;' . _('Favorite Albums');
show_info_box($title,'album',$items);
}
@@ -52,7 +52,7 @@
<?php
if (count($favorite_songs)) {
$items = $working_user->format_favorites($favorite_songs);
- $title = '<a href="' . Config::get('web_path') . '/stats.php?action=play_favorite&amp;type=songs">' .
+ $title = '<a href="' . Config::get('web_path') . '/stream.php?action=play_favorite&amp;type=song">' .
get_user_icon('all') . '</a>&nbsp;' . _('Favorite Songs');
show_info_box($title,'your_song',$items);
}