diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2008-03-11 07:24:24 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2008-03-11 07:24:24 +0000 |
commit | 591ca8e918bd59cff7301df830e86d2633c8b84a (patch) | |
tree | 47041851a442b0dee74e446f232a34068c170c1b /lib | |
parent | 7c8a11684d9de33fa0b7ed54fd59fd7cf2745911 (diff) | |
download | ampache-591ca8e918bd59cff7301df830e86d2633c8b84a.tar.gz ampache-591ca8e918bd59cff7301df830e86d2633c8b84a.tar.bz2 ampache-591ca8e918bd59cff7301df830e86d2633c8b84a.zip |
almost done cleaning up the democratic play mojo
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/democratic.class.php | 63 | ||||
-rw-r--r-- | lib/class/tmpplaylist.class.php | 25 |
2 files changed, 54 insertions, 34 deletions
diff --git a/lib/class/democratic.class.php b/lib/class/democratic.class.php index 10d72777..f8008035 100644 --- a/lib/class/democratic.class.php +++ b/lib/class/democratic.class.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2007 Ampache.org + Copyright (c) 2001 - 2008 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -69,6 +69,24 @@ class Democratic extends tmpPlaylist { $this->f_cooldown = $this->cooldown . ' ' . _('minutes'); $this->f_primary = $this->primary ? _('Primary') : ''; + switch ($this->level) { + case '5': + $this->f_level = _('Guest'); + break; + case '25': + $this->f_level = _('User'); + break; + case '50': + $this->f_level = _('Content Manager'); + break; + case '75': + $this->f_level = _('Catalog Manager'); + break; + case '100': + $this->f_level = _('Admin'); + break; + } + } // format /** @@ -99,18 +117,20 @@ class Democratic extends tmpPlaylist { * This returns the curren users current playlist, or if specified * this current playlist of the user */ - public static function get_current_playlist($user_id='') { - - // If not passed user global - $user_id = $user_id ? $user_id : $GLOBALS['user']->id; + public static function get_current_playlist() { + $democratic_id = Config::get('democratic_id'); - /* Find the - 1 one for now */ - $sql = "SELECT `id` FROM `tmp_playlist` WHERE `session`='-1'"; - $db_results = Dba::query($sql); - $row = Dba::fetch_assoc($db_results); + if (!$democratic_id) { + $level = Dba::escape($GLOBALS['user']->access); + $sql = "SELECT `id` FROM `democratic` WHERE `level` <= '$level' " . + " ORDER BY `level` DESC,`primary` DESC"; + $db_results = Dba::query($sql); + $row = Dba::fetch_assoc($db_results); + $democratic_id = $row['id']; + } - $object = new Democratic($row['id']); + $object = new Democratic($democratic_id); return $object; @@ -440,5 +460,28 @@ class Democratic extends tmpPlaylist { } // prune_tracks + /** + * clear + * This is really just a wrapper function, it clears the entire playlist + * including all votes etc. + */ + public function clear() { + + $tmp_id = Dba::escape($this->id); + + /* Clear all votes then prune */ + $sql = "DELETE FROM user_vote USING user_vote " . + "LEFT JOIN tmp_playlist_data ON user_vote.object_id = tmp_playlist_data.id " . + "WHERE tmp_playlist_data.tmp_playlist='$tmp_id'"; + $db_results = Dba::query($sql); + + // Prune! + self::prune_tracks(); + + return true; + + } // clear_playlist + + } // Democratic class ?> diff --git a/lib/class/tmpplaylist.class.php b/lib/class/tmpplaylist.class.php index ec3a9962..905da3bd 100644 --- a/lib/class/tmpplaylist.class.php +++ b/lib/class/tmpplaylist.class.php @@ -285,7 +285,7 @@ class tmpPlaylist { // 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 " . - "WHERE tmp_playlist.id IS NULL"; + "WHERE tmp_playlist.id IS NULL AND tmp_playlist.type != 'vote'"; $db_results = Dba::query($sql); } // prune_tracks @@ -358,27 +358,4 @@ class tmpPlaylist { } // delete_track - /** - * clear_playlist - * This is really just a wrapper function, it clears the entire playlist - * including all votes etc. - */ - public function clear_playlist() { - - $tmp_id = Dba::escape($this->id); - - /* Clear all votes then prune */ - $sql = "DELETE FROM user_vote USING user_vote " . - "LEFT JOIN tmp_playlist_data ON user_vote.object_id = tmp_playlist_data.id " . - "WHERE tmp_playlist_data.tmp_playlist='$tmp_id'"; - $db_results = Dba::query($sql); - - // Prune! - self::prune_tracks(); - - return true; - - } // clear_playlist - - } // class tmpPlaylist |