/*
* This page is used for viewing reports in every viewpoint except auto.
* It doesn't AJAX grab a new report when you resolve each one, use auto
* for that (reports.php). If you wanted to add a new view, you'd simply
* add to the case statement(s) below and add an entry to views.php to
* explain it.
* Any changes made to this page within the foreach loop should probably be
* replicated on the auto page (reports.php).
*/
if (!check_perms('admin_reports')) {
error(403);
}
include(SERVER_ROOT.'/classes/class_text.php');
$Text = NEW TEXT;
define('REPORTS_PER_PAGE', '10');
list($Page,$Limit) = Format::page_limit(REPORTS_PER_PAGE);
if (isset($_GET['view'])) {
$View = $_GET['view'];
} else {
error(404);
}
if (isset($_GET['id'])) {
if (!is_number($_GET['id']) && $View != 'type') {
error(404);
} else {
$ID = db_string($_GET['id']);
}
} else {
$ID = '';
}
$Order = "ORDER BY r.ReportedTime ASC";
if (!$ID) {
switch ($View) {
case 'resolved' :
$Title = 'All the old smelly reports';
$Where = "WHERE r.Status = 'Resolved'";
$Order = 'ORDER BY r.LastChangeTime DESC';
break;
case 'unauto' :
$Title = 'New reports, not auto assigned!';
$Where = "WHERE r.Status = 'New'";
break;
default :
error(404);
break;
}
} else {
switch ($View) {
case 'staff' :
$DB->query("SELECT Username FROM users_main WHERE ID=".$ID);
list($Username) = $DB->next_record();
if ($Username) {
$Title = $Username."'s in-progress reports";
} else {
$Title = $ID."'s in-progress reports";
}
$Where = "WHERE r.Status = 'InProgress' AND r.ResolverID = ".$ID;
break;
case 'resolver' :
$DB->query("SELECT Username FROM users_main WHERE ID=".$ID);
list($Username) = $DB->next_record();
if ($Username) {
$Title = $Username."'s resolved reports";
} else {
$Title = $ID."'s resolved reports";
}
$Where = "WHERE r.Status = 'Resolved' AND r.ResolverID = ".$ID;
$Order = 'ORDER BY r.LastChangeTime DESC';
break;
case 'group' :
$Title = "Unresolved reports for the group $ID";
$Where = "WHERE r.Status != 'Resolved' AND tg.ID = ".$ID;
break;
case 'torrent' :
$Title = 'All reports for the torrent '.$ID;
$Where = 'WHERE r.TorrentID = '.$ID;
break;
case 'report' :
$Title = 'Viewing resolution of report '.$ID;
$Where = 'WHERE r.ID = '.$ID;
break;
case 'reporter' :
$DB->query("SELECT Username FROM users_main WHERE ID=".$ID);
list($Username) = $DB->next_record();
if ($Username) {
$Title = 'All torrents reported by '.$Username;
} else {
$Title = 'All torrents reported by user '.$ID;
}
$Where = 'WHERE r.ReporterID = '.$ID;
$Order = 'ORDER BY r.ReportedTime DESC';
break;
case 'uploader' :
$DB->query("SELECT Username FROM users_main WHERE ID=".$ID);
list($Username) = $DB->next_record();
if ($Username) {
$Title = 'All reports for torrents uploaded by '.$Username;
} else {
$Title = 'All reports for torrents uploaded by user '.$ID;
}
$Where = "WHERE r.Status != 'Resolved' AND t.UserID = ".$ID;
break;
case 'type':
$Title = 'All new reports for the chosen type';
$Where = "WHERE r.Status = 'New' AND r.Type = '".$ID."'";
break;
break;
default :
error(404);
break;
}
}
$DB->query("SELECT SQL_CALC_FOUND_ROWS
r.ID,
r.ReporterID,
reporter.Username,
r.TorrentID,
r.Type,
r.UserComment,
r.ResolverID,
resolver.Username,
r.Status,
r.ReportedTime,
r.LastChangeTime,
r.ModComment,
r.Track,
r.Image,
r.ExtraID,
r.Link,
r.LogMessage,
tg.Name,
tg.ID,
CASE COUNT(ta.GroupID)
WHEN 1 THEN aa.ArtistID
WHEN 0 THEN '0'
ELSE '0'
END AS ArtistID,
CASE COUNT(ta.GroupID)
WHEN 1 THEN aa.Name
WHEN 0 THEN ''
ELSE 'Various Artists'
END AS ArtistName,
tg.Year,
tg.CategoryID,
t.Time,
t.Remastered,
t.RemasterTitle,
t.RemasterYear,
t.Media,
t.Format,
t.Encoding,
t.Size,
t.HasCue,
t.HasLog,
t.LogScore,
t.UserID AS UploaderID,
uploader.Username
FROM reportsv2 AS r
LEFT JOIN torrents AS t ON t.ID=r.TorrentID
LEFT JOIN torrents_group AS tg ON tg.ID=t.GroupID
LEFT JOIN torrents_artists AS ta ON ta.GroupID=tg.ID AND ta.Importance='1'
LEFT JOIN artists_alias AS aa ON aa.AliasID=ta.AliasID
LEFT JOIN users_main AS resolver ON resolver.ID=r.ResolverID
LEFT JOIN users_main AS reporter ON reporter.ID=r.ReporterID
LEFT JOIN users_main AS uploader ON uploader.ID=t.UserID "
.$Where."
GROUP BY r.ID "
.$Order."
LIMIT ".$Limit);
$Reports = $DB->to_array();
$DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record();
$PageLinks=Format::get_pages($Page,$Results,REPORTS_PER_PAGE,11);
View::show_header('Reports V2!', 'reportsv2,bbcode');
?>
=$Title?>
include('header.php'); ?>
if ($View != 'resolved') { ?>
}
if ($View == 'staff' && $LoggedUser['ID'] == $ID) { ?>
|
} ?>