1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-06 03:49:56 +02:00

more flagging fixes, you can flag files now you just cant do anything about it

This commit is contained in:
Karl 'vollmerk' Vollmer 2006-01-15 06:27:55 +00:00
parent e3e529394d
commit 2d5ed879bd
10 changed files with 385 additions and 371 deletions

View file

@ -4,9 +4,8 @@
-------------------------------------------------------------------------- --------------------------------------------------------------------------
v.3.3.2-Beta2 v.3.3.2-Beta2
- Removed old flagging tables and added a new one as part of - Rewrote entire Flag method, this includes the edit functionality
full flagging rewrite. - Fixed play selected on playlists, it no longer always plays
- Fixed play selected on playlists, it no longer always plays
everything. everything.
- Fixed redirection after applying a rating to an album - Fixed redirection after applying a rating to an album
- Fixed a few typos in the xmlrpc code and playlists and fixed the - Fixed a few typos in the xmlrpc code and playlists and fixed the

View file

@ -20,32 +20,43 @@
*/ */
/* /**
* Flag Document
* This is called for all of our flagging needs
*/
This will allow users to flag songs for having broken tags or bad rips.
*/ require_once('modules/init.php');
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';
}
show_template('header'); show_template('header');
if ( $action == 'flag' ) { $action = scrub_in($_REQUEST['action']);
$type = 'show_flagged_form'; $flag = new Flag($_REQUEST['flag_id']);
$song_id = $song;
include(conf('prefix') . "/templates/flag.inc"); /* 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(); show_footer();
?> ?>

98
lib/class/flag.class.php Normal file
View file

@ -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
?>

View file

@ -59,34 +59,30 @@ class Song {
if ($song_id) { if ($song_id) {
/* Assign id for use in get_info() */ /* Assign id for use in get_info() */
$this->id = $song_id; $this->id = sql_escape($song_id);
/* Get the information from the db */ /* Get the information from the db */
if ($info = $this->get_info()) { if ($info = $this->get_info()) {
/* Assign Vars */ /* Assign Vars */
$this->file = $info->file; $this->file = $info->file;
$this->album = $info->album; $this->album = $info->album;
$this->artist = $info->artist; $this->artist = $info->artist;
$this->title = $info->title; $this->title = $info->title;
$this->comment = $info->comment; $this->comment = $info->comment;
$this->year = $info->year; $this->year = $info->year;
$this->bitrate = $info->bitrate; $this->bitrate = $info->bitrate;
$this->rate = $info->rate; $this->rate = $info->rate;
$this->mode = $info->mode; $this->mode = $info->mode;
$this->size = $info->size; $this->size = $info->size;
$this->time = $info->time; $this->time = $info->time;
$this->track = $info->track; $this->track = $info->track;
$this->genre = $info->genre; $this->genre = $info->genre;
$this->addition_time = $info->addition_time; $this->addition_time = $info->addition_time;
$this->catalog = $info->catalog; $this->catalog = $info->catalog;
$this->played = $info->played; $this->played = $info->played;
$this->update_time = $info->update_time; $this->update_time = $info->update_time;
$this->flagid = $info->flagid; $this->enabled = $info->enabled;
$this->flaguser = $info->flaguser;
$this->flagtype = $info->flagtype;
$this->flagcomment = $info->flagcomment;
$this->enabled = $info->enabled;
// Format the Type of the song // Format the Type of the song
$this->format_type(); $this->format_type();
@ -107,7 +103,7 @@ class Song {
/* Grab the basic information from the catalog and return it */ /* Grab the basic information from the catalog and return it */
$sql = "SELECT song.id,file,catalog,album,song.comment,year,artist,". $sql = "SELECT song.id,file,catalog,album,song.comment,year,artist,".
"title,bitrate,rate,mode,size,time,track,genre,played,song.enabled,update_time,". "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()); $db_results = mysql_query($sql, dbh());
@ -115,7 +111,7 @@ class Song {
return $results; return $results;
} //get_info } // get_info
/*! /*!
@function format_type @function format_type
@ -144,6 +140,7 @@ class Song {
$this->mime = "audio/mpeg"; $this->mime = "audio/mpeg";
break; break;
case "rm": case "rm":
case "ra":
$this->mime = "audio/x-realaudio"; $this->mime = "audio/x-realaudio";
break; break;
case "flac"; case "flac";
@ -163,6 +160,7 @@ class Song {
} }
} // get_type } // get_type
/*! /*!
@function get_album_songs @function get_album_songs
@discussion gets an array of song objects based on album @discussion gets an array of song objects based on album
@ -170,7 +168,7 @@ class Song {
function get_album_songs($album_id) { function get_album_songs($album_id) {
$sql = "SELECT id FROM song WHERE album='$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)) { while ($r = mysql_fetch_object($db_results)) {
$results[] = new Song($r->id); $results[] = new Song($r->id);
@ -235,6 +233,45 @@ class Song {
} // get_genre_name } // 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 * set_played
* this checks to see if the current object has been played * this checks to see if the current object has been played
@ -684,20 +721,21 @@ class Song {
//TODO: fill out these cases once we have it working for m4a //TODO: fill out these cases once we have it working for m4a
case "m4a": case "m4a":
$return = false; $return = false;
break; break;
default: default:
$return = true; $return = true;
break; break;
} // end switch } // end switch
return $return; return $return;
} // end native_stream } // end native_stream
/*! /**
@function stream_cmd * stream_cmd
@discussion test if the song type streams natively and if not returns a transcoding command from the config * test if the song type streams natively and
*/ * if not returns a transcoding command from the config
*/
function stream_cmd() { function stream_cmd() {
$return = 'downsample_cmd'; $return = 'downsample_cmd';
@ -706,16 +744,16 @@ class Song {
switch ($this->type) { switch ($this->type) {
case "m4a": case "m4a":
$return = "stream_cmd_m4a"; $return = "stream_cmd_m4a";
break; break;
default: default:
$return = "downsample_cmd"; $return = "downsample_cmd";
break; break;
} // end switch } // end switch
} // end if not native_stream } // end if not native_stream
return $return; return $return;
} // end stream_cmd } // end stream_cmd
} //end of song class } // end of song class
?> ?>

View file

@ -1196,4 +1196,22 @@ function show_playlist_import() {
} // 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
?> ?>

View file

@ -83,7 +83,7 @@ if (!$results['conf']['allow_stream_playback']) {
$results['conf']['raw_web_path'] = $results['conf']['web_path']; $results['conf']['raw_web_path'] = $results['conf']['web_path'];
$results['conf']['web_path'] = $http_type . $_SERVER['HTTP_HOST'] . $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']['catalog_file_pattern']= 'mp3|mpc|m4p|m4a|mp4|aac|ogg|rm|wma|asf|flac|spx|ra';
$results['conf']['http_port'] = $_SERVER['SERVER_PORT']; $results['conf']['http_port'] = $_SERVER['SERVER_PORT'];
if (!$results['conf']['prefix']) { if (!$results['conf']['prefix']) {
@ -164,15 +164,11 @@ require_once(conf('prefix') . "/lib/xmlrpc.php");
require_once(conf('prefix') . "/modules/xmlrpc/xmlrpc.inc"); require_once(conf('prefix') . "/modules/xmlrpc/xmlrpc.inc");
if (conf('allow_slim_playback')) { 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')) { if (conf('allow_mpd_playback')) {
require_once(conf('prefix') . "/modules/mpd/mpd.class.php"); require_once(conf('prefix') . '/modules/mpd/mpd.class.php');
}
if (conf('allow_xmms2_playback')) {
require_once(conf('prefix') . "/modules/xmms2/xmms2.class.php");
} }
if (conf('ratings')) { if (conf('ratings')) {
@ -181,18 +177,19 @@ if (conf('ratings')) {
} }
// Classes // Classes
require_once(conf('prefix') . "/lib/class/catalog.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/stream.class.php');
require_once(conf('prefix') . "/lib/class/playlist.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/song.class.php');
require_once(conf('prefix') . "/lib/class/view.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/update.class.php');
require_once(conf('prefix') . "/lib/class/user.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/album.class.php');
require_once(conf('prefix') . "/lib/class/artist.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/access.class.php');
require_once(conf('prefix') . "/lib/class/error.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/genre.class.php');
require_once(conf('prefix') . '/lib/class/flag.class.php');
/* Set a new Error Handler */ /* Set a new Error Handler */
$old_error_handler = set_error_handler("ampache_error_handler"); $old_error_handler = set_error_handler("ampache_error_handler");

View file

@ -38,42 +38,6 @@ function show_album_pulldown ($album) {
} // show_album_pulldown() } // show_album_pulldown()
/*
* 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() * delete_user_stats()
* *
@ -95,87 +59,6 @@ function delete_user_stats ($user) {
} // delete_user_stats() } // 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 */ /* 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 () { function show_playlist_form () {
print <<<ECHO print <<<ECHO

View file

@ -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> &nbsp; </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>&nbsp;</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&amp;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&amp;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')
?>

136
templates/show_flag.inc.php Normal file
View file

@ -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> &nbsp; </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>&nbsp;</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&amp;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&amp;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')
?>

View file

@ -21,9 +21,6 @@
*/ */
$web_path = conf('web_path'); $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 it's a playlist and they've got rights */
if (is_object($playlist) && ($GLOBALS['user']->username == $playlist->user || $GLOBALS['user']->has_access('100'))) { if (is_object($playlist) && ($GLOBALS['user']->username == $playlist->user || $GLOBALS['user']->has_access('100'))) {
$tab = 1; $tab = 1;
@ -46,7 +43,6 @@ if (is_object($playlist) && ($GLOBALS['user']->username == $playlist->user || $G
<th><?php echo _("Size"); ?></th> <th><?php echo _("Size"); ?></th>
<th><?php echo _("Bitrate"); ?></th> <th><?php echo _("Bitrate"); ?></th>
<th><?php echo _("Genre"); ?></th> <th><?php echo _("Genre"); ?></th>
<th><?php echo _("Flag"); ?></th>
<th><?php echo _("Action"); ?></th> <th><?php echo _("Action"); ?></th>
<?php if (conf('ratings') || conf('ratings')=="false") { ?> <?php if (conf('ratings') || conf('ratings')=="false") { ?>
<th><?php echo _("Rating"); ?></th> <th><?php echo _("Rating"); ?></th>
@ -97,6 +93,7 @@ foreach ($song_ids as $song_id) {
<?php $tab++; <?php $tab++;
} ?> } ?>
<td> <td>
<?php if ($song->has_flag()) { echo "<strong>**</strong>"; } ?>
<a href="<?php echo $web_path; ?>/song.php?action=m3u&amp;song=<?php echo $song->id; ?>" title="<?php echo scrub_out($song->title); ?>" <?php echo $text_class; ?>><?php echo scrub_out($song->f_title); ?></a> <a href="<?php echo $web_path; ?>/song.php?action=m3u&amp;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>
<td> <td>
@ -120,25 +117,21 @@ foreach ($song_ids as $song_id) {
<td> <td>
<?php echo $song->f_genre; ?> <?php echo $song->f_genre; ?>
</td> </td>
<td <?php echo $song->f_style; ?> title="<?php echo $song->flagcomment; ?>">
<?php echo $song->flagtype; ?>
</td>
<td> <td>
<?php if ($user->has_access('100')) { ?> <a href="<?php echo $web_path; ?>/flag.php?action=show_flag&amp;type=song&amp;id=<?php echo $song->id; ?>">Flag</a>
<a href="<?php echo $web_path; ?>/admin/song.php?action=edit&amp;song=<?php echo $song->id; ?>">Edit</a> | <a href="<?php echo $web_path; ?>/flag.php?song=<?php echo $song->id; ?>&amp;action=flag">Flag</a> | <?php if ($GLOBALS['user']->has_access('100')) { ?>
| <a href="<?php echo $web_path; ?>/admin/song.php?action=edit&amp;song=<?php echo $song->id; ?>">Edit</a> |
<?php if ($song->enabled) { ?> <?php if ($song->enabled) { ?>
<a href="<?php echo $web_path; ?>/admin/song.php?action=disable&amp;song_ids=<?php echo $song->id; ?>">Disable</a> <a href="<?php echo $web_path; ?>/admin/song.php?action=disable&amp;song_ids=<?php echo $song->id; ?>">Disable</a>
<?php } else { ?> <?php } else { ?>
<a href="<?php echo $web_path; ?>/admin/song.php?action=enabled&amp;song_ids=<?php echo $song->id; ?>">Enable</a> <a href="<?php echo $web_path; ?>/admin/song.php?action=enabled&amp;song_ids=<?php echo $song->id; ?>">Enable</a>
<?php } //status ?> <?php } //status ?>
<?php } else { ?>
<a href="<?php echo $web_path; ?>/flag.php?song=<?php echo $song->id; ?>&amp;action=flag">Flag</a>
<?php } //access ?> <?php } //access ?>
<?php if ($user->prefs['download']) { ?> <?php if ($GLOBALS['user']->prefs['download']) { ?>
| <a href="<?php echo $web_path; ?>/download/index.php?action=download&amp;song_id=<?php echo $song->id; ?>&amp;fn=<?php echo rawurlencode($song->f_artist_full . " - " . $song->title . "." . $song->type); ?>"><?php echo _("Download"); ?></a> | <a href="<?php echo $web_path; ?>/download/index.php?action=download&amp;song_id=<?php echo $song->id; ?>&amp;fn=<?php echo rawurlencode($song->f_artist_full . " - " . $song->title . "." . $song->type); ?>"><?php echo _("Download"); ?></a>
<?php } ?> <?php } ?>
<?php if ($user->prefs['direct_link']) { ?> <?php if ($GLOBALS['user']->prefs['direct_link']) { ?>
| <a href="<?php echo $web_path; ?>/play/index.php?song=<?php echo $song->id; ?>&amp;uid=<?php echo $user->username . "&amp;sid=" . session_id(); ?>&amp;fn=<?php echo rawurlencode($song->f_artist_full . " - " . $song->title . "." . $song->type); ?>"><?php echo _("Direct Link"); ?></a> | <a href="<?php echo $web_path; ?>/play/index.php?song=<?php echo $song->id; ?>&amp;uid=<?php echo $GLOBALS['user']->username . "&amp;sid=" . session_id(); ?>&amp;fn=<?php echo rawurlencode($song->f_artist_full . " - " . $song->title . "." . $song->type); ?>"><?php echo _("Direct Link"); ?></a>
<?php } ?> <?php } ?>
</td> </td>
<?php if(conf('ratings')) { ?> <?php if(conf('ratings')) { ?>
@ -150,9 +143,6 @@ foreach ($song_ids as $song_id) {
<?php <?php
}// foreach loop }// foreach loop
//
// Another here doc
//
$time = floor($totaltime/60) . ":" . sprintf("%02d", ($totaltime%60) ); $time = floor($totaltime/60) . ":" . sprintf("%02d", ($totaltime%60) );
$megs = sprintf("%.2f", ($totalsize/1048576)); $megs = sprintf("%.2f", ($totalsize/1048576));
$num = count($song_ids); $num = count($song_ids);
@ -168,10 +158,10 @@ $num = count($song_ids);
<td align="right" nowrap="nowrap"><?php echo $megs; ?> MB</td> <td align="right" nowrap="nowrap"><?php echo $megs; ?> MB</td>
<td></td> <td></td>
<td></td> <td></td>
<td></td>
<td colspan="2"></td> <td colspan="2"></td>
</tr> </tr>
</table> </table>
<p class="header2"><?php echo _('** Indicates flagged songs'); ?></p>
<br /> <br />
<?php show_play_selected(); ?> <?php show_play_selected(); ?>
</form> </form>