summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--albums.php14
-rw-r--r--artists.php9
-rwxr-xr-xdocs/CHANGELOG3
-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
-rw-r--r--modules/lib.php37
-rw-r--r--modules/libglue/session.php4
-rw-r--r--song.php3
-rw-r--r--templates/show_artist.inc23
-rw-r--r--templates/show_artist_box.inc.php44
-rw-r--r--templates/show_playlist_box.inc.php31
-rw-r--r--templates/show_songs.inc13
17 files changed, 203 insertions, 141 deletions
diff --git a/albums.php b/albums.php
index 02e591b6..ee97351c 100644
--- a/albums.php
+++ b/albums.php
@@ -46,20 +46,16 @@ if ($_REQUEST['action'] === 'clear_art') {
} // clear_art
// if we have album
elseif (isset($album)) {
- $album = new Album($album);
+ $album = new Album($_REQUEST['album']);
$album->format_album();
- $artist_obj = new Artist($artist_obj);
-
require (conf('prefix') . "/templates/show_album.inc");
- if (isset($artist) && $artist_obj->name == "Unknown (Orphaned)" ) {
- $song_ids = get_song_ids_from_artist_and_album($artist, $album->id);
- }
- else {
- $song_ids = get_song_ids_from_album($album->id);
- }
+ /* Get the song ids for this album */
+ $song_ids = $album->get_song_ids($_REQUEST['artist']);
+
show_songs($song_ids,0,$album);
+
} // isset(album)
// Finds the Album art from amazon
diff --git a/artists.php b/artists.php
index a46396ee..cbaa6e0a 100644
--- a/artists.php
+++ b/artists.php
@@ -39,14 +39,15 @@ switch($action) {
case 'show':
case 'Show':
show_alphabet_list('artists','artists.php');
- $artist = new Artist(scrub_in($_REQUEST['artist']));
+ $artist = new Artist($_REQUEST['artist']);
$artist->show_albums();
break;
case 'show_all_songs':
- $artist = get_artist_name(scrub_in($_REQUEST['artist']));
- echo "<h2>" . _("All songs by") . " $artist</h2>";
- $song_ids = get_song_ids_from_artist($_REQUEST['artist']);
+ $artist = new Artist($_REQUEST['artist']);
+ $artist->format_artist();
+ $song_ids = $artist->get_song_ids();
+ require(conf('prefix') . '/templates/show_artist_box.inc.php');
show_songs($song_ids);
break;
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index 625b6f43..d60b2d32 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -4,6 +4,9 @@
--------------------------------------------------------------------------
v.3.3.2-Beta1
+ - Added the Import From File action for playlists back. The link
+ was just missing
+ - Fixed SQL errors with Windows + Mysql5.x (Thx WarrenG)
- Rewrote entire Playlist class and document to use the new id
field in database, also added support for playlist tracks
that are based on search critera. NOT FINISHED!
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
diff --git a/modules/lib.php b/modules/lib.php
index b1eda672..ec833ca2 100644
--- a/modules/lib.php
+++ b/modules/lib.php
@@ -228,28 +228,6 @@ function get_song_ids_from_album ($album) {
}
-function get_song_ids_from_artist ($artist) {
-
- global $settings;
- $dbh = dbh();
-
- $song_ids = array();
- $artist = sql_escape($artist);
-
- $query = "SELECT id FROM song" .
- " WHERE artist = '$artist'" .
- " ORDER BY album, track";
-
- $db_result = mysql_query($query, $dbh);
-
- while ( $r = mysql_fetch_object($db_result) ) {
- $song_ids[] = $r->id;
- }
-
- return $song_ids;
-}
-
-
/*
* get_song_ids_from_artist_and_album();
*
@@ -313,21 +291,12 @@ function get_songs_from_type ($type, $results, $artist_id = 0) {
/* Lets tie it to album too, so we can show art ;) */
/*********************************************************/
/* One symbol, m(__)m */
-function show_songs ($song_ids, $playlist_id=0, $album=0) {
+function show_songs ($song_ids, $playlist, $album=0) {
$dbh = dbh();
// Get info about current user
- $user = new User($_SESSION['userdata']['username']);
-
- // Get info about playlist owner
- if (isset($playlist_id) && $playlist_id != 0) {
- $sql = "SELECT user FROM playlist WHERE id = '$playlist_id'";
- $db_result = mysql_query($sql, $dbh);
- if ($r = mysql_fetch_array($db_result)) {
- $pluser = get_user_byid($r[0]);
- }
- }
+ $user = $GLOBALS['user'];
$totaltime = 0;
$totalsize = 0;
@@ -336,7 +305,7 @@ function show_songs ($song_ids, $playlist_id=0, $album=0) {
return true;
-}// function show_songs
+} // function show_songs
diff --git a/modules/libglue/session.php b/modules/libglue/session.php
index 9aa7c70b..7f18ce8a 100644
--- a/modules/libglue/session.php
+++ b/modules/libglue/session.php
@@ -147,8 +147,8 @@ function make_local_session_only($data,$id=0)
$local_expirecol = libglue_param('local_expirecol');
$local_typecol = libglue_param('local_typecol');
$sql= "INSERT INTO $local_table ".
- " ($local_sid,$local_usercol,$local_typecol)".
- " VALUES ('$id','$username','$type')";
+ " ($local_sid,$local_usercol,$local_typecol,value)".
+ " VALUES ('$id','$username','$type','')";
$db_result = mysql_query($sql, $local_dbh);
if($db_result) return TRUE;
diff --git a/song.php b/song.php
index 43758d44..248cf490 100644
--- a/song.php
+++ b/song.php
@@ -92,7 +92,8 @@ elseif ( $_REQUEST['playlist_id'] AND $action != 'play_selected') {
}
}
elseif ( $_REQUEST['artist'] ) {
- $song_ids = get_song_ids_from_artist( $_REQUEST['artist'] );
+ $artist = new Artist($_REQUEST['artist']);
+ $song_ids = $artist->get_song_ids();
}
/*!
@action Random Song
diff --git a/templates/show_artist.inc b/templates/show_artist.inc
index 8e125740..a71ddaca 100644
--- a/templates/show_artist.inc
+++ b/templates/show_artist.inc
@@ -26,28 +26,7 @@ $artist_id = $artist->id;
$web_path = conf('web_path');
?>
<br />
-<table class="text-box">
-<tr>
- <td>
- <span class="header1"><?php print _("Albums by") . " " . $artist->full_name; ?></span>
- <ul>
- <?php
- if (conf('ratings')) {
- show_rating($artist->id,'artist');
- } // end if ratings
- echo "<br />\n";
- ?>
- <li><a href="<?php print $web_path; ?>/artists.php?action=show_all_songs&amp;artist=<?php print $artist_id; ?>"><?php print _("Show All Songs By") . " " . $artist->full_name; ?></a></li>
- <li><a href="<?php print $web_path; ?>/song.php?action=m3u&amp;artist=<?php print $artist_id; ?>"><?php print _("Play All Songs By") . " " . $artist->full_name; ?></a></li>
- <li><a href="<?php print $web_path; ?>/song.php?action=m3u&amp;artist_random=<?php print $artist_id; ?>"><?php print _("Play Random Songs By") . " " . $artist->full_name; ?></a></li>
- <?php if ($user->has_access('100')) { ?>
- <li><a href="<?php echo $web_path; ?>/artists.php?action=update_from_tags&amp;artist=<?php print $artist_id; ?>"><?php print _("Update from tags"); ?></a></li>
- <li><a href="<?php echo $web_path; ?>/artists.php?action=show_rename&amp;artist=<?php echo $artist_id; ?>"><?php echo _("Rename Artist"); ?></a></li>
- <?php } ?>
- </ul>
- </td>
-</tr>
-</table>
+<?php require (conf('prefix') . '/templates/show_artist_box.inc.php'); ?>
<!-- *** Multi-Album Art Display Thx MrBlahh Updated by clader *** -->
<br />
<form name="songs" method="post" enctype="multipart/form-data" action="artists.php">
diff --git a/templates/show_artist_box.inc.php b/templates/show_artist_box.inc.php
new file mode 100644
index 00000000..83908e94
--- /dev/null
+++ b/templates/show_artist_box.inc.php
@@ -0,0 +1,44 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2006 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+?>
+<table class="text-box">
+<tr>
+ <td>
+ <span class="header1"><?php print _("Albums by") . " " . $artist->full_name; ?></span>
+ <ul>
+ <?php
+ if (conf('ratings')) {
+ show_rating($artist->id,'artist');
+ } // end if ratings
+ echo "<br />\n";
+ ?>
+ <li><a href="<?php print $web_path; ?>/artists.php?action=show_all_songs&amp;artist=<?php print $artist_id; ?>"><?php print _("Show All Songs By") . " " . $artist->full_name; ?></a></li>
+ <li><a href="<?php print $web_path; ?>/song.php?action=m3u&amp;artist=<?php print $artist_id; ?>"><?php print _("Play All Songs By") . " " . $artist->full_name; ?></a></li>
+ <li><a href="<?php print $web_path; ?>/song.php?action=m3u&amp;artist_random=<?php print $artist_id; ?>"><?php print _("Play Random Songs By") . " " . $artist->full_name; ?></a></li>
+ <?php if ($user->has_access('100')) { ?>
+ <li><a href="<?php echo $web_path; ?>/artists.php?action=update_from_tags&amp;artist=<?php print $artist_id; ?>"><?php print _("Update from tags"); ?></a></li>
+ <li><a href="<?php echo $web_path; ?>/artists.php?action=show_rename&amp;artist=<?php echo $artist_id; ?>"><?php echo _("Rename Artist"); ?></a></li>
+ <?php } ?>
+ </ul>
+ </td>
+</tr>
+</table>
diff --git a/templates/show_playlist_box.inc.php b/templates/show_playlist_box.inc.php
new file mode 100644
index 00000000..ee9f314c
--- /dev/null
+++ b/templates/show_playlist_box.inc.php
@@ -0,0 +1,31 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2006 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+?>
+
+<table class="text-box">
+<tr><td>
+ <span class="header1"><?php echo _('Playlist Actions'); ?></span><br />
+ &nbsp;&nbsp;&nbsp;<a href="<?php echo conf('web_path'); ?>/playlist.php?action=new"><?php echo _('Create New Playlist'); ?></a><br />
+ &nbsp;&nbsp;&nbsp;<a href="<?php echo conf('web_path'); ?>/playlist.php"><?php echo _('View All Playlists'); ?></a><br />
+ &nbsp;&nbsp;&nbsp;<a href="<?php echo conf('web_path'); ?>/playlist.php?action=show_import_playlist"><?php echo _('Import From File'); ?></a><br />
+</td></tr>
+</table>
diff --git a/templates/show_songs.inc b/templates/show_songs.inc
index db69d7e4..8329588b 100644
--- a/templates/show_songs.inc
+++ b/templates/show_songs.inc
@@ -55,11 +55,12 @@ if (is_object($playlist) && ($GLOBALS['user']->username == $playlist->user || $G
<?php
/* FIXME: don't even get me started with how many things are wrong with this code */
foreach ($song_ids as $song_id) {
-
+
/* Arr matey crapy code abounds! */
- if ($playlist_owner) {
+ if (is_object($playlist)) {
if ($song_id['song']) {
$song = new Song($song_id['song']);
+ $track_id = $song_id['id'];
}
else {
$song = new Song();
@@ -90,11 +91,11 @@ if (is_object($playlist) && ($GLOBALS['user']->username == $playlist->user || $G
<input type="checkbox" name="song[]" value="<?php echo $song->id; ?>" id="song_<?php echo $song->id; ?>" />
</td>
<?php
- if (is_object($playlist) && ($GLOBALS['user']->username == $playlist->user || $GLOBALS['user']->has_access('100'))) {
- /* $tracknum = $playlist->get_track($track_id); */
+ if ($playlist_owner) {
+ $tracknum = $playlist->get_track($track_id);
?>
<td>
- <input type="text" tabindex="<?php echo $tab; ?>" size="3" name="<?php echo "tr_" . $song->id; ?>" value="<?php echo $tracknum ?>" onchange="<?php echo "document.getElementById('song_" . $track_id . "').checked='checked';"; ?>" />
+ <input type="text" tabindex="<?php echo $tab; ?>" size="3" name="<?php echo "tr_" . $song->id; ?>" value="<?php echo $tracknum; ?>" onchange="<?php echo "document.getElementById('song_" . $track_id . "').checked='checked';"; ?>" />
</td>
<?php $tab++; } ?>
<td>
@@ -161,7 +162,7 @@ if (is_object($playlist) && ($GLOBALS['user']->username == $playlist->user || $G
?>
<tr class="table-header">
<td></td>
- <?php if (isset($playlist_id) && $playlist_id != 0 && ($user->username == $pluser->username || $user->access === 'admin')) { ?> <td></td> <?php } ?>
+ <?php if (is_object($playlist)) { ?> <td></td> <?php } ?>
<td><?php echo _("Total"); ?>:</td>
<td nowrap="nowrap"><?php echo $num; ?> song(s)</td>
<td></td>