diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-01-15 06:27:55 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-01-15 06:27:55 +0000 |
commit | 2d5ed879bd17024154e87de22c811bbfd0e69433 (patch) | |
tree | fbc39798312d1799510cc5ef0f103ebb554e3776 | |
parent | e3e529394d526608e3ebeadb69234120f0f300ed (diff) | |
download | ampache-2d5ed879bd17024154e87de22c811bbfd0e69433.tar.gz ampache-2d5ed879bd17024154e87de22c811bbfd0e69433.tar.bz2 ampache-2d5ed879bd17024154e87de22c811bbfd0e69433.zip |
more flagging fixes, you can flag files now you just cant do anything about it
-rwxr-xr-x | docs/CHANGELOG | 5 | ||||
-rw-r--r-- | flag.php | 53 | ||||
-rw-r--r-- | lib/class/flag.class.php | 98 | ||||
-rw-r--r-- | lib/class/song.class.php | 112 | ||||
-rw-r--r-- | lib/ui.lib.php | 18 | ||||
-rw-r--r-- | modules/init.php | 35 | ||||
-rw-r--r-- | modules/lib.php | 141 | ||||
-rw-r--r-- | templates/flag.inc | 132 | ||||
-rw-r--r-- | templates/show_flag.inc.php | 136 | ||||
-rw-r--r-- | templates/show_songs.inc | 26 |
10 files changed, 385 insertions, 371 deletions
diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 55f8dde2..a1cfabb7 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,9 +4,8 @@ -------------------------------------------------------------------------- v.3.3.2-Beta2 - - Removed old flagging tables and added a new one as part of - full flagging rewrite. - - Fixed play selected on playlists, it no longer always plays + - Rewrote entire Flag method, this includes the edit functionality + - Fixed play selected on playlists, it no longer always plays everything. - Fixed redirection after applying a rating to an album - Fixed a few typos in the xmlrpc code and playlists and fixed the @@ -20,32 +20,43 @@ */ -/* - - This will allow users to flag songs for having broken tags or bad rips. +/** + * Flag Document + * This is called for all of our flagging needs + */ -*/ -require_once("modules/init.php"); - -$action = scrub_in($_REQUEST['action']); -$song = scrub_in($_REQUEST['song']); - -if ( $action == 'flag_song') { - $flagged_type = scrub_in($_REQUEST['flagged_type']); - $comment = scrub_in($_REQUEST['comment']); - insert_flagged_song($song, $flagged_type, $comment); - $flag_text = _("Flagging song completed."); - $action = 'flag'; -} +require_once('modules/init.php'); show_template('header'); -if ( $action == 'flag' ) { - $type = 'show_flagged_form'; - $song_id = $song; - include(conf('prefix') . "/templates/flag.inc"); -} +$action = scrub_in($_REQUEST['action']); +$flag = new Flag($_REQUEST['flag_id']); + +/* Switch on the action */ +switch ($action) { + case 'remove_flag': + break; + case 'flag': + $id = scrub_in($_REQUEST['id']); + $type = scrub_in($_REQUEST['type']); + $flag_type = scrub_in($_REQUEST['flag_type']); + $comment = scrub_in($_REQUEST['comment']); + $flag->add($id,$type,$flag_type,$comment); + show_confirmation(_('Item Flagged'),_('The specified item has been flagged'),$_SESSION['source_page']); + break; + case 'show_flag': + /* Store where they came from */ + $_SESSION['source_page'] = return_referer(); + include(conf('prefix') . '/templates/show_flag.inc.php'); + break; + case 'show_remove_flag': + + break; + default: + + break; +} // end action switch show_footer(); ?> diff --git a/lib/class/flag.class.php b/lib/class/flag.class.php new file mode 100644 index 00000000..fe5a0f8c --- /dev/null +++ b/lib/class/flag.class.php @@ -0,0 +1,98 @@ +<?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 + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + 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. + +*/ + +/** + * Flag Class + * This handles flagging of songs, albums and artists + */ +class Flag { + + /* DB based variables */ + var $id; + var $user; + var $object_id; + var $object_type; + var $comment; + var $flag; + + /** + * Constructor + * This takes a flagged.id and then pulls in the information for said flag entry + */ + function Flag($flag_id=0) { + + $this->id = $flag_id; + + if (!$this->id) { return false; } + + $info = $this->_get_info(); + + $this->user = $info['user']; + $this->object_id = $info['object_id']; + $this->object_type = $info['object_type']; + $this->comment = $info['comment']; + $this->flag = $info['flag']; + + return true; + + } // flag + + /** + * _get_info + * Private function for getting the information for this object from the database + */ + function _get_info() { + + $id = sql_escape($this->id); + + $sql = "SELECT * FROM flagged WHERE id='$id'"; + $db_results = mysql_query($sql, dbh()); + + $results = mysql_fetch_assoc($db_results); + + return $results; + + } // _get_info + + /** + * add + * This adds a flag entry for an item, it takes an id, a type, the flag type + * and a comment and then inserts the mofo + */ + function add($id,$type,$flag,$comment) { + + $id = sql_escape($id); + $type = sql_escape($type); + $flag = sql_escape($flag); + $comment = sql_escape($comment); + + $sql = "INSERT INTO flagged (`object_id`,`object_type`,`flag`,`comment`) VALUES " . + " ('$id','$type','$flag','$comment')"; + $db_results = mysql_query($sql, dbh()); + + return true; + + } // add + +} //end of flag class + +?> diff --git a/lib/class/song.class.php b/lib/class/song.class.php index 910aa1e7..44e90096 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -59,34 +59,30 @@ class Song { if ($song_id) { /* Assign id for use in get_info() */ - $this->id = $song_id; + $this->id = sql_escape($song_id); /* Get the information from the db */ if ($info = $this->get_info()) { /* Assign Vars */ - $this->file = $info->file; - $this->album = $info->album; - $this->artist = $info->artist; - $this->title = $info->title; - $this->comment = $info->comment; - $this->year = $info->year; - $this->bitrate = $info->bitrate; - $this->rate = $info->rate; - $this->mode = $info->mode; - $this->size = $info->size; - $this->time = $info->time; - $this->track = $info->track; - $this->genre = $info->genre; + $this->file = $info->file; + $this->album = $info->album; + $this->artist = $info->artist; + $this->title = $info->title; + $this->comment = $info->comment; + $this->year = $info->year; + $this->bitrate = $info->bitrate; + $this->rate = $info->rate; + $this->mode = $info->mode; + $this->size = $info->size; + $this->time = $info->time; + $this->track = $info->track; + $this->genre = $info->genre; $this->addition_time = $info->addition_time; - $this->catalog = $info->catalog; - $this->played = $info->played; + $this->catalog = $info->catalog; + $this->played = $info->played; $this->update_time = $info->update_time; - $this->flagid = $info->flagid; - $this->flaguser = $info->flaguser; - $this->flagtype = $info->flagtype; - $this->flagcomment = $info->flagcomment; - $this->enabled = $info->enabled; + $this->enabled = $info->enabled; // Format the Type of the song $this->format_type(); @@ -107,7 +103,7 @@ class Song { /* Grab the basic information from the catalog and return it */ $sql = "SELECT song.id,file,catalog,album,song.comment,year,artist,". "title,bitrate,rate,mode,size,time,track,genre,played,song.enabled,update_time,". - "addition_time FROM song WHERE song.id = '" . sql_escape($this->id) . "'"; + "addition_time FROM song WHERE song.id = '$this->id'"; $db_results = mysql_query($sql, dbh()); @@ -115,7 +111,7 @@ class Song { return $results; - } //get_info + } // get_info /*! @function format_type @@ -144,6 +140,7 @@ class Song { $this->mime = "audio/mpeg"; break; case "rm": + case "ra": $this->mime = "audio/x-realaudio"; break; case "flac"; @@ -163,6 +160,7 @@ class Song { } } // get_type + /*! @function get_album_songs @discussion gets an array of song objects based on album @@ -170,7 +168,7 @@ class Song { function get_album_songs($album_id) { $sql = "SELECT id FROM song WHERE album='$album_id'"; - $db_results = mysql_query($sql, libglue_param(libglue_param('dbh_name'))); + $db_results = mysql_query($sql, dbh()); while ($r = mysql_fetch_object($db_results)) { $results[] = new Song($r->id); @@ -236,6 +234,45 @@ class Song { } // get_genre_name /** + * get_flags + * This gets any flag information this song may have, it always + * returns an array as it may be possible to have more then + * one flag + */ + function get_flags() { + + $sql = "SELECT id,flag,comment FROM flagged WHERE object_type='song' AND object_id='$this->id'"; + $db_results = mysql_query($sql, dbh()); + + $results = array(); + + while ($r = mysql_fetch_assoc($db_results)) { + $results[] = $r; + } + + return $results; + + } // get_flag + + /** + * has_flag + * This just returns true or false depending on if this song is flagged for something + * We don't care what so we limit the SELECT to 1 + */ + function has_flag() { + + $sql = "SELECT id FROM flagged WHERE object_type='song' AND object_id='$this->id' LIMIT 1"; + $db_results = mysql_query($sql, dbh()); + + if (mysql_fetch_assoc($db_results)) { + return true; + } + + return false; + + } // has_flag + + /** * set_played * this checks to see if the current object has been played * if not then it sets it to played @@ -684,20 +721,21 @@ class Song { //TODO: fill out these cases once we have it working for m4a case "m4a": $return = false; - break; + break; default: $return = true; - break; + break; } // end switch return $return; - } // end native_stream + } // end native_stream - /*! - @function stream_cmd - @discussion test if the song type streams natively and if not returns a transcoding command from the config - */ + /** + * stream_cmd + * test if the song type streams natively and + * if not returns a transcoding command from the config + */ function stream_cmd() { $return = 'downsample_cmd'; @@ -706,16 +744,16 @@ class Song { switch ($this->type) { case "m4a": $return = "stream_cmd_m4a"; - break; + break; default: $return = "downsample_cmd"; - break; - } // end switch - } // end if not native_stream + break; + } // end switch + } // end if not native_stream return $return; - } // end stream_cmd + } // end stream_cmd -} //end of song class +} // end of song class ?> diff --git a/lib/ui.lib.php b/lib/ui.lib.php index 24b84ad5..6b984a01 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -1196,4 +1196,22 @@ function show_playlist_import() { } // show_playlist_import +/** + * show_songs + * Still not happy with this function, but at least it's in the right + * place now + */ +function show_songs ($song_ids, $playlist, $album=0) { + + $dbh = dbh(); + + $totaltime = 0; + $totalsize = 0; + + require (conf('prefix') . "/templates/show_songs.inc"); + + return true; + +} // show_songs + ?> diff --git a/modules/init.php b/modules/init.php index 22ca81b6..27144e27 100644 --- a/modules/init.php +++ b/modules/init.php @@ -83,7 +83,7 @@ if (!$results['conf']['allow_stream_playback']) { $results['conf']['raw_web_path'] = $results['conf']['web_path']; $results['conf']['web_path'] = $http_type . $_SERVER['HTTP_HOST'] . $results['conf']['web_path']; -$results['conf']['version'] = '3.3.2-Beta2 (Build 002)'; +$results['conf']['version'] = '3.3.2-Beta2 (Build 003)'; $results['conf']['catalog_file_pattern']= 'mp3|mpc|m4p|m4a|mp4|aac|ogg|rm|wma|asf|flac|spx|ra'; $results['conf']['http_port'] = $_SERVER['SERVER_PORT']; if (!$results['conf']['prefix']) { @@ -164,15 +164,11 @@ require_once(conf('prefix') . "/lib/xmlrpc.php"); require_once(conf('prefix') . "/modules/xmlrpc/xmlrpc.inc"); if (conf('allow_slim_playback')) { - require_once(conf('prefix') . "/modules/slimserver/slim.class.php"); + require_once(conf('prefix') . '/modules/slimserver/slim.class.php'); } if (conf('allow_mpd_playback')) { - require_once(conf('prefix') . "/modules/mpd/mpd.class.php"); -} - -if (conf('allow_xmms2_playback')) { - require_once(conf('prefix') . "/modules/xmms2/xmms2.class.php"); + require_once(conf('prefix') . '/modules/mpd/mpd.class.php'); } if (conf('ratings')) { @@ -181,18 +177,19 @@ if (conf('ratings')) { } // Classes -require_once(conf('prefix') . "/lib/class/catalog.class.php"); -require_once(conf('prefix') . "/lib/class/stream.class.php"); -require_once(conf('prefix') . "/lib/class/playlist.class.php"); -require_once(conf('prefix') . "/lib/class/song.class.php"); -require_once(conf('prefix') . "/lib/class/view.class.php"); -require_once(conf('prefix') . "/lib/class/update.class.php"); -require_once(conf('prefix') . "/lib/class/user.class.php"); -require_once(conf('prefix') . "/lib/class/album.class.php"); -require_once(conf('prefix') . "/lib/class/artist.class.php"); -require_once(conf('prefix') . "/lib/class/access.class.php"); -require_once(conf('prefix') . "/lib/class/error.class.php"); -require_once(conf('prefix') . "/lib/class/genre.class.php"); +require_once(conf('prefix') . '/lib/class/catalog.class.php'); +require_once(conf('prefix') . '/lib/class/stream.class.php'); +require_once(conf('prefix') . '/lib/class/playlist.class.php'); +require_once(conf('prefix') . '/lib/class/song.class.php'); +require_once(conf('prefix') . '/lib/class/view.class.php'); +require_once(conf('prefix') . '/lib/class/update.class.php'); +require_once(conf('prefix') . '/lib/class/user.class.php'); +require_once(conf('prefix') . '/lib/class/album.class.php'); +require_once(conf('prefix') . '/lib/class/artist.class.php'); +require_once(conf('prefix') . '/lib/class/access.class.php'); +require_once(conf('prefix') . '/lib/class/error.class.php'); +require_once(conf('prefix') . '/lib/class/genre.class.php'); +require_once(conf('prefix') . '/lib/class/flag.class.php'); /* Set a new Error Handler */ $old_error_handler = set_error_handler("ampache_error_handler"); diff --git a/modules/lib.php b/modules/lib.php index f35efcc6..020e1819 100644 --- a/modules/lib.php +++ b/modules/lib.php @@ -39,42 +39,6 @@ function show_album_pulldown ($album) { /* - * show_flagged_popup($reason); - * - * Shows a listing of the flagged_types for when people want to mark - * a song as being broken in some way. - */ - -function show_flagged_popup($reason,$label='value', $name='flagged_type', $other='') { - - global $settings; - $dbh = dbh(); - - $access = $_SESSION['userdata']['access']; - - $query = "SELECT type,value FROM flagged_types"; - if ($access !== 'admin') { - $query .= " WHERE access = '$access'"; - } - $db_result = mysql_query($query, $dbh); - - echo "\n<select name=\"$name\" $other>\n"; - - while ( $r = mysql_fetch_array($db_result) ) { - // $r[0] = id, $r[1] = type - if ( $reason === $r['type'] ) { - echo "\t<option value=\"".$r['type']."\" selected=\"selected\">".htmlspecialchars($r[$label])."</option>\n"; - } - else { - echo "\t<option value=\"".$r['type']."\">".htmlspecialchars($r[$label])."</option>\n"; - } - } - - echo "\n</select>\n"; -} // show_flagged_popup() - - -/* * delete_user_stats() * * just delete stats for specific users or all of them @@ -95,87 +59,6 @@ function delete_user_stats ($user) { } // delete_user_stats() -/* - * insert_flagged_song() - * - */ - -function insert_flagged_song($song, $reason, $comment) { - - $user = $_SESSION['userdata']['username']; - $time = time(); - $sql = "INSERT INTO flagged (user,song,type,comment,date)" . - " VALUES ('$user','$song', '$reason', '$comment', '$time')"; - $db_result = mysql_query($sql, dbh()); - -} // insert_flagged_song() - - -/* - * get_flagged(); - * - * Get all of the songs from the flagged table. These are songs that - * may or may not be broken. - * Deprecated by hopson on 7/27 - */ - -function get_flagged() { - - $dbh = dbh(); - - $sql = "SELECT flagged.id, user.username, type, song, date, comment" . - " FROM flagged, user" . - " WHERE flagged.user = user.username" . - " ORDER BY date"; - $db_result = mysql_query($sql, $dbh); - - $arr = array(); - - while ( $flag = mysql_fetch_object($db_result) ) { - $arr[] = $flag; - } - - return $arr; -} // get_flagged() - - -/* - * get_flagged_type($type); - * - * Return the text associated with this type. - */ - -function get_flagged_type($type) { - - $dbh = dbh(); - - $sql = "SELECT value FROM flagged_types WHERE type = '$type'"; - echo $sql; - $db_result = mysql_query($sql, $dbh); - - if ($flagged_type = mysql_fetch_object($db_result)) { - return $flagged_type->value; - } - else { - return FALSE; - } -} // get_flagged_type() - - -/* - * delete_flagged( $flag ); - * - */ - -function delete_flagged($flag) { - - $dbh = dbh(); - - $sql = "DELETE FROM flagged WHERE id = '$flag'"; - $db_result = mysql_query($sql, $dbh); -} // delete_flagged() - - /*********************************************************/ /* Functions for getting songs given artist, album or id */ /*********************************************************/ @@ -285,30 +168,6 @@ function get_songs_from_type ($type, $results, $artist_id = 0) { } -/*********************************************************/ -/* This is the main song display function. I found tieing it to the playlist functions - was really handy in getting added functionality at no cost. -/* Lets tie it to album too, so we can show art ;) */ -/*********************************************************/ -/* One symbol, m(__)m */ -function show_songs ($song_ids, $playlist, $album=0) { - - $dbh = dbh(); - - // Get info about current user - $user = $GLOBALS['user']; - - $totaltime = 0; - $totalsize = 0; - - require (conf('prefix') . "/templates/show_songs.inc"); - - return true; - -} // function show_songs - - - function show_playlist_form () { print <<<ECHO diff --git a/templates/flag.inc b/templates/flag.inc deleted file mode 100644 index fde096ab..00000000 --- a/templates/flag.inc +++ /dev/null @@ -1,132 +0,0 @@ -<?php -/* - - Copyright (c) 2001 - 2005 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 - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - 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. - -*/ - -/*! - @header - - A template file - -*/ -$web_path = conf('web_path'); -// let's put a couple of things in this file - -if ($type == 'show_flagged_form') { - $song = new Song($song_id); - $song->format_song(); - if (!preg_match('/\.mp3$/', $song->file)) { - echo "<p>Ampache can only edit MP3 file tags currently.<br/>"; - echo "<a href=\"".$_SERVER['HTTP_REFERER']."\">Back</a>"; - return; - } // end if (!preg_match('/\.mp3$/',$song->file)) -?> - - <p style="font-size: 10pt; font-weight: bold;"><?php echo _("Flag song"); ?></p> - <p><?php echo _("Flag the following song as having one of the problems listed below. Site admins will then take the appropriate action for the flagged files."); ?></p> - - <?php if ($flag_text) { ?> - <p style="color: red;"><?php echo $flag_text ; ?></p> - <?php } ?> - - <form name="flag_song" method="post" action="<?php echo $web_path; ?>/flag.php"> - <table class="tabledata" cellpadding="3" cellspacing="1"> - <tr class="even"> - <td><?php echo _("File"); ?>:</td> - <td><?php echo $song->file; ?></td> - </tr> - <tr class="even"> - <td><?php echo _("Song"); ?>:</td> - <td><b><?php echo $song->f_title; ?></b> by <?php echo $song->f_artist_full; ?></td> - </tr> - <tr class="even"> - <td><?php echo _("Reason to flag"); ?>:</td> - <td><?php show_flagged_popup($reason); ?></td> - </tr> - <tr class="even"> - <td><?php echo _("Comment"); ?>:</td> - <td><input name="comment" type="text" size="50" value="<?php echo $comment; ?>"></input> - </td> - </tr> - <tr class="odd"> - <td> </td> - <td> - <input type="submit" value="<?php echo _("Flag Song"); ?>" /> - <input type="hidden" name="action" value="flag_song" /> - </td> - </tr> - </table> - <input type="hidden" name="song" value="<?php echo $song->id; ?>" /> - </form> - -<?php -} // end if ($type == 'show_flagged_form') -elseif ($type == 'show_flagged_songs') { - $flags = get_flagged(); -?> - <p style="font-size: 10pt; font-weight: bold;">View Flagged Songs</p> - <p>This is the list of songs that have been flagged by your Ampache users. Use - this list to determine what songs you need to re-rip or tags you need to update.</p> - <?php - if ($flags) { ?> - <form name="flag_update" action="<?php echo $web_path; ?>/flag.php" method="post"> - <table class="tabledata" cellspacing="0" cellpadding="0" border="1"> - <tr class="table-header"> - <td> </td> - <td>Song</td> - <td>Flag</td> - <td>New Flag:</td> - <td>Flagged by</td> - <td>ID3 Update:</td> - </tr> - <?php - foreach ($flags as $flag) { - $song = new Song($flag->song); - $song->format_song(); - $alt_title = $song->title; - $artist = $song->f_artist; - $alt_artist = $song->f_full_artist; - - echo "<tr class=\"even\">". - "<td><input type=\"checkbox\" id=\"flag_".$flag->id."\" name=\"flag[]\" value=\"".$flag->id."\"></input></td>". - "<td><a href=\"".$web_path."/song.php?song=$flag->song\" title=\"$alt_title\">$song->f_title</a> by ". - "<a href=\"".$web_path."/artist.php?action=show&artist=$song->artist_id\" title=\"$alt_artist\">$artist</a></td>". - "<td>$flag->type</td><td>"; - $onchange = "onchange=\"document.getElementById('flag_".$flag->id."').checked='checked';\""; - show_flagged_popup($flag->type, 'type', $flag->id."_newflag", $onchange); - echo "</td><td>".$flag->username."<br />".date('m/d/y',$flag->date)."</td>"; - /*echo "<td><a href=\"catalog.php?action=fixed&flag=$flag->id\">Fixed</a></td></tr>\n";*/ - if ($flag->type === 'newid3') { - echo "<td><input type=\"radio\" name=\"accept_".$flag->id."\" value=\"accept\" />Accept"; - echo "<input type=\"radio\" name=\"accept_".$flag->id."\" value=\"reject\" />Reject</td></tr>"; - } else { - echo "<td><a href=\"".$web_path."/admin/song.php?action=edit&song=".$flag->song."\">edit/view</a></td>"; - echo "</tr>\n"; - } // end if ($flag->type === 'newid3') and else - } // end foreach ($flags as $flag) - ?> - <tr class="even"><td colspan="6"><input type="submit" name="action" value="Update Flags"></input></td></tr> - </table> - </form> -<?php } else { ?> - <p> You don't have any flagged songs. </p> -<?php } // end if ($flags) and else -} // end elseif ($type == 'show_flagged_songs') -?> diff --git a/templates/show_flag.inc.php b/templates/show_flag.inc.php new file mode 100644 index 00000000..571d822d --- /dev/null +++ b/templates/show_flag.inc.php @@ -0,0 +1,136 @@ +<?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 + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + 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. + +*/ + +$web_path = conf('web_path'); +$type = scrub_in($_REQUEST['type']); + +switch ($type) { + case 'song': + $song = new Song($_REQUEST['id']); + $song->format_song(); + $title = scrub_out($song->f_title . " by " . $song->f_artist_full); + $file = scrub_out($song->file); + break; + case 'album': + break; + case 'artist': + break; + default: + break; +} // end type switch +?> + +<p class="header1"><?php echo _('Flag song'); ?></p> +<p><?php echo _('Flag the following song as having one of the problems listed below. Site admins will then take the appropriate action for the flagged files.'); ?></p> + +<form name="flag" method="post" action="<?php echo $web_path; ?>/flag.php" enctype="multipart/form-data"> +<table class="text-box"> +<tr class="<?php echo flip_class(); ?>"> + <td><?php echo _('File'); ?>:</td> + <td><?php echo $file; ?></td> +</tr> +<tr class="<?php echo flip_class(); ?>"> + <td><?php echo _('Item'); ?>:</td> + <td><strong><?php echo $title; ?></strong></td> +</tr> +<tr class="<?php echo flip_class(); ?>"> + <td><?php echo _('Reason to flag'); ?>:</td> + <td> + <select name="flag_type"> + <option value="delete"><?php echo _('Delete'); ?></option> + <option value="retag"><?php echo _('Incorrect Tags'); ?></option> + <option value="reencode"><?php echo _('Re-encode'); ?></option> + <option value="other"><?php echo _('Other'); ?></option> + </select> + </td> +</tr> +<tr class="<?php echo flip_class(); ?>"> + <td><?php echo _('Comment'); ?>:</td> + <td><input name="comment" type="text" size="50" maxlength="128" value="" /></td> +</tr> +<tr class="<?php echo flip_class(); ?>"> + <td> </td> + <td> + <input type="submit" value="<?php echo _('Flag'); ?>" /> + <input type="hidden" name="id" value="<?php echo scrub_out($_REQUEST['id']); ?>" /> + <input type="hidden" name="action" value="flag" /> + <input type="hidden" name="type" value="<?php echo scrub_out($type); ?>" /> + </td> +</tr> +</table> +</form> +<?php +// NOT USED YET! +if ($type == 'pigsfly') { +//elseif ($type == 'show_flagged_songs') { + $flags = get_flagged(); + +?> +<p style="font-size: 10pt; font-weight: bold;">View Flagged Songs</p> +<p>This is the list of songs that have been flagged by your Ampache users. Use +this list to determine what songs you need to re-rip or tags you need to update.</p> +<?php +if ($flags) { ?> + <form name="flag_update" action="<?php echo $web_path; ?>/flag.php" method="post"> + <table class="tabledata" cellspacing="0" cellpadding="0" border="1"> + <tr class="table-header"> + <td> </td> + <td>Song</td> + <td>Flag</td> + <td>New Flag:</td> + <td>Flagged by</td> + <td>ID3 Update:</td> + </tr> + <?php + foreach ($flags as $flag) { + $song = new Song($flag->song); + $song->format_song(); + $alt_title = $song->title; + $artist = $song->f_artist; + $alt_artist = $song->f_full_artist; + + echo "<tr class=\"even\">". + "<td><input type=\"checkbox\" id=\"flag_".$flag->id."\" name=\"flag[]\" value=\"".$flag->id."\"></input></td>". + "<td><a href=\"".$web_path."/song.php?song=$flag->song\" title=\"$alt_title\">$song->f_title</a> by ". + "<a href=\"".$web_path."/artist.php?action=show&artist=$song->artist_id\" title=\"$alt_artist\">$artist</a></td>". + "<td>$flag->type</td><td>"; + $onchange = "onchange=\"document.getElementById('flag_".$flag->id."').checked='checked';\""; + show_flagged_popup($flag->type, 'type', $flag->id."_newflag", $onchange); + echo "</td><td>".$flag->username."<br />".date('m/d/y',$flag->date)."</td>"; + /*echo "<td><a href=\"catalog.php?action=fixed&flag=$flag->id\">Fixed</a></td></tr>\n";*/ + if ($flag->type === 'newid3') { + echo "<td><input type=\"radio\" name=\"accept_".$flag->id."\" value=\"accept\" />Accept"; + echo "<input type=\"radio\" name=\"accept_".$flag->id."\" value=\"reject\" />Reject</td></tr>"; + } else { + echo "<td><a href=\"".$web_path."/admin/song.php?action=edit&song=".$flag->song."\">edit/view</a></td>"; + echo "</tr>\n"; + } // end if ($flag->type === 'newid3') and else + } // end foreach ($flags as $flag) + ?> + <tr class="even"><td colspan="6"><input type="submit" name="action" value="Update Flags"></input></td></tr> + </table> + </form> +?php } else { ?> +<p> You don't have any flagged songs. </p> +<?php } // end if ($flags) and else +} // end elseif ($type == 'show_flagged_songs') +?> diff --git a/templates/show_songs.inc b/templates/show_songs.inc index e8078231..df1bfeba 100644 --- a/templates/show_songs.inc +++ b/templates/show_songs.inc @@ -21,9 +21,6 @@ */ $web_path = conf('web_path'); -// Need to set the username for the song ratings. -$username = $GLOBALS['user']->username; - /* If it's a playlist and they've got rights */ if (is_object($playlist) && ($GLOBALS['user']->username == $playlist->user || $GLOBALS['user']->has_access('100'))) { $tab = 1; @@ -46,7 +43,6 @@ if (is_object($playlist) && ($GLOBALS['user']->username == $playlist->user || $G <th><?php echo _("Size"); ?></th> <th><?php echo _("Bitrate"); ?></th> <th><?php echo _("Genre"); ?></th> - <th><?php echo _("Flag"); ?></th> <th><?php echo _("Action"); ?></th> <?php if (conf('ratings') || conf('ratings')=="false") { ?> <th><?php echo _("Rating"); ?></th> @@ -97,6 +93,7 @@ foreach ($song_ids as $song_id) { <?php $tab++; } ?> <td> + <?php if ($song->has_flag()) { echo "<strong>**</strong>"; } ?> <a href="<?php echo $web_path; ?>/song.php?action=m3u&song=<?php echo $song->id; ?>" title="<?php echo scrub_out($song->title); ?>" <?php echo $text_class; ?>><?php echo scrub_out($song->f_title); ?></a> </td> <td> @@ -120,25 +117,21 @@ foreach ($song_ids as $song_id) { <td> <?php echo $song->f_genre; ?> </td> - <td <?php echo $song->f_style; ?> title="<?php echo $song->flagcomment; ?>"> - <?php echo $song->flagtype; ?> - </td> <td> - <?php if ($user->has_access('100')) { ?> - <a href="<?php echo $web_path; ?>/admin/song.php?action=edit&song=<?php echo $song->id; ?>">Edit</a> | <a href="<?php echo $web_path; ?>/flag.php?song=<?php echo $song->id; ?>&action=flag">Flag</a> | + <a href="<?php echo $web_path; ?>/flag.php?action=show_flag&type=song&id=<?php echo $song->id; ?>">Flag</a> + <?php if ($GLOBALS['user']->has_access('100')) { ?> + | <a href="<?php echo $web_path; ?>/admin/song.php?action=edit&song=<?php echo $song->id; ?>">Edit</a> | <?php if ($song->enabled) { ?> <a href="<?php echo $web_path; ?>/admin/song.php?action=disable&song_ids=<?php echo $song->id; ?>">Disable</a> <?php } else { ?> <a href="<?php echo $web_path; ?>/admin/song.php?action=enabled&song_ids=<?php echo $song->id; ?>">Enable</a> <?php } //status ?> - <?php } else { ?> - <a href="<?php echo $web_path; ?>/flag.php?song=<?php echo $song->id; ?>&action=flag">Flag</a> <?php } //access ?> - <?php if ($user->prefs['download']) { ?> + <?php if ($GLOBALS['user']->prefs['download']) { ?> | <a href="<?php echo $web_path; ?>/download/index.php?action=download&song_id=<?php echo $song->id; ?>&fn=<?php echo rawurlencode($song->f_artist_full . " - " . $song->title . "." . $song->type); ?>"><?php echo _("Download"); ?></a> <?php } ?> - <?php if ($user->prefs['direct_link']) { ?> - | <a href="<?php echo $web_path; ?>/play/index.php?song=<?php echo $song->id; ?>&uid=<?php echo $user->username . "&sid=" . session_id(); ?>&fn=<?php echo rawurlencode($song->f_artist_full . " - " . $song->title . "." . $song->type); ?>"><?php echo _("Direct Link"); ?></a> + <?php if ($GLOBALS['user']->prefs['direct_link']) { ?> + | <a href="<?php echo $web_path; ?>/play/index.php?song=<?php echo $song->id; ?>&uid=<?php echo $GLOBALS['user']->username . "&sid=" . session_id(); ?>&fn=<?php echo rawurlencode($song->f_artist_full . " - " . $song->title . "." . $song->type); ?>"><?php echo _("Direct Link"); ?></a> <?php } ?> </td> <?php if(conf('ratings')) { ?> @@ -150,9 +143,6 @@ foreach ($song_ids as $song_id) { <?php }// foreach loop -// -// Another here doc -// $time = floor($totaltime/60) . ":" . sprintf("%02d", ($totaltime%60) ); $megs = sprintf("%.2f", ($totalsize/1048576)); $num = count($song_ids); @@ -168,10 +158,10 @@ $num = count($song_ids); <td align="right" nowrap="nowrap"><?php echo $megs; ?> MB</td> <td></td> <td></td> - <td></td> <td colspan="2"></td> </tr> </table> +<p class="header2"><?php echo _('** Indicates flagged songs'); ?></p> <br /> <?php show_play_selected(); ?> </form> |