- +
- + +
- @@ -76,3 +80,16 @@
diff --git a/docs/CHANGELOG b/docs/CHANGELOG index ac69e5d3..9060e41f 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,10 @@ -------------------------------------------------------------------------- v.3.4-Alpha2 + - Added ability to delete songs from a saved playlist + - Added ability to create a new playlist based on active playlist + - Fixed the Playlist Method 'Send on Add' so that it works, the + 'Send and Clear' is still broken - Fixed Advanced random - Fixed missing artist name on Albums of the Moment - Added simple Playlist element view, non-editable diff --git a/images/icon_playlist_add.png b/images/icon_playlist_add.png new file mode 100644 index 00000000..d650552d Binary files /dev/null and b/images/icon_playlist_add.png differ diff --git a/lib/class/playlist.class.php b/lib/class/playlist.class.php index 0daff266..62628bb7 100644 --- a/lib/class/playlist.class.php +++ b/lib/class/playlist.class.php @@ -320,30 +320,30 @@ class Playlist { * if you want to add a dyn_song you need to use the one shot function * add_dyn_song */ - function add_songs($song_ids=array()) { + public function add_songs($song_ids=array()) { /* We need to pull the current 'end' track and then use that to * append, rather then integrate take end track # and add it to * $song->track add one to make sure it really is 'next' */ - $sql = "SELECT `track` FROM playlist_data WHERE `playlist`='" . $this->id . "' ORDER BY `track` DESC LIMIT 1"; - $db_results = mysql_query($sql, dbh()); - $data = mysql_fetch_assoc($db_results); + $sql = "SELECT `track` FROM `playlist_data` WHERE `playlist`='" . $this->id . "' ORDER BY `track` DESC LIMIT 1"; + $db_results = Dba::query($sql); + $data = Dba::fetch_assoc($db_results); $base_track = $data['track']; foreach ($song_ids as $song_id) { /* We need the songs track */ $song = new Song($song_id); - $track = sql_escape($song->track+$base_track); - $id = sql_escape($song->id); - $pl_id = sql_escape($this->id); + $track = Dba::escape($song->track+$base_track); + $id = Dba::escape($song->id); + $pl_id = Dba::escape($this->id); /* Don't insert dead songs */ if ($id) { - $sql = "INSERT INTO playlist_data (`playlist`,`song`,`track`) " . - " VALUES ('$pl_id','$id','$track')"; - $db_results = mysql_query($sql, dbh()); + $sql = "INSERT INTO `playlist_data` (`playlist`,`object_id`,`object_type`,`track`) " . + " VALUES ('$pl_id','$id','song','$track')"; + $db_results = Dba::query($sql); } // if valid id } // end foreach songs @@ -382,22 +382,22 @@ class Playlist { * This function creates an empty playlist, gives it a name and type * Assumes $GLOBALS['user']->id as the user */ - function create($name,$type) { + public static function create($name,$type) { - $name = sql_escape($name); - $type = sql_escape($type); - $user = sql_escape($GLOBALS['user']->id); + $name = Dba::escape($name); + $type = Dba::escape($type); + $user = Dba::escape($GLOBALS['user']->id); $date = time(); - $sql = "INSERT INTO playlist (`name`,`user`,`type`,`date`) " . - " VALUES ('$name','$user','$type','$date')"; - $db_results = mysql_query($sql, dbh()); + $sql = "INSERT INTO `playlist` (`name`,`user`,`type`,`genre`,`date`) " . + " VALUES ('$name','$user','$type','0','$date')"; + $db_results = Dba::query($sql); - $insert_id = mysql_insert_id(dbh()); + $insert_id = Dba::insert_id(); return $insert_id; - } //create_paylist + } // create /** * set_items diff --git a/lib/preferences.php b/lib/preferences.php index fe404331..6ab531fc 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -339,10 +339,11 @@ function create_preference_input($name,$value) { echo "\n"; break; case 'playlist_method': + ${$value} = ' selected="selected"'; echo "\n"; break; case 'transcode': diff --git a/server/playlist.ajax.php b/server/playlist.ajax.php index f2198faa..158e7fe2 100644 --- a/server/playlist.ajax.php +++ b/server/playlist.ajax.php @@ -39,6 +39,32 @@ switch ($_REQUEST['action']) { $results['browse_content'] = ob_get_contents(); ob_end_clean(); break; + case 'create': + // Pull the current active playlist items + $objects = $GLOBALS['user']->playlist->get_items(); + + $name = $GLOBALS['user']->username . ' - ' . date("d/m/Y H:i:s",time()); + + // generate the new playlist + $playlist_id = Playlist::create($name,'public'); + $playlist = new Playlist($playlist_id); + + // Itterate through and add them to our new playlist + foreach ($objects as $uid=>$object_data) { + // For now only allow songs on here, we'll change this later + if ($object_data['1'] == 'song') { + $songs[] = $object_data['0']; + } + } // object_data + + // Add our new songs + $playlist->add_songs($songs); + $playlist->format(); + ob_start(); + require_once Config::get('prefix') . '/templates/show_playlist.inc.php'; + $results['content'] = ob_get_contents(); + ob_end_clean(); + break; default: $results['rfc3514'] = '0x1'; break; diff --git a/server/stream.ajax.php b/server/stream.ajax.php new file mode 100644 index 00000000..744e0a3d --- /dev/null +++ b/server/stream.ajax.php @@ -0,0 +1,35 @@ + diff --git a/templates/header.inc.php b/templates/header.inc.php index 90f4782a..e4a95048 100644 --- a/templates/header.inc.php +++ b/templates/header.inc.php @@ -79,6 +79,8 @@ if (Config::get('use_rss')) { ?> + +