diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-12-14 05:13:09 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-12-14 05:13:09 +0000 |
commit | ce1a8672d4b2d78b8301527311a410af893c4943 (patch) | |
tree | b987e8f283d8c651d242add41a7dc0d24ba598f5 | |
parent | 52d8985a27674da0dbd6d85a055bb07555917c23 (diff) | |
download | ampache-ce1a8672d4b2d78b8301527311a410af893c4943.tar.gz ampache-ce1a8672d4b2d78b8301527311a410af893c4943.tar.bz2 ampache-ce1a8672d4b2d78b8301527311a410af893c4943.zip |
* Added delete admin function on democratic play
* fixed some minor display issues with playlist dropdowns
* added Delete Disabled bin script for removing disabled songs
-rw-r--r-- | bin/delete_disabled.php.inc | 51 | ||||
-rwxr-xr-x | docs/CHANGELOG | 2 | ||||
-rw-r--r-- | lib/playlist.lib.php | 41 | ||||
-rw-r--r-- | lib/ui.lib.php | 2 | ||||
-rw-r--r-- | modules/lib.php | 129 | ||||
-rw-r--r-- | server/ajax.server.php | 28 | ||||
-rw-r--r-- | templates/default.css | 4 | ||||
-rw-r--r-- | templates/show_play_selected.inc.php | 2 | ||||
-rw-r--r-- | templates/show_search.inc | 2 | ||||
-rw-r--r-- | templates/show_tv_adminctl.inc.php | 4 | ||||
-rw-r--r-- | templates/show_tv_playlist.inc.php | 14 | ||||
-rw-r--r-- | templates/sidebar.inc.php | 2 | ||||
-rw-r--r-- | tv.php | 2 |
13 files changed, 147 insertions, 136 deletions
diff --git a/bin/delete_disabled.php.inc b/bin/delete_disabled.php.inc new file mode 100644 index 00000000..0c163a17 --- /dev/null +++ b/bin/delete_disabled.php.inc @@ -0,0 +1,51 @@ +<?php +/* + + Copyright 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. + +*/ + +/** + * Delete Disabled + * This WILL DELETE MUSIC!!!! it does what it's name would suggest and deletes + * any disabled songs + */ + +/* will not delete anything if debug is true */ +$debug = true; + + +$no_session = '1'; +require ("../lib/init.php"); + +/* Get a list of filenames */ +$sql = "SELECT id,file FROM song WHERE enabled='0'"; +$db_results = mysql_query($sql,dbh()); + +while ($r = mysql_fetch_assoc($db_results)) { + + if ($debug) { + echo "Deleting: " . $r['file'] . "\n"; + } + else { + unlink($r['file']); + $sql = "DELETE FROM song WHERE id='" . sql_escape($r['id']) . "'"; + $del_results = mysql_query($sql,dbh()); + } +} // end while + +?> diff --git a/docs/CHANGELOG b/docs/CHANGELOG index c9af9d3b..95ec1bdc 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,8 @@ -------------------------------------------------------------------------- v.3.3.3-Beta1 + - Added /bin/delete_disabled.php.inc to delete any disabled + songs in your DB, defaults to Debug only mode - Fixed display issue with players that ignore EXTINF in m3us (Thx AlxRogan) - Added Refreshing to the Recently Played menu at the same time diff --git a/lib/playlist.lib.php b/lib/playlist.lib.php index e7248522..0ff1ba24 100644 --- a/lib/playlist.lib.php +++ b/lib/playlist.lib.php @@ -164,5 +164,46 @@ function prune_empty_playlists() { } // prune_empty_playlists +/** + * show_playlist_select + * This shows the playlist select box, it takes a playlist ID and a type as an optional + * param, the type is 'normal','democratic','dynamic' these are hacks and make baby vollmer cry + * but I'm too lazy to fix them right now + */ +function show_playlist_select($playlist_id=0,$type='') { + + /* If democratic show everything, else normal */ + if ($type == 'democratic') { + $where_sql = '1=1'; + } + else { + $where_sql = " `user` = '" . sql_escape($GLOBALS['user']->id) . "'"; + } + + $sql = "SELECT id,name FROM playlist " . + "WHERE " . $where_sql . " ORDER BY name"; + $db_results = mysql_query($sql,dbh()); + + echo "<select name=\"playlist_id\">\n"; + + /* The first value changes depending on our type */ + if ($type == 'democratic') { + echo "\t<option value=\"0\">" . _('All') . "</option>\n"; + } + elseif ($type != 'dynamic') { + echo "\t<option value=\"0\"> -" . _('New Playlist') . "- </option>\n"; + } + + while ($r = mysql_fetch_assoc($db_results)) { + $select_txt = ''; + if ($playlist_id == $r['id']) { $select_txt = ' selected="selected" '; } + + echo "\t<option value=\"" . scrub_out($r['id']) . "\"$select_txt>" . scrub_out($r['name']) . "</option>\n"; + + } // end while + + echo '</select>'; + +} // show_playlist_select ?> diff --git a/lib/ui.lib.php b/lib/ui.lib.php index e1154b21..7fd7073a 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -1284,7 +1284,7 @@ function get_user_icon($name) { $img_url = conf('web_path') . '/images/' . $icon_name; } - $string = "<img src=\"$img_url\" border=\"0\" alt=\"$name\" title=\"$name\" />"; + $string = "<img style=\"cursor: pointer;\" src=\"$img_url\" border=\"0\" alt=\"$name\" title=\"$name\" />"; return $string; diff --git a/modules/lib.php b/modules/lib.php index e51b8e4a..93e4c812 100644 --- a/modules/lib.php +++ b/modules/lib.php @@ -10,36 +10,6 @@ */ -/*********************************************************/ -/* Functions for getting songs given artist, album or id */ -/*********************************************************/ -// TODO : albums should be always gruoped by -// id, like 'greatest hits' album is below, never by name. -// Other catalog functions should take care of assigning all -// songs with same name album to the same album id. It should -// not be done here. -// I'm commenting all this out to always sort by ID, to -// see how bad it is. -Rubin -function get_songs_from_album ($album) { - - global $settings; - $dbh = dbh(); - - $songs = array(); - - $query = "SELECT track, id as song FROM song" . - " WHERE album = '$album'" . - " ORDER BY track, title"; - - $db_result = mysql_query($query, $dbh); - - while ( $r = mysql_fetch_array($db_result) ) { - $songs[] = $r; - } - - return $songs; -} - // Used by playlist functions when you have an array of something of type // and you want to extract the songs from it whether type is artists or albums @@ -70,39 +40,8 @@ function get_songs_from_type ($type, $results, $artist_id = 0) { return $song; } - -function show_playlist_form () { - - print <<<ECHO -<table cellpadding="5" class="tabledata"> - <tr align="center" class="odd"> - <td> - <input type="button" name="select_all" value="Select All" onclick="this.value=check_results()" /> - </td> - <td> Playlist:</td> - <td> - <input name="action" class="button" type="submit" value="Add to" /> -ECHO; - - show_playlist_dropdown(); - - print <<<ECHO - <input name="action" class="button" type="submit" value="View" /> - <input name="action" class="button" type="submit" value="Edit" /> - - </td> - </tr> - <tr align="center" class="even"> - <td colspan="6"> - <input name="action" class="button" type="submit" value="Play Selected" /> - </td> - </tr> -</table> -ECHO; - -} - - +// This function makes baby vollmer cry, need to fix +//FIXME function get_artist_info ($artist_id) { $dbh = dbh(); @@ -220,70 +159,6 @@ function show_albums ($albums,$view=0) { } // show_albums -function get_playlist_track_from_song ( $playlist_id, $song_id ) { - - $dbh = dbh(); - - $sql = "SELECT track FROM playlist_data" . - " WHERE playlist = '$playlist_id'" . - " AND song = '$song_id'"; - $db_result = mysql_query($sql, $dbh); - if ($r = mysql_fetch_array($db_result)) { - return $r[0]; - } - else { - return FALSE; - } -} - -/** - * show_playlist_dropdown - * Hacking this for now... will fix tomorrow evening - * Hmm Vollmer Lies... it's been a lot longer then said tomorrow evening... - */ -function show_playlist_dropdown ($playlist_id=0,$no_new=false) { - - global $settings; - $dbh = dbh(); - - $userid = scrub_in($_SESSION['userdata']['username']); - $sql = "SELECT * FROM playlist" . - " WHERE user = '$userid'" . - " AND name <> 'Temporary'" . - " ORDER BY name"; - $db_result = @mysql_query($sql, $dbh); - - echo "<select name=\"playlist_id\">\n"; - if (!$no_new) { echo "<option value=\"0\"> -New Playlist- </option>\n"; } - - while ( $r = @mysql_fetch_object($db_result) ) { - if ( $playlist_id == $r->id ) { - echo "<option value=\"" . $r->id . "\" selected=\"selected\">" . $r->name . "</option>\n"; - } - else { - echo "<option value=\"" . $r->id . "\">" . $r->name . "</option>\n"; - } - } - echo "</select>\n"; -} - - -// Used to show when we have an access error for a playlist -function show_playlist_access_error ($playlist, $username) { - - $plname = $playlist->name; - $pluser = new User($playlist->user); - $plowner = $pluser->username; - - print <<<ECHO -<p style="font: 12px bold;"> Playlist Access Error </p> -<p>$username doesn't have access to update the '$plname' playlist, it is owned by $plowner.</p> - -ECHO; - -} - - // Used to show a form with confirm action button on it (for deleting playlists, users, etc) /*! @function show_confirm_action diff --git a/server/ajax.server.php b/server/ajax.server.php index f47dac14..53644560 100644 --- a/server/ajax.server.php +++ b/server/ajax.server.php @@ -152,9 +152,35 @@ switch ($action) { $xml_doc = xml_from_array($results); echo $xml_doc; break; + /* Admin Actions on the tv page */ + case 'tv_admin': + if (!$GLOBALS['user']->has_access(100) || !conf('allow_democratic_playback')) { break; } + + /* Get the playlist */ + $tmp_playlist = get_democratic_playlist(-1); + + ob_start(); + + /* Switch on the command we need to run */ + switch ($_REQUEST['cmd']) { + case 'delete': + $tmp_playlist->delete_track($_REQUEST['track_id']); + $songs = $tmp_playlist->get_items(); + require_once(conf('prefix') . '/templates/show_tv_playlist.inc.php'); + $results['tv_playlist'] = ob_get_contents(); + break; + default: + // Rien a faire + break; + } // end switch + + ob_end_clean(); + $xml_doc = xml_from_array($results); + echo $xml_doc; + break; /* This can be a positve (1) or negative (-1) vote */ case 'vote': - if (!$GLOBALS['user']->has_access(25) || $GLOBALS['user']->prefs['play_type'] != 'democratic') { break; } + if (!$GLOBALS['user']->has_access(25) || !conf('allow_democratic_playback')) { break; } /* Get the playlist */ $tmp_playlist = get_democratic_playlist(-1); diff --git a/templates/default.css b/templates/default.css index 625ea8ec..6bc33087 100644 --- a/templates/default.css +++ b/templates/default.css @@ -566,11 +566,13 @@ li.current-rating{ border-bottom:2px solid #000000; border-left:2px solid #000000; border-top:2px solid #000000;} + .text-action, .text-action li { margin-top:5px; list-style: none; margin-bottom:5px; padding-left:0px; + text-wrap: none; } .text-action a, .text-action span { background: #dddddd; @@ -578,11 +580,13 @@ li.current-rating{ padding-left:2px; padding-right:2px; text-decoration: none; + text-wrap: none; } .text-action #pt_active { background: #000000; color: #ffffff; border:1px solid #dddddd; + text-wrap: none; } #nowplaying { width:600px; diff --git a/templates/show_play_selected.inc.php b/templates/show_play_selected.inc.php index 31ec04fc..4270b99c 100644 --- a/templates/show_play_selected.inc.php +++ b/templates/show_play_selected.inc.php @@ -45,7 +45,7 @@ if (is_object($GLOBALS['playlist'])) { ?> <tr align="center"> <td colspan="2"> <?php echo _('Playlist'); ?>: <input type="button" value="<?php echo _('Add to'); ?>" onclick="return SubmitToPage('songs','<?php echo $web_path; ?>/playlist.php?action=add_to');" /> - <?php show_playlist_dropdown($_SESSION['data']['playlist_id']); ?> + <?php show_playlist_select($_SESSION['data']['playlist_id']); ?> <input class="button" type="button" value="<?php echo _('View'); ?>" onclick="return SubmitToPage('songs','<?php echo $web_path; ?>/playlist.php?action=view');" /> <input class="button" type="button" value="<?php echo _('Edit'); ?>" onclick="return SubmitToPage('songs','<?php echo $web_path; ?>/playlist.php?action=edit');" /> </td> diff --git a/templates/show_search.inc b/templates/show_search.inc index e3e88e89..4a3a7dee 100644 --- a/templates/show_search.inc +++ b/templates/show_search.inc @@ -143,7 +143,7 @@ <br /> <form method="post" action="<?php echo conf('web_path'); ?>/playlist.php?action=add_dyn_song"> <?php echo _('Save Search As Track on'); ?>: -<?php show_playlist_dropdown($_SESSION['data']['playlist_id']); ?> +<?php show_playlist_select($_SESSION['data']['playlist_id'],'dynamic'); ?> <input class="button" type="submit" value="<?php echo _('Save'); ?>" /></form> <?php } ?> <?php require (conf('prefix') . '/templates/show_box_bottom.inc.php'); ?> diff --git a/templates/show_tv_adminctl.inc.php b/templates/show_tv_adminctl.inc.php index b9a624c1..7eaceebc 100644 --- a/templates/show_tv_adminctl.inc.php +++ b/templates/show_tv_adminctl.inc.php @@ -23,7 +23,7 @@ <?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_dropdown(); ?> +<?php show_playlist_select('','democratic'); ?> <input type="hidden" name="action" value="create_playlist" /> <input type="submit" value="<?php echo _('Activate'); ?>" /> </form> @@ -44,7 +44,7 @@ else { <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_dropdown($tmp_playlist->base_playlist); ?> + <?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> diff --git a/templates/show_tv_playlist.inc.php b/templates/show_tv_playlist.inc.php index 94bb1c7b..50bc7d11 100644 --- a/templates/show_tv_playlist.inc.php +++ b/templates/show_tv_playlist.inc.php @@ -43,6 +43,10 @@ else { <td><?php echo _('Action'); ?></td> <td><?php echo _('Votes'); ?></td> <td><?php echo _('Song'); ?></td> + <td><?php echo _('Time'); ?></td> + <?php if ($GLOBALS['user']->has_access(100)) { ?> + <td><?php echo _('Admin'); ?></td> + <?php } ?> </tr> <?php @@ -60,7 +64,15 @@ foreach($songs as $row_id=>$song_id) { <?php } ?> </td> <td><?php echo scrub_out($tmp_playlist->get_vote($row_id)); ?></td> - <td><?php echo scrub_out($song->title . ' / ' . $song->get_album_name()); ?></td> + <td><?php echo $song->f_link . " / " . $song->f_album_link . " / " . $song->f_artist_link; ?></td> + <td><?php echo $song->f_time; ?></td> + <?php if ($GLOBALS['user']->has_access(100)) { ?> + <td> + <span onclick="ajaxPut('<?php echo conf('ajax_url'); ?>?action=tv_admin&cmd=delete&track_id=<?php echo $song_id; ?><?php echo conf('ajax_info'); ?>')" /> + <?php echo get_user_icon('delete'); ?> + </span> + </td> + <?php } ?> </tr> <?php } // end foreach diff --git a/templates/sidebar.inc.php b/templates/sidebar.inc.php index ab7ec8f7..af3bc38b 100644 --- a/templates/sidebar.inc.php +++ b/templates/sidebar.inc.php @@ -193,7 +193,7 @@ $web_path = conf('web_path'); ?> <?php require_once(conf('prefix') . '/templates/show_playtype_switch.inc.php'); ?> </li> -<?php if ($GLOBALS['user']->prefs['play_type'] == 'democratic') { ?> +<?php if (conf('allow_democratic_playback')) { ?> <li> <a href="<?php echo $web_path; ?>/tv.php"><?php echo _('Democratic View'); ?></a> </li> @@ -24,7 +24,7 @@ $dbh = dbh(); $web_path = conf('web_path'); /* Make sure they have access to this */ -if (!conf('allow_democratic_playback') || $GLOBALS['user']->prefs['play_type'] != 'democratic') { +if (!conf('allow_democratic_playback')) { access_denied(); exit; } |