From 8e9678729653489a0839c14bc23d743e1509c319 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Mon, 30 Jul 2007 06:21:50 +0000 Subject: added your playlists with play link to the leftbar, no way to edit them yet --- lib/class/playlist.class.php | 90 ++++++++++++++++++++++++-------------------- lib/general.lib.php | 11 +++--- lib/playlist.lib.php | 32 ---------------- 3 files changed, 56 insertions(+), 77 deletions(-) (limited to 'lib') diff --git a/lib/class/playlist.class.php b/lib/class/playlist.class.php index a5a6fd75..f5f570ec 100644 --- a/lib/class/playlist.class.php +++ b/lib/class/playlist.class.php @@ -1,13 +1,13 @@ id = intval($playlist_id); + $this->id = intval($id); $info = $this->_get_info(); - $this->name = $info['name']; - $this->user = $info['user']; - $this->type = $info['type']; - $this->date = $info['date']; + + foreach ($info as $key=>$value) { + $this->$key = $value; + } } // Playlist @@ -59,17 +56,28 @@ class Playlist { * This is an internal (private) function that gathers the information for this object from the * playlist_id that was passed in. */ - function _get_info() { + private function _get_info() { - $sql = "SELECT * FROM `playlist` WHERE `id`='" . sql_escape($this->id) . "'"; - $db_results = mysql_query($sql, dbh()); + $sql = "SELECT * FROM `playlist` WHERE `id`='" . Dba::escape($this->id) . "'"; + $db_results = Dba::query($sql); - $results = mysql_fetch_assoc($db_results); + $results = Dba::fetch_assoc($db_results); return $results; } // _get_info + /** + * format + * This takes the current playlist object and gussies it up a little + * bit so it is presentable to the users + */ + public function format() { + + $this->f_link = '' . $this->name . ''; + + } // format + /** * get_track * Takes a playlist_data.id and returns the current track value for said entry @@ -90,16 +98,16 @@ class Playlist { * This returns an array of playlist songs that are in this playlist. Because the same * song can be on the same playlist twice they are key'd by the uid from playlist_data */ - function get_items() { - - $sql = "SELECT * FROM playlist_data WHERE playlist='" . sql_escape($this->id) . "' ORDER BY track"; - $db_results = mysql_query($sql, dbh()); + public function get_items() { - while ($r = mysql_fetch_assoc($db_results)) { + $results = array(); - $key = $r['id']; - $results[$key] = $r; + $sql = "SELECT * FROM `playlist_data` WHERE `playlist`='" . Dba::escape($this->id) . "' ORDER BY `track`"; + $db_results = Dba::query($sql); + while ($row = Dba::fetch_assoc($db_results)) { + $key = $row['id']; + $results[$key] = $row['song']; } // end while return $results; @@ -225,23 +233,25 @@ class Playlist { } // get_song_count /** - * has_access - * This takes no arguments. It looks at the currently logged in user (_SESSION) - * This accounts for admin powers and the access on a per list basis + * get_users + * This returns the specified users playlists as an array of + * playlist ids */ - function has_access() { + public static function get_users($user_id) { - // Admin always have rights - if ($GLOBALS['user']->has_access(100)) { return true; } + $user_id = Dba::escape($user_id); + $results = array(); - // People under 25 don't get playlist access even if they created it - if (!$GLOBALS['user']->has_access(25)) { return false; } + $sql = "SELECT `id` FROM `playlist` WHERE `user`='$user_id'"; + $db_results = Dba::query($sql); - if ($this->user == $GLOBALS['user']->id) { return true; } + while ($row = Dba::fetch_assoc($db_results)) { + $results[] = $row['id']; + } - return false; + return $results; - } // has_access + } // get_users /** * update_type diff --git a/lib/general.lib.php b/lib/general.lib.php index ea1556d3..5c724f18 100644 --- a/lib/general.lib.php +++ b/lib/general.lib.php @@ -164,13 +164,14 @@ function session_exists($sid,$xml_rpc=0) { } // session_exists -/*! - @function extend_session - @discussion just update the expire time -*/ +/** + * extend_session + * just updates the expire time of the specified session this + * is used by the the play script after a song finishes + */ function extend_session($sid) { - $new_time = time() + Config::get('local_length'); + $new_time = time() + Config::get('session_length'); if ($_COOKIE['amp_longsess'] == '1') { $new_time = time() + 86400*364; } diff --git a/lib/playlist.lib.php b/lib/playlist.lib.php index 7f069a31..5889a4b6 100644 --- a/lib/playlist.lib.php +++ b/lib/playlist.lib.php @@ -54,38 +54,6 @@ function show_playlists() { } // show_playlists -/** - * show_playlist - * This function takes a playlist object and calls show_songs after - * runing get_items() - */ -function show_playlist($playlist) { - - /* Create the Playlist */ - $song_ids = $playlist->get_items(); - - - show_playlist_menu(); - - if (count($song_ids) > 0) { - show_songs($song_ids, $playlist); - } - else { - echo "
" . _("No songs in this playlist.") . "
\n"; - } - -} // show_playlist - -/** - * show_playlist_menu - * This shows a little pretty box that contains the playlist 'functions' - */ -function show_playlist_menu() { - - require (conf('prefix') . '/templates/show_playlist_box.inc.php'); - -} // show_playlist_menu - /** * show_playlist_edit * This function shows the edit form for a playlist, nothing special here -- cgit