summaryrefslogtreecommitdiffstats
path: root/lib/class/playlist.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/class/playlist.class.php')
-rw-r--r--lib/class/playlist.class.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/class/playlist.class.php b/lib/class/playlist.class.php
index b17eadc6..7fa55492 100644
--- a/lib/class/playlist.class.php
+++ b/lib/class/playlist.class.php
@@ -186,18 +186,26 @@ class Playlist {
/*!
@function add_songs
@discussion Reads an array of song_ids to add to the playlist
+ @param $song_ids the array of song_ids
+ @param $is_ordered boolean, if true insert in order submitted, not by track number
*/
- function add_songs($song_ids) {
+ function add_songs($song_ids, $is_ordered = false) {
$dbh = dbh();
if ($this->id && isset($song_ids) && is_array($song_ids)) {
+ $count = 0;
foreach ($song_ids as $song_id) {
+ if( $is_ordered ) {
+ $track_num = $count++;
+ } else {
+ $track_num = $song->track;
+ }
$song = new Song($song_id);
if (isset($song->id)) {
$sql = "INSERT INTO playlist_data" .
" (playlist, song, track)" .
- " VALUES ('$this->id', '$song->id', '$song->track')";
+ " VALUES ('$this->id', '$song->id', '$track_num')";
$db_results = mysql_query($sql, $dbh);
}
}