summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/class/album.class.php47
-rw-r--r--lib/class/artist.class.php21
-rw-r--r--lib/class/catalog.class.php22
-rw-r--r--lib/class/playlist.class.php4
-rw-r--r--lib/class/rating.class.php4
-rw-r--r--lib/playlist.lib.php33
-rw-r--r--lib/ui.lib.php32
7 files changed, 100 insertions, 63 deletions
diff --git a/lib/class/album.class.php b/lib/class/album.class.php
index df9d06b3..86ef3af4 100644
--- a/lib/class/album.class.php
+++ b/lib/class/album.class.php
@@ -105,6 +105,30 @@ class Album {
} // get_songs
+ /**
+ * get_song_ids
+ * This returns an array of the song id's that are on this album. This is used by the
+ * show_songs function and can be pased and artist if you so desire to limit it to that
+ */
+ function get_song_ids($artist='') {
+
+ /* If they pass an artist then constrain it based on the artist as well */
+ if ($artist) {
+ $artist_sql = " AND artist='" . sql_escape($artist) . "'";
+ }
+
+ $sql = "SELECT id FROM song WHERE album='" . sql_escape($this->id) . "' $artist_sql ORDER BY track";
+ $db_results = mysql_query($sql, dbh());
+
+ $results = array();
+
+ while ($r = mysql_fetch_assoc($db_results)) {
+ $results[] = $r['id'];
+ }
+
+ return $results;
+
+ } // get_song_ids
/*!
@function format_album
@@ -466,29 +490,6 @@ class Album {
} // find_art
- /*!
- @function get_song_ids
- @discussion returns a list of song_ids on the album
- get_songs returns a list of song objects
- */
- // it seems get_songs really should call this,
- // but I don't feel comfortable imposing that - RCR
- function get_song_ids( $limit = 0 ) {
-
- $results = array();
- $sql = "SELECT id FROM song WHERE album='$this->id' ORDER BY track, title";
-
- if ($limit) { $sql .= " LIMIT $limit"; }
-
- $db_results = mysql_query($sql, dbh());
-
- while ($r = mysql_fetch_object($db_results)) {
- $results[] = $r->id;
- }
-
- return $results;
- } // get_song_ids
-
} //end of album class
?>
diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php
index 961b5991..173fe884 100644
--- a/lib/class/artist.class.php
+++ b/lib/class/artist.class.php
@@ -67,7 +67,7 @@ class Artist {
function get_info() {
/* Grab the basic information from the catalog and return it */
- $sql = "SELECT * FROM artist WHERE id='$this->id'";
+ $sql = "SELECT * FROM artist WHERE id='" . sql_escape($this->id) . "'";
$db_results = mysql_query($sql, dbh());
$results = mysql_fetch_object($db_results);
@@ -112,6 +112,24 @@ class Artist {
} // get_songs
+ /**
+ * get_song_ids
+ * This gets an array of song ids that are assoicated with this artist. This is great for using
+ * with the show_songs function
+ */
+ function get_song_ids() {
+
+ $sql = "SELECT id FROM song WHERE artist='" . sql_escape($this->id) . "' ORDER BY album, track";
+ $db_results = mysql_query($sql, dbh());
+
+ while ($r = mysql_fetch_assoc($db_results)) {
+ $results[] = $r['id'];
+ }
+
+ return $results;
+
+ } // get_song_ids
+
/*!
@function get_random_songs
@discussion gets a random number, and
@@ -265,7 +283,6 @@ class Artist {
/* Set Vars */
$web_path = conf('web_path');
-
$albums = $this->get_albums();
$this->format_artist();
$artist = $this;
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php
index dcbf074e..19cfd0ba 100644
--- a/lib/class/catalog.class.php
+++ b/lib/class/catalog.class.php
@@ -1668,7 +1668,13 @@ class Catalog {
/* If not found create */
else {
- $sql = "INSERT INTO artist (name, prefix) VALUES ('$artist', '$prefix')";
+ $prefix_txt = 'NULL';
+
+ if ($prefix) {
+ $prefix_txt = "'$prefix'";
+ }
+
+ $sql = "INSERT INTO artist (name, prefix) VALUES ('$artist', $prefix_txt)";
$db_results = mysql_query($sql, dbh());
$artist_id = mysql_insert_id(dbh());
@@ -1744,8 +1750,13 @@ class Catalog {
/* If not found create */
else {
+ $prefix_txt = 'NULL';
+
+ if ($prefix) {
+ $prefix_txt = "'$prefix'";
+ }
- $sql = "INSERT INTO album (name, prefix,year) VALUES ('$album', '$prefix','$album_year')";
+ $sql = "INSERT INTO album (name, prefix,year) VALUES ('$album',$prefix_txt,'$album_year')";
$db_results = mysql_query($sql, dbh());
$album_id = mysql_insert_id(dbh());
@@ -1780,9 +1791,10 @@ class Catalog {
@param $genre The name of the genre
*/
function check_genre($genre) {
-
- if (!$genre) {
- return false;
+
+ /* If a genre isn't specified force one */
+ if (strlen($genre) < 1) {
+ $genre = "Unknown (Orphaned)";
}
if ($this->genres[$genre]) {
diff --git a/lib/class/playlist.class.php b/lib/class/playlist.class.php
index a3455d7f..0ab165cd 100644
--- a/lib/class/playlist.class.php
+++ b/lib/class/playlist.class.php
@@ -76,8 +76,12 @@ class Playlist {
*/
function get_track($id) {
+ $sql = "SELECT track FROM playlist_data WHERE id='" . sql_escape($id) . "'";
+ $db_results = mysql_query($sql, dbh());
+ $result = mysql_fetch_assoc($db_results);
+ return $result['track'];
} // get_track
diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php
index f9dd0794..136d212e 100644
--- a/lib/class/rating.class.php
+++ b/lib/class/rating.class.php
@@ -44,10 +44,12 @@ class Rating {
$this->id = $id;
$this->type = $type;
-
if (intval($id) > 1) {
$this->get_average();
}
+ else {
+ $this->rating='0';
+ }
} // Rating
diff --git a/lib/playlist.lib.php b/lib/playlist.lib.php
index 0d0e3fe6..f312b2a2 100644
--- a/lib/playlist.lib.php
+++ b/lib/playlist.lib.php
@@ -33,6 +33,8 @@
*/
function show_playlists() {
+ show_playlist_menu();
+
/* Always show yours first */
$playlists = get_playlists('private');
$type = 'Private';
@@ -53,6 +55,37 @@ function show_playlists() {
} // show_playlists
/**
+ * show_playlist
+ * This function takes a playlist object and calls show_songs after
+ * runing get_items()
+ */
+function show_playlist($playlist) {
+
+ /* Create the Playlist */
+ $song_ids = $playlist->get_items();
+
+ show_playlist_menu();
+
+ if (count($song_ids) > 0) {
+ show_songs($song_ids, $playlist);
+ }
+ else {
+ echo "<div class=\"text-box\">" . _("No songs in this playlist.") . "</div>\n";
+ }
+
+} // show_playlist
+
+/**
+ * show_playlist_menu
+ * This shows a little pretty box that contains the playlist 'functions'
+ */
+function show_playlist_menu() {
+
+ require (conf('prefix') . '/templates/show_playlist_box.inc.php');
+
+} // show_playlist_menu
+
+/**
* get_playlists
* This function takes private,adminprivate or public and returns an array of playlist objects
* that match, it checks permission
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index 2cf05a46..2a779ffe 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -204,19 +204,6 @@ if (!function_exists('_')) {
} // if _ isn't defined
/**
- * show_playlist_menu
- * playlist functions
- */
-function show_playlist_menu () {
-
- echo "<br /><span class=\"header2\">" . _("Playlist Actions") . ": <a href=\"" . conf('web_path') . "/playlist.php?action=new\">" . _("New") ."</a> | ";
- echo "<a href=\"" . conf('web_path') . "/playlist.php\"> " . _("View All") . "</a> | ";
- echo "<a href=\"" . conf('web_path') . "/playlist.php?action=show_import_playlist\"> " . _("Import") . "</a>";
- echo "</span><br /><br />";
-
-} // show_playlist_menu
-
-/**
* show_admin_menu
* shows the admin menu
*/
@@ -442,25 +429,6 @@ function show_edit_profile($username) {
} // show_edit_profile
/**
- * show_playlist
- * This function takes a playlist object and calls show_songs after
- * runing get_items()
- */
-function show_playlist($playlist) {
-
- /* Create the Playlist */
- $song_ids = $playlist->get_items();
-
- if (count($song_ids) > 0) {
- show_songs($song_ids, $playlist->id);
- }
- else {
- echo "<div class=\"text-box\">" . _("No songs in this playlist.") . "</div>\n";
- }
-
-} // show_playlist
-
-/**
* show_play_selected
* this shows the playselected/add to playlist
* box, which includes a little javascript