From e7fea90327419214531371543662056c1398470d Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Sat, 13 Aug 2005 04:30:26 +0000 Subject: new mpd mojo from rosensama and rperkins --- lib/class/playlist.class.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/class/playlist.class.php') 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); } } -- cgit