summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--democratic.php24
-rw-r--r--lib/class/democratic.class.php63
-rw-r--r--lib/class/tmpplaylist.class.php25
-rw-r--r--templates/show_democratic.inc.php2
4 files changed, 55 insertions, 59 deletions
diff --git a/democratic.php b/democratic.php
index ec7c7fcc..04755def 100644
--- a/democratic.php
+++ b/democratic.php
@@ -79,30 +79,6 @@ switch ($_REQUEST['action']) {
$songs = $tmp_playlist->get_items();
require_once(conf('prefix') . '/templates/show_tv.inc.php');
break;
- /* This clears the entire democratic playlist, admin only */
- case 'clear_playlist':
- if (!$GLOBALS['user']->has_access(100)) {
- access_denied();
- break;
- }
-
- $tmp_playlist = new tmpPlaylist($_REQUEST['tmp_playlist_id']);
- $tmp_playlist->clear_playlist();
- require_once(conf('prefix') . '/templates/header.inc');
- show_confirmation(_('Playlist Cleared'),'',conf('web_path') . '/tv.php');
- require_once(conf('prefix') . '/templates/footer.inc');
- break;
- /* This sends the playlist to the 'method' of their chosing */
- case 'send_playlist':
- /* Only Admins Here */
- if (!$GLOBALS['user']->has_access(100)) {
- access_denied();
- break;
- }
- // Tmp just to make this work
- header("Location: " . Config::get('web_path') . "/stream.php?action=democratic");
- exit;
- break;
case 'manage_playlists':
if (!Access::check('interface','75')) {
access_denied();
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
diff --git a/templates/show_democratic.inc.php b/templates/show_democratic.inc.php
index dc3972ba..07e7afb0 100644
--- a/templates/show_democratic.inc.php
+++ b/templates/show_democratic.inc.php
@@ -19,7 +19,7 @@
*/
-show_box_top(_('Current Playlist'));
+show_box_top($democratic->name . ' ' . _('Playlist'));
?>
<div id="democratic_playlist">
<?php require_once Config::get('prefix') . '/templates/show_democratic_playlist.inc.php'; ?>