From 598a200b969da093a99153173129257da080f71b Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Mon, 30 Oct 2006 04:46:45 +0000 Subject: ok this is ugly but it works --- lib/class/stream.class.php | 31 ++++++++++++++++++++-- lib/class/tmp_playlist.class.php | 57 ++++++++++++++++++++++++++++++++++++++-- lib/preferences.php | 13 ++++----- 3 files changed, 91 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php index cda7a1d3..7d0566bb 100644 --- a/lib/class/stream.class.php +++ b/lib/class/stream.class.php @@ -227,9 +227,36 @@ class Stream { /* First insert the songs we've got into * a tmp_playlist */ + $tmp_playlist = new tmpPlaylist(); + $playlist_id = $tmp_playlist->create($this->sess,'xspf','song',''); + $tmp_playlist = new tmpPlaylist($playlist_id); - /* Echo some ugly javascript to make it pop-open the player */ - + /* Add the songs to this new playlist */ + foreach ($this->songs as $song_id) { + $tmp_playlist->add_object($song_id); + } // end foreach + + /* Build the extra info we need to have it pass */ + $play_info = "?action=show&tmpplaylist_id=" . $tmp_playlist->id; + + // start ugly evil javascript code + //FIXME: This needs to go in a template, here for now though + echo "\n"; + echo "" . conf('site_title') . "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; } // create_xspf_player diff --git a/lib/class/tmp_playlist.class.php b/lib/class/tmp_playlist.class.php index 8829c41e..acd78329 100644 --- a/lib/class/tmp_playlist.class.php +++ b/lib/class/tmp_playlist.class.php @@ -89,7 +89,7 @@ class tmpPlaylist { $db_results = mysql_query($sql, dbh()); while ($results = mysql_fetch_assoc($db_results)) { - $items[] = $results['id']; + $items[] = $results['object_id']; } return $items; @@ -97,7 +97,7 @@ class tmpPlaylist { } // get_items /** - * ceate + * create * This function initializes a new tmpPlaylist it is assoicated with the current * session rather then a user, as you could have same user multiple locations */ @@ -114,10 +114,63 @@ class tmpPlaylist { $id = mysql_insert_id(dbh()); + /* Clean any other playlists assoicated with this sessoin */ + $this->delete($sessid,$id); + return $id; } // create + /** + * delete + * This deletes any other tmp_playlists assoicated with this + * session + */ + function delete($sessid,$id) { + + $sessid = sql_escape($sessid); + $id = sql_escape($id); + + $sql = "DELETE FROM tmp_playlist WHERE session='$sessid' AND id != '$id'"; + $db_results = mysql_query($sql,dbh()); + + /* Remove assoicated tracks */ + $this->prune_tracks(); + + return true; + + } // delete + + /** + * prune_tracks + * This prunes tracks that don't have playlists + */ + function prune_tracks() { + + $sql = "DELETE FROM tmp_playlist_data USING tmp_playlist_data " . + "LEFT JOIN tmp_playlist ON tmp_playlist_data.tmp_playlist=tmp_playlist.id " . + "WHERE tmp_playlist.id IS NULL"; + $db_results = mysql_query($sql,dbh()); + + } // prune_tracks + + /** + * add_object + * This adds the object of $this->object_type to this tmp playlist + */ + function add_object($object_id) { + + $object_id = sql_escape($object_id); + $playlist_id = sql_escape($this->id); + + $sql = "INSERT INTO tmp_playlist_data (`object_id`,`tmp_playlist`) " . + " VALUES ('$object_id','$playlist_id')"; + $db_results = mysql_query($sql, dbh()); + + return true; + + } // add_object + /** * vote * This function is called by users to vote on a system wide playlist diff --git a/lib/preferences.php b/lib/preferences.php index 8bd01020..0022911b 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -286,12 +286,13 @@ function create_preference_input($name,$value) { $var_name = $value . "_type"; ${$var_name} = "selected=\"selected\""; echo "\n"; break; case 'lang': -- cgit