diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-10-30 04:46:45 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-10-30 04:46:45 +0000 |
commit | 598a200b969da093a99153173129257da080f71b (patch) | |
tree | b9b12acc57a92063b3227f7dc495e62749449f19 /lib/class/tmp_playlist.class.php | |
parent | 07ad109268f038880d1bd1d4cda299cbff59b83a (diff) | |
download | ampache-598a200b969da093a99153173129257da080f71b.tar.gz ampache-598a200b969da093a99153173129257da080f71b.tar.bz2 ampache-598a200b969da093a99153173129257da080f71b.zip |
ok this is ugly but it works
Diffstat (limited to 'lib/class/tmp_playlist.class.php')
-rw-r--r-- | lib/class/tmp_playlist.class.php | 57 |
1 files changed, 55 insertions, 2 deletions
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,11 +114,64 @@ 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 * This adds the specified objects to the tmp_playlist and adds a 'vote' |