diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-11-12 07:36:52 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-11-12 07:36:52 +0000 |
commit | f435ca753c1d6ce8f657c3374ae71daec6daf2be (patch) | |
tree | 47fcefdbfb3b3ffd71c8bc27b35af0255df62e83 | |
parent | 7b303176665062673f07f451ddbf571f8a2c3c80 (diff) | |
download | ampache-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
-rw-r--r-- | config/ampache.cfg.php.dist | 17 | ||||
-rw-r--r-- | democratic.php | 29 | ||||
-rw-r--r-- | lib/class/democratic.class.php | 27 | ||||
-rw-r--r-- | lib/class/playlist.class.php | 4 | ||||
-rw-r--r-- | lib/democratic.lib.php | 44 | ||||
-rw-r--r-- | lib/init.php | 3 | ||||
-rw-r--r-- | lib/ui.lib.php | 26 | ||||
-rw-r--r-- | templates/show_create_democratic.inc.php | 44 | ||||
-rw-r--r-- | templates/show_manage_democratic.inc.php | 56 | ||||
-rw-r--r-- | templates/show_recently_played.inc.php | 8 | ||||
-rw-r--r-- | templates/show_tv_adminctl.inc.php | 53 | ||||
-rw-r--r-- | templates/show_tv_nowplaying.inc.php | 43 | ||||
-rw-r--r-- | themes/classic/templates/default.css | 4 |
13 files changed, 185 insertions, 173 deletions
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 @@ -<?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 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 @@ +<?php +/* + + Copyright (c) 2001 - 2007 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. + +*/ + +show_box_top(_('Create Democratic Playlist')); ?> +<form method="post" action="<?php echo Config::get('web_path'); ?>/democratic.php?action=create" enctype="multipart/form-data"> +<table class="tabledata" cellspacing="0" cellpadding="0"> +<tr> + <td><?php echo _('Name'); ?></td> + <td><input type="textbox" name="name" value="" /></td> +</tr> +<tr> + <td><?php echo _('Base Playlist'); ?></td> + <td><?php show_playlist_select('democratic'); ?></td> +</tr> +<tr> + <td><?php echo _('Make Default'); ?></td> + <td><input type="checkbox" name="make_default" value="1" /></td> +</tr> +<tr> + <td> + <input type="submit" value="<?php echo _('Create'); ?>" /> + </td> +</tr> +</table> +</form> +<?php show_box_bottom(); ?> 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 @@ +<?php +/* + + Copyright (c) 2001 - 2007 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. + +*/ + +show_box_top(_('Manage Democratic Playlists')); ?> +<table class="tabledata" cellpadding="0" cellspacing="0"> +<colgroup> + <col id="col_number" /> + <col id="col_base_playlist" /> + <col id="col_vote_count" /> + <col id="col_action" /> +</colgroup> +<tr class="th-top"> + <th class="cel_number"><?php echo _('Playlist'); ?></th> + <th class="cel_base_playlist"><?php echo _('Base Playlist'); ?></th> + <th class="cel_vote_count"><?php echo _('Current Number of Votes'); ?></th> + <th class="cel_action"><?php echo _('Action'); ?></th> +</tr> +<?php + foreach ($playlists as $democratic_id) { + $democratic = new Democratic($democratic_id); + $playlist = new Playlist($democratic->base_playlist); +?> +<tr> + <td><?php echo abs($democratic->id); ?></td> + <td><?php echo scrub_out($playlist->name); ?></td> + <td><?php echo $democratic->count_items(); ?></td> + <td> </td> +</tr> +<?php } if (!count($playlists)) { ?> +<tr> + <td colspan="4"><span class="fatalerror"><?php echo _('Not Enough Data'); ?></span></td> +</tr> +<?php } ?> +</table> +<div> +<span class="text-action"><a href="<?php echo Config::get('web_path'); ?>/democratic.php?action=show_create"><?php echo _('Create New Playlist'); ?></a></span> +</div> +<?php show_box_bottom(); ?> 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 <col id="col_lastplayed" /> </colgroup> <tr class="th-top"> - <th class="cel_username"><?php echo _('Username'); ?></th> <th class="cel_song"><?php echo _('Song'); ?></th> <th class="cel_album"><?php echo _('Album'); ?></th> <th class="cel_artist"><?php echo _('Artist'); ?></th> + <th class="cel_username"><?php echo _('Username'); ?></th> <th class="cel_lastplayed"><?php echo _('Last Played'); ?></th> </tr> <?php foreach ($data as $row) { @@ -69,14 +69,14 @@ $time_unit = array('',_('seconds ago'),_('minutes ago'),_('hours ago'),_('days a $song->format(); ?> <tr class="<?php echo flip_class(); ?>"> + <td class="cel_song"><?php echo $song->f_link; ?></td> + <td class="cel_album"><?php echo $song->f_album_link; ?></td> + <td class="cel_artist"><?php echo $song->f_artist_link; ?></td> <td class="cel_username"> <a href="<?php echo Config::get('web_path'); ?>/stats.php?action=show_user&user_id=<?php echo scrub_out($row_user->id); ?>"> <?php echo scrub_out($row_user->fullname); ?> </a> </td> - <td class="cel_song"><?php echo $song->f_link; ?></td> - <td class="cel_album"><?php echo $song->f_album_link; ?></td> - <td class="cel_artist"><?php echo $song->f_artist_link; ?></td> <td class="cel_lastplayed"><?php echo $time_string; ?></td> </tr> <?php } ?> 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 @@ -<?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. - -*/ -?> -<h3><?php echo _('Admin Controls'); ?></h3> -<?php if (!$tmp_playlist->vote_active()) { ?> -<form id="form_playlist" method="post" action="<?php echo conf('web_path'); ?>/tv.php" enctype="multipart/form-data" > -<?php echo _('Base Playlist'); ?>: -<?php show_playlist_select('','democratic'); ?> -<input type="hidden" name="action" value="create_playlist" /> -<input type="submit" value="<?php echo _('Activate'); ?>" /> -</form> -<?php -} - -else { -?> -<div class="text-action"> - <a href="<?php echo conf('web_path'); ?>/tv.php?action=clear_playlist&tmp_playlist_id=<?php echo scrub_out($tmp_playlist->id); ?>"><?php echo _('Clear Playlist'); ?></a> -</div> -<form method="post" style="Display:inline;" action="<?php echo conf('web_path'); ?>/tv.php?action=send_playlist&tmp_playlist_id=<?php echo scrub_out($tmp_playlist->id); ?>" enctype="multipart/form-data"> -<select name="play_type"> - <option value="localplay"><?php echo _('Localplay'); ?></option> - <option value="stream"><?php echo _('Stream'); ?></option> - <option value="downsample"><?php echo _('Downsample'); ?></option> -</select> -<input type="submit" value="<?php echo _('Play'); ?>" /> -</form> -<br /> -<?php echo _('Base Playlist'); ?>: -<form method="post" style="Display:inline;" action="<?php echo conf('web_path'); ?>/tv.php?action=update_playlist&playlist_id=<?php echo $tmp_playlist->base_playlist; ?>" enctype="multipart/form-data"> - <?php show_playlist_select($tmp_playlist->base_playlist,'democratic'); ?> - <input type="hidden" name="tmp_playlist_id" value="<?php echo $tmp_playlist->id; ?>" /> - <input type="submit" value="<?php echo _('Update'); ?>" /> -</form> -<?php } ?> 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 @@ -<?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. - -*/ -/* Pull the Now Playing Information */ -$results = get_now_playing(); -$web_path = conf('web_path'); -?> -<table cellpadding="0"> -<?php -foreach ($results as $row) { - $title = scrub_out(truncate_with_ellipse($row['song']->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')); -?> -<tr> - <td> - <a target="_blank" href="<?php echo $web_path; ?>/image.php?id=<?php echo $row['song']->album; ?>&type=popup&sid=<?php echo session_id(); ?>" onclick="popup_art('<?php echo $web_path; ?>/image.php?id=<?php echo $row['song']->album; ?>&type=popup&sid=<?php echo session_id(); ?>'); return false;"> - <img align="middle" src="<?php echo $web_path; ?>/image.php?id=<?php echo $row['song']->album; ?>&fast=1" width="275" height="275" /> - </a> - </td> -</tr> -<tr> - <td><?php echo $title; ?> - (<?php echo $album; ?> / <?php echo $artist; ?> )</td> -</tr> -<?php } // end foreach ?> -</table> 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;
|