summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-11-12 07:36:52 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-11-12 07:36:52 +0000
commitf435ca753c1d6ce8f657c3374ae71daec6daf2be (patch)
tree47fcefdbfb3b3ffd71c8bc27b35af0255df62e83 /lib
parent7b303176665062673f07f451ddbf571f8a2c3c80 (diff)
downloadampache-f435ca753c1d6ce8f657c3374ae71daec6daf2be.tar.gz
ampache-f435ca753c1d6ce8f657c3374ae71daec6daf2be.tar.bz2
ampache-f435ca753c1d6ce8f657c3374ae71daec6daf2be.zip
more democratic play work, still not working going to need db change to make it work how I want, will do later
Diffstat (limited to 'lib')
-rw-r--r--lib/class/democratic.class.php27
-rw-r--r--lib/class/playlist.class.php4
-rw-r--r--lib/democratic.lib.php44
-rw-r--r--lib/init.php3
-rw-r--r--lib/ui.lib.php26
5 files changed, 43 insertions, 61 deletions
diff --git a/lib/class/democratic.class.php b/lib/class/democratic.class.php
index f1955aed..276a74e1 100644
--- a/lib/class/democratic.class.php
+++ b/lib/class/democratic.class.php
@@ -22,20 +22,9 @@
/**
* Democratic
* This class handles democratic play, which is a fancy
- * name for voting based playback. This uses the tmp playlist
- * heavily
+ * name for voting based playback. This extends the tmpplaylist
*/
-class Democratic {
-
- /**
- * Constructor
- * This doesn't do anything currently
- */
- public function __construct() {
-
- return true;
-
- } // Constructor
+class Democratic extends tmpPlaylist {
/**
* get_playlists
@@ -44,7 +33,19 @@ class Democratic {
*/
public static function get_playlists() {
+ // Pull all tmp playlsits with a session of < 0 (as those are fake)
+ // This is kind of hackish, should really think about tweaking the db
+ // and doing this right.
+ $sql = "SELECT `id` FROM `tmp_playlist` WHERE `session`< '0'";
+ $db_results = Dba::query($sql);
+
+ $results = array();
+
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $results[] = $row['id'];
+ }
+ return $results;
} // get_playlists
diff --git a/lib/class/playlist.class.php b/lib/class/playlist.class.php
index b36cf268..f186785f 100644
--- a/lib/class/playlist.class.php
+++ b/lib/class/playlist.class.php
@@ -220,7 +220,7 @@ class Playlist {
* This simply returns a int of how many song elements exist in this playlist
* For now let's consider a dyn_song a single entry
*/
- function get_song_count() {
+ public function get_song_count() {
$sql = "SELECT COUNT(`id`) FROM `playlist_data` WHERE `playlist`='" . Dba::escape($this->id) . "'";
$db_results = Dba::query($sql);
@@ -427,7 +427,7 @@ class Playlist {
* and numbers them in a liner fashion, not allowing for
* the same track # twice, this is an optional funcition
*/
- function normalize_tracks() {
+ public function normalize_tracks() {
/* First get all of the songs in order of their tracks */
$sql = "SELECT `id` FROM `playlist_data` WHERE `playlist`='" . Dba::escape($this->id) . "' ORDER BY `track` ASC";
diff --git a/lib/democratic.lib.php b/lib/democratic.lib.php
deleted file mode 100644
index f027a5dc..00000000
--- a/lib/democratic.lib.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-/*
-
- Copyright (c) 2001 - 2006 Ampache.org
- All Rights Reserved
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-
-/**
- * get_democratic_playlist
- * This retrives the tmpPlaylist->id based on our cheating
- * use of the -1 session value. We still pass a value just
- * incase we want to support multiple 'voting' queues later
- * in life
- */
-function get_democratic_playlist($session_id) {
-
- $session_id = sql_escape($session_id);
-
- $sql = "SELECT id FROM tmp_playlist WHERE session='$session_id'";
- $db_results = mysql_query($sql, dbh());
-
- $results = mysql_fetch_assoc($db_results);
-
- $tmp_playlist = new tmpPlaylist($results['id']);
-
- return $tmp_playlist;
-
-} //get_democratic_playlist
-
-?>
diff --git a/lib/init.php b/lib/init.php
index aab58189..69b3fc2c 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -77,7 +77,7 @@ if (!count($results)) {
}
/** This is the version.... fluf nothing more... **/
-$results['version'] = '3.4-Alpha3 Build (002)';
+$results['version'] = '3.4-Alpha3 Build (003)';
$results['int_config_version'] = '5';
$results['raw_web_path'] = $results['web_path'];
@@ -130,7 +130,6 @@ require_once $prefix . '/lib/gettext.php';
require_once $prefix . '/lib/batch.lib.php';
require_once $prefix . '/lib/themes.php';
require_once $prefix . '/lib/stream.lib.php';
-require_once $prefix . '/lib/democratic.lib.php';
require_once $prefix . '/lib/xmlrpc.php';
require_once $prefix . '/lib/class/localplay.abstract.php';
require_once $prefix . '/modules/xmlrpc/xmlrpc.inc';
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index cbfb0fc1..9ab7650d 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -910,6 +910,32 @@ function show_user_select($name,$selected='',$style='') {
} // show_user_select
/**
+ * show_playlist_select
+ * This one is for users! shows a select/option statement so you can pick a user
+ * to blame
+ */
+function show_playlist_select($name,$selected='',$style='') {
+
+ echo "<select name=\"$name\" style=\"$style\">\n";
+ echo "\t<option value=\"\">" . _('None') . "</option>\n";
+
+ $sql = "SELECT `id`,`name` FROM `playlist` ORDER BY `name`";
+ $db_results = Dba::query($sql);
+
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $select_txt = '';
+ if ($row['id'] == $selected) {
+ $select_txt = 'selected="selected"';
+ }
+ // If they don't have a full name, revert to the username
+ echo "\t<option value=\"" . $row['id'] . "\" $select_txt>" . scrub_out($row['name']) . "</option>\n";
+ } // end while users
+
+ echo "</select>\n";
+
+} // show_playlist_select
+
+/**
* show_box_top
* This function requires the top part of the box
* it takes title as an optional argument