From f435ca753c1d6ce8f657c3374ae71daec6daf2be Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Mon, 12 Nov 2007 07:36:52 +0000 Subject: more democratic play work, still not working going to need db change to make it work how I want, will do later --- config/ampache.cfg.php.dist | 17 ++++------ democratic.php | 29 +++++++++++++++++ lib/class/democratic.class.php | 27 +++++++-------- lib/class/playlist.class.php | 4 +-- lib/democratic.lib.php | 44 ------------------------- lib/init.php | 3 +- lib/ui.lib.php | 26 +++++++++++++++ templates/show_create_democratic.inc.php | 44 +++++++++++++++++++++++++ templates/show_manage_democratic.inc.php | 56 ++++++++++++++++++++++++++++++++ templates/show_recently_played.inc.php | 8 ++--- templates/show_tv_adminctl.inc.php | 53 ------------------------------ templates/show_tv_nowplaying.inc.php | 43 ------------------------ themes/classic/templates/default.css | 4 +-- 13 files changed, 185 insertions(+), 173 deletions(-) delete mode 100644 lib/democratic.lib.php create mode 100644 templates/show_create_democratic.inc.php create mode 100644 templates/show_manage_democratic.inc.php delete mode 100644 templates/show_tv_adminctl.inc.php delete mode 100644 templates/show_tv_nowplaying.inc.php diff --git a/config/ampache.cfg.php.dist b/config/ampache.cfg.php.dist index 23703b93..ce70c9da 100644 --- a/config/ampache.cfg.php.dist +++ b/config/ampache.cfg.php.dist @@ -116,8 +116,8 @@ require_session = "true" ; Downsample Remote ; If this is set to true and access control is on any users who are not -; coming from a defined localnet will be automatically downsampled -; regardless of their preferences +; coming from a defined 'network' ACL will be automatically downsampled +; regardless of their preferences. Requires access_control to be enabled ; DEFAULT: false ;downsample_remote = "false" @@ -449,15 +449,12 @@ search_type = fuzzy ;###################################################### ; These are commands used to transcode non-streaming -; formats to the target file type for streaming. Any -; file types defined here will automatically be transcoded -; using the stream_cmd_??? regardless of personal preferences +; formats to the target file type for streaming. ; This can be useful in re-encoding file types that don't stream -; very well, or if the player doesn't support some file types. -; This is also the string used when 'downsampling' is selected -; +; very well, or if your player doesn't support some file types. +; This is also the string used when 'downsampling' is selected ; REQUIRED variables -; transcode_TYPE = true/false ## True if you want to force transcode +; transcode_TYPE = true/false ## True to force transcode regardless of prefs ; transcode_TYPE_target = TARGET_FILE_TYPE ; transcode_cmd_TYPE = TRANSCODE_COMMAND ; %FILE% = filename @@ -465,7 +462,6 @@ search_type = fuzzy ; %SAMPLE% = sample rate ; %EOF% = end of file in min.sec - ; List of filetypes to transcode transcode_m4a = true transcode_m4a_target = mp3 @@ -478,6 +474,7 @@ transcode_mp3_target = mp3 transcode_cmd_flac = "flac -dc %FILE% | lame -r -b 128 -S - - " transcode_cmd_m4a = "faad -f 2 -w %FILE% | lame -r -b 128 -S - -" transcode_cmd_mp3 = "mp3splt -qnf %FILE% %OFFSET% %EOF% -o - | lame --mp3input -q 3 -b %SAMPLE% -S - -" + # This line seems to work better for windows, switch if needed #transcode_cmd_mp3 = "mp3splt -qnf -o - %FILE% %OFFSET% %EOF% | lame --mp3input -q 3 -b %SAMPLE% -S - -" diff --git a/democratic.php b/democratic.php index e14cc17a..abd7ab68 100644 --- a/democratic.php +++ b/democratic.php @@ -31,6 +31,27 @@ show_header(); // Switch on their action switch ($_REQUEST['action']) { + case 'show_create': + if (!$GLOBALS['user']->has_access('75')) { + access_denied(); + break; + } + + // Show the create page + require_once Config::get('prefix') . '/templates/show_create_democratic.inc.php'; + + break; + case 'create': + // Only power users here + if (!$GLOBALS['user']->has_access('75')) { + access_denied(); + break; + } + // Create the playlist + //FIXME: don't use hardcoded id value here, needs db rework to fix this + Democratic::create('-1','vote','song',$_REQUEST['democratic']); + header("Location: " . Config::get('web_path') . "/democratic.php?action=manage_playlists"); + break; case 'create_playlist': /* Only Admins Here */ if (!$GLOBALS['user']->has_access(100)) { @@ -75,6 +96,14 @@ switch ($_REQUEST['action']) { if ($stream_type != 'localplay') { exit; } break; case 'manage_playlists': + if (!$GLOBALS['user']->has_access('75')) { + access_denied(); + break; + } + // Get all of the non-user playlists + $playlists = Democratic::get_playlists(); + + require_once Config::get('prefix') . '/templates/show_manage_democratic.inc.php'; break; case 'update_playlist': 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 @@ -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 @@ -909,6 +909,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 "\n"; + +} // show_playlist_select + /** * show_box_top * This function requires the top part of the box diff --git a/templates/show_create_democratic.inc.php b/templates/show_create_democratic.inc.php new file mode 100644 index 00000000..5fa0dbc5 --- /dev/null +++ b/templates/show_create_democratic.inc.php @@ -0,0 +1,44 @@ + +
+ + + + + + + + + + + + + + + + +
+ +
+
+ diff --git a/templates/show_manage_democratic.inc.php b/templates/show_manage_democratic.inc.php new file mode 100644 index 00000000..9cdcdd28 --- /dev/null +++ b/templates/show_manage_democratic.inc.php @@ -0,0 +1,56 @@ + + ++ + + + + + + + + + + +base_playlist); +?> + + + + + + + + + + + +
id); ?>name); ?>count_items(); ?> 
+
+ +
+ diff --git a/templates/show_recently_played.inc.php b/templates/show_recently_played.inc.php index 4d3b416d..ed67bab3 100644 --- a/templates/show_recently_played.inc.php +++ b/templates/show_recently_played.inc.php @@ -32,10 +32,10 @@ $time_unit = array('',_('seconds ago'),_('minutes ago'),_('hours ago'),_('days a - + format(); ?> + f_link; ?> + f_album_link; ?> + f_artist_link; ?> fullname); ?> - f_link; ?> - f_album_link; ?> - f_artist_link; ?> diff --git a/templates/show_tv_adminctl.inc.php b/templates/show_tv_adminctl.inc.php deleted file mode 100644 index 09d0b773..00000000 --- a/templates/show_tv_adminctl.inc.php +++ /dev/null @@ -1,53 +0,0 @@ - -

-vote_active()) { ?> -
-: - - - -
- -
- -
-
- - -
-
-: -
- base_playlist,'democratic'); ?> - - -
- diff --git a/templates/show_tv_nowplaying.inc.php b/templates/show_tv_nowplaying.inc.php deleted file mode 100644 index 27dceac9..00000000 --- a/templates/show_tv_nowplaying.inc.php +++ /dev/null @@ -1,43 +0,0 @@ - - -title,'25')); - $album = scrub_out(truncate_with_ellipse($row['song']->f_album_full,'25')); - $artist = scrub_out(truncate_with_ellipse($row['song']->f_artist_full,'25')); -?> - - - - - - - -
- - - -
- ( / )
diff --git a/themes/classic/templates/default.css b/themes/classic/templates/default.css index 82825cec..e03ec453 100644 --- a/themes/classic/templates/default.css +++ b/themes/classic/templates/default.css @@ -755,9 +755,9 @@ td.user_disabled { .fatalerror { display:table-cell; padding:3px; - color: #903; + color:#903; font-weight:bold; - border:2px solid #903; + font-size:1.2em; } .disabled { text-decoration:line-through; -- cgit