summaryrefslogtreecommitdiffstats
path: root/lib/class/tmpplaylist.class.php
diff options
context:
space:
mode:
authorPaul 'flowerysong' Arthur <flowerysong00@yahoo.com>2010-03-14 20:14:52 +0000
committerPaul 'flowerysong' Arthur <flowerysong00@yahoo.com>2010-03-14 20:14:52 +0000
commit1cb0983ed04c65e06d502ae2ac9ed6d5e31d70dc (patch)
tree54655ff3e692a71a17f1d37cd97374b263557ca1 /lib/class/tmpplaylist.class.php
parentef48bf3fbdca2a4d25f5d025f4c6ad23905e5369 (diff)
downloadampache-1cb0983ed04c65e06d502ae2ac9ed6d5e31d70dc.tar.gz
ampache-1cb0983ed04c65e06d502ae2ac9ed6d5e31d70dc.tar.bz2
ampache-1cb0983ed04c65e06d502ae2ac9ed6d5e31d70dc.zip
Cosmetics: remove trailing whitespace
Diffstat (limited to 'lib/class/tmpplaylist.class.php')
-rw-r--r--lib/class/tmpplaylist.class.php160
1 files changed, 80 insertions, 80 deletions
diff --git a/lib/class/tmpplaylist.class.php b/lib/class/tmpplaylist.class.php
index 615897bb..a2be6e18 100644
--- a/lib/class/tmpplaylist.class.php
+++ b/lib/class/tmpplaylist.class.php
@@ -23,10 +23,10 @@
/**
* TempPlaylist Class
* This class handles the temporary playlists in ampache, it handles the
- * tmp_playlist and tmp_playlist_data tables, and sneaks out at night to
+ * tmp_playlist and tmp_playlist_data tables, and sneaks out at night to
* visit user_vote from time to time
*/
-class tmpPlaylist extends database_object {
+class tmpPlaylist extends database_object {
/* Variables from the Datbase */
public $id;
@@ -36,36 +36,36 @@ class tmpPlaylist extends database_object {
public $base_playlist;
/* Generated Elements */
- public $items = array();
+ public $items = array();
/**
- * Constructor
+ * Constructor
* This takes a playlist_id as an optional argument and gathers the information
- * if not playlist_id is passed returns false (or if it isn't found
+ * if not playlist_id is passed returns false (or if it isn't found
*/
- public function __construct($playlist_id='') {
+ public function __construct($playlist_id='') {
if (!$playlist_id) { return false; }
-
+
$this->id = intval($playlist_id);
$info = $this->_get_info();
- foreach ($info as $key=>$value) {
- $this->$key = $value;
- }
+ foreach ($info as $key=>$value) {
+ $this->$key = $value;
+ }
return true;
} // __construct
- /**
+ /**
* _get_info
- * This is an internal (private) function that gathers the information for this object from the
- * playlist_id that was passed in.
+ * This is an internal (private) function that gathers the information for this object from the
+ * playlist_id that was passed in.
*/
- private function _get_info() {
+ private function _get_info() {
- $sql = "SELECT * FROM `tmp_playlist` WHERE `id`='" . Dba::escape($this->id) . "'";
+ $sql = "SELECT * FROM `tmp_playlist` WHERE `id`='" . Dba::escape($this->id) . "'";
$db_results = Dba::read($sql);
$results = Dba::fetch_assoc($db_results);
@@ -79,22 +79,22 @@ class tmpPlaylist extends database_object {
* This returns a playlist object based on the session that is passed to us
* this is used by the load_playlist on user for the most part
*/
- public static function get_from_session($session_id) {
+ public static function get_from_session($session_id) {
+
+ $session_id = Dba::escape($session_id);
- $session_id = Dba::escape($session_id);
+ $sql = "SELECT `id` FROM `tmp_playlist` WHERE `session`='$session_id'";
+ $db_results = Dba::read($sql);
- $sql = "SELECT `id` FROM `tmp_playlist` WHERE `session`='$session_id'";
- $db_results = Dba::read($sql);
+ $results = Dba::fetch_row($db_results);
- $results = Dba::fetch_row($db_results);
-
- if (!$results['0']) {
- $results['0'] = tmpPlaylist::create($session_id,'user','song');
- }
+ if (!$results['0']) {
+ $results['0'] = tmpPlaylist::create($session_id,'user','song');
+ }
- $playlist = new tmpPlaylist($results['0']);
+ $playlist = new tmpPlaylist($results['0']);
- return $playlist;
+ return $playlist;
} // get_from_session
@@ -103,20 +103,20 @@ class tmpPlaylist extends database_object {
* This returns a tmp playlist object based on a userid passed
* this is used for the user profiles page
*/
- public static function get_from_userid($user_id) {
+ public static function get_from_userid($user_id) {
// This is a little stupid, because we don't have the user_id in the session or
// in the tmp_playlist table we have to do it this way.
- $client = new User($user_id);
- $username = Dba::escape($client->username);
+ $client = new User($user_id);
+ $username = Dba::escape($client->username);
+
+ $sql = "SELECT `tmp_playlist`.`id` FROM `tmp_playlist` LEFT JOIN `session` ON `session`.`id`=`tmp_playlist`.`session` " .
+ " WHERE `session`.`username`='$username' ORDER BY `session`.`expire` DESC";
+ $db_results = Dba::read($sql);
- $sql = "SELECT `tmp_playlist`.`id` FROM `tmp_playlist` LEFT JOIN `session` ON `session`.`id`=`tmp_playlist`.`session` " .
- " WHERE `session`.`username`='$username' ORDER BY `session`.`expire` DESC";
- $db_results = Dba::read($sql);
+ $data = Dba::fetch_assoc($db_results);
- $data = Dba::fetch_assoc($db_results);
-
- return $data['id'];
+ return $data['id'];
} // get_from_userid
@@ -126,20 +126,20 @@ class tmpPlaylist extends database_object {
* has gotten a little more complicated because of type, the values are an array
* 0 being ID 1 being TYPE
*/
- public function get_items() {
+ public function get_items() {
$order = 'ORDER BY id ASC';
-
+
/* Select all objects from this playlist */
- $sql = "SELECT tmp_playlist_data.object_type, tmp_playlist_data.id, tmp_playlist_data.object_id " .
- "FROM tmp_playlist_data " .
+ $sql = "SELECT tmp_playlist_data.object_type, tmp_playlist_data.id, tmp_playlist_data.object_id " .
+ "FROM tmp_playlist_data " .
"WHERE tmp_playlist_data.tmp_playlist='" . Dba::escape($this->id) . "' $order";
$db_results = Dba::read($sql);
-
+
/* Define the array */
$items = array();
- while ($results = Dba::fetch_assoc($db_results)) {
+ while ($results = Dba::fetch_assoc($db_results)) {
$key = $results['id'];
$items[$key] = array($results['object_type'],$results['object_id']);
}
@@ -150,16 +150,16 @@ class tmpPlaylist extends database_object {
/**
* get_next_object
- * This returns the next object in the tmp_playlist most of the time this
+ * This returns the next object in the tmp_playlist most of the time this
* will just be the top entry, but if there is a base_playlist and no
* items in the playlist then it returns a random entry from the base_playlist
*/
- public function get_next_object() {
+ public function get_next_object() {
$tmp_id = Dba::escape($this->id);
$order = " ORDER BY tmp_playlist_data.id DESC";
- $sql = "SELECT tmp_playlist_data.object_id FROM tmp_playlist_data " .
+ $sql = "SELECT tmp_playlist_data.object_id FROM tmp_playlist_data " .
"WHERE tmp_playlist_data.tmp_playlist = '$tmp_id' $order LIMIT 1";
$db_results = Dba::read($sql);
@@ -173,14 +173,14 @@ class tmpPlaylist extends database_object {
* count_items
* This returns a count of the total number of tracks that are in this tmp playlist
*/
- public function count_items() {
+ public function count_items() {
- $sql = "SELECT COUNT(`id`) FROM `tmp_playlist_data` WHERE `tmp_playlist_data`.`tmp_playlist`='" . $this->id . "'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT COUNT(`id`) FROM `tmp_playlist_data` WHERE `tmp_playlist_data`.`tmp_playlist`='" . $this->id . "'";
+ $db_results = Dba::read($sql);
- $results = Dba::fetch_row($db_results);
+ $results = Dba::fetch_row($db_results);
- return $results['0'];
+ return $results['0'];
} // count_items
@@ -188,50 +188,50 @@ class tmpPlaylist extends database_object {
* clear
* This clears all the objects out of a single playlist
*/
- public function clear() {
+ public function clear() {
- $sql = "DELETE FROM `tmp_playlist_data` WHERE `tmp_playlist_data`.`tmp_playlist`='" . $this->id . "'";
- $db_results = Dba::write($sql);
+ $sql = "DELETE FROM `tmp_playlist_data` WHERE `tmp_playlist_data`.`tmp_playlist`='" . $this->id . "'";
+ $db_results = Dba::write($sql);
- return true;
+ return true;
} // clear
- /**
+ /**
* 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
*/
- public static function create($sessid,$type,$object_type) {
+ public static function create($sessid,$type,$object_type) {
$sessid = Dba::escape($sessid);
$type = Dba::escape($type);
$object_type = Dba::escape($object_type);
- $sql = "INSERT INTO `tmp_playlist` (`session`,`type`,`object_type`) " .
+ $sql = "INSERT INTO `tmp_playlist` (`session`,`type`,`object_type`) " .
" VALUES ('$sessid','$type','$object_type')";
$db_results = Dba::write($sql);
$id = Dba::insert_id();
- $do_prune = rand(0,4);
- if ($do_prune%2) {
+ $do_prune = rand(0,4);
+ if ($do_prune%2) {
self::prune_playlists();
- self::prune_tracks();
- }
+ self::prune_tracks();
+ }
/* Clean any other playlists assoicated with this session */
self::delete($sessid,$id);
return $id;
- } // create
+ } // create
/**
* update_playlist
* This updates the base_playlist on this tmp_playlist
*/
- public function update_playlist($playlist_id) {
+ public function update_playlist($playlist_id) {
$playlist_id = Dba::escape($playlist_id);
$tmp_id = Dba::escape($this->id);
@@ -246,9 +246,9 @@ class tmpPlaylist extends database_object {
/**
* delete
* This deletes any other tmp_playlists assoicated with this
- * session
+ * session
*/
- public static function delete($sessid,$id) {
+ public static function delete($sessid,$id) {
$sessid = Dba::escape($sessid);
$id = Dba::escape($id);
@@ -267,11 +267,11 @@ class tmpPlaylist extends database_object {
* prune_playlists
* This deletes and playlists that don't have an assoicated session
*/
- public static function prune_playlists() {
+ public static function prune_playlists() {
/* Just delete if no matching session row */
- $sql = "DELETE FROM `tmp_playlist` USING `tmp_playlist` " .
- "LEFT JOIN session ON session.id=tmp_playlist.session " .
+ $sql = "DELETE FROM `tmp_playlist` USING `tmp_playlist` " .
+ "LEFT JOIN session ON session.id=tmp_playlist.session " .
"WHERE session.id IS NULL AND tmp_playlist.type != 'vote'";
$db_results = Dba::write($sql);
@@ -281,13 +281,13 @@ class tmpPlaylist extends database_object {
/**
* prune_tracks
- * This prunes tracks that don't have playlists or don't have votes
+ * This prunes tracks that don't have playlists or don't have votes
*/
- public static function prune_tracks() {
+ public static function prune_tracks() {
// This prue is always run clears data for playlists that don't have tmp_playlist anymore
- $sql = "DELETE FROM tmp_playlist_data USING tmp_playlist_data " .
- "LEFT JOIN tmp_playlist ON tmp_playlist_data.tmp_playlist=tmp_playlist.id " .
+ $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 = Dba::write($sql);
@@ -298,13 +298,13 @@ class tmpPlaylist extends database_object {
* This adds the object of $this->object_type to this tmp playlist
* it takes an optional type, default is song
*/
- public function add_object($object_id,$object_type) {
+ public function add_object($object_id,$object_type) {
$object_id = Dba::escape($object_id);
$playlist_id = Dba::escape($this->id);
- $object_type = $object_type ? Dba::escape($object_type) : 'song';
+ $object_type = $object_type ? Dba::escape($object_type) : 'song';
- $sql = "INSERT INTO `tmp_playlist_data` (`object_id`,`tmp_playlist`,`object_type`) " .
+ $sql = "INSERT INTO `tmp_playlist_data` (`object_id`,`tmp_playlist`,`object_type`) " .
" VALUES ('$object_id','$playlist_id','$object_type')";
$db_results = Dba::write($sql);
@@ -315,12 +315,12 @@ class tmpPlaylist extends database_object {
/**
* vote_active
* This checks to see if this playlist is a voting playlist
- * and if it is active
+ * and if it is active
*/
- public function vote_active() {
+ public function vote_active() {
/* Going to do a little more here later */
- if ($this->type == 'vote') { return true; }
+ if ($this->type == 'vote') { return true; }
return false;
@@ -330,17 +330,17 @@ class tmpPlaylist extends database_object {
* delete_track
* This deletes a track from the tmpplaylist
*/
- public function delete_track($id) {
+ public function delete_track($id) {
$id = Dba::escape($id);
/* delete the track its self */
- $sql = "DELETE FROM `tmp_playlist_data` " .
+ $sql = "DELETE FROM `tmp_playlist_data` " .
" WHERE `id`='$id'";
$db_results = Dba::write($sql);
return true;
} // delete_track
-
+
} // class tmpPlaylist