Gazelle/sections/reports/reports.php

257 lines
7.7 KiB
PHP
Raw Permalink Normal View History

2011-03-28 14:21:28 +00:00
<?
/************************************************************************
************************************************************************/
2012-12-10 08:00:21 +00:00
if (!check_perms('admin_reports') && !check_perms('project_team') && !check_perms('site_moderate_forums')) {
2011-03-28 14:21:28 +00:00
error(404);
}
// Number of reports per page
define('REPORTS_PER_PAGE', '10');
2012-12-10 08:00:21 +00:00
list($Page, $Limit) = Format::page_limit(REPORTS_PER_PAGE);
2011-03-28 14:21:28 +00:00
2012-12-10 08:00:21 +00:00
include(SERVER_ROOT . '/sections/reports/array.php');
2011-03-28 14:21:28 +00:00
// Header
2012-12-10 08:00:21 +00:00
View::show_header('Reports', 'bbcode,reports');
2011-03-28 14:21:28 +00:00
2012-12-10 08:00:21 +00:00
if ($_GET['id'] && is_number($_GET['id'])) {
2013-07-04 08:00:56 +00:00
$View = 'Single report';
$Where = 'r.ID = ' . $_GET['id'];
2013-09-15 08:00:53 +00:00
} elseif (empty($_GET['view'])) {
2013-07-04 08:00:56 +00:00
$View = 'New';
$Where = "Status = 'New'";
2011-03-28 14:21:28 +00:00
} else {
$View = $_GET['view'];
2012-12-10 08:00:21 +00:00
switch ($_GET['view']) {
2013-10-01 23:08:42 +00:00
case 'old':
2013-07-04 08:00:56 +00:00
$Where = "Status = 'Resolved'";
2011-03-28 14:21:28 +00:00
break;
2013-10-01 23:08:42 +00:00
default:
2011-03-28 14:21:28 +00:00
error(404);
break;
}
}
2012-12-10 08:00:21 +00:00
if (!check_perms('admin_reports')) {
if (check_perms('project_team')) {
$Where .= " AND Type = 'request_update'";
}
2012-12-10 08:00:21 +00:00
if (check_perms('site_moderate_forums')) {
2013-08-28 23:08:41 +00:00
$Where .= " AND Type IN('comment', 'post', 'thread')";
}
2011-03-28 14:21:28 +00:00
}
2013-05-21 08:01:09 +00:00
$Reports = $DB->query("
2013-05-29 08:00:51 +00:00
SELECT
SQL_CALC_FOUND_ROWS
2013-02-22 08:00:24 +00:00
r.ID,
2011-03-28 14:21:28 +00:00
r.UserID,
2013-02-22 08:00:24 +00:00
um.Username,
r.ThingID,
r.Type,
r.ReportedTime,
r.Reason,
2012-12-10 08:00:21 +00:00
r.Status,
r.ClaimerID,
2013-03-09 08:00:18 +00:00
r.Notes,
r.ResolverID
2013-02-22 08:00:24 +00:00
FROM reports AS r
2013-07-04 08:00:56 +00:00
JOIN users_main AS um ON r.UserID = um.ID
2013-05-21 08:01:09 +00:00
WHERE $Where
ORDER BY ReportedTime DESC
LIMIT $Limit");
2011-03-28 14:21:28 +00:00
// Number of results (for pagination)
$DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record();
// Done with the number of results. Move $DB back to the result set for the reports
$DB->set_query_id($Reports);
// Start printing stuff
?>
<div class="thin">
2013-01-16 08:00:31 +00:00
<div class="header">
<h2>Active Reports</h2>
<div class="linkbox">
<a href="reports.php">New</a> |
<a href="reports.php?view=old">Old</a> |
<a href="reports.php?action=stats">Stats</a>
</div>
</div>
<div class="linkbox">
2013-04-17 08:00:58 +00:00
<?
2012-08-19 08:00:19 +00:00
// pagination
2012-12-10 08:00:21 +00:00
$Pages = Format::get_pages($Page, $Results, REPORTS_PER_PAGE, 11);
echo $Pages;
?>
2013-01-16 08:00:31 +00:00
</div>
2013-04-17 08:00:58 +00:00
<?
2013-01-29 08:00:36 +00:00
while (list($ReportID, $SnitchID, $SnitchName, $ThingID, $Short, $ReportedTime, $Reason, $Status, $ClaimerID, $Notes, $ResolverID) = $DB->next_record()) {
2012-12-10 08:00:21 +00:00
$Type = $Types[$Short];
2013-07-04 08:00:56 +00:00
$Reference = "reports.php?id=$ReportID#report$ReportID";
2013-10-26 08:00:58 +00:00
?>
2013-11-08 08:01:03 +00:00
<div id="report_<?=$ReportID?>" style="margin-bottom: 1em;" class="pending_report_v1">
2013-01-16 08:00:31 +00:00
<table cellpadding="5" id="report_<?=$ReportID?>">
<tr>
<td><strong><a href="<?=$Reference?>">Report #<?=$ReportID?></a></strong></td>
<td>
<strong><?=$Type['title']?></strong> was reported by <a href="user.php?id=<?=$SnitchID?>"><?=$SnitchName?></a> <?=time_diff($ReportedTime)?>
2013-02-09 08:01:01 +00:00
<a href="reports.php?action=compose&amp;to=<?=$SnitchID?>&amp;reportid=<?=$ReportID?>&amp;type=<?=$Short?>&amp;thingid=<?=$ThingID?>" class="brackets">Contact</a>
2013-01-16 08:00:31 +00:00
</td>
</tr>
<tr>
<td class="center" colspan="2">
<strong>
2013-04-17 08:00:58 +00:00
<? switch ($Short) {
2013-07-04 08:00:56 +00:00
case 'user':
$DB->query("
SELECT Username
FROM users_main
WHERE ID = $ThingID");
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) {
2013-05-21 08:01:09 +00:00
echo 'No user with the reported ID found';
2012-12-10 08:00:21 +00:00
} else {
list($Username) = $DB->next_record();
2013-05-21 08:01:09 +00:00
echo "<a href=\"user.php?id=$ThingID\">" . display_str($Username) . '</a>';
2012-12-10 08:00:21 +00:00
}
break;
2013-07-04 08:00:56 +00:00
case 'request':
case 'request_update':
$DB->query("
SELECT Title
FROM requests
WHERE ID = $ThingID");
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) {
2013-05-21 08:01:09 +00:00
echo 'No request with the reported ID found';
2012-12-10 08:00:21 +00:00
} else {
list($Name) = $DB->next_record();
2013-05-21 08:01:09 +00:00
echo "<a href=\"requests.php?action=view&amp;id=$ThingID\">" . display_str($Name) . '</a>';
2012-12-10 08:00:21 +00:00
}
break;
2013-07-04 08:00:56 +00:00
case 'collage':
$DB->query("
SELECT Name
FROM collages
WHERE ID = $ThingID");
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) {
2013-05-21 08:01:09 +00:00
echo 'No collage with the reported ID found';
2012-12-10 08:00:21 +00:00
} else {
list($Name) = $DB->next_record();
2013-05-21 08:01:09 +00:00
echo "<a href=\"collages.php?id=$ThingID\">" . display_str($Name) . '</a>';
2012-12-10 08:00:21 +00:00
}
break;
2013-07-04 08:00:56 +00:00
case 'thread':
$DB->query("
SELECT Title
FROM forums_topics
WHERE ID = $ThingID");
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) {
2013-05-21 08:01:09 +00:00
echo 'No forum thread with the reported ID found';
2012-12-10 08:00:21 +00:00
} else {
list($Title) = $DB->next_record();
2013-05-21 08:01:09 +00:00
echo "<a href=\"forums.php?action=viewthread&amp;threadid=$ThingID\">" . display_str($Title) . '</a>';
2012-12-10 08:00:21 +00:00
}
break;
2013-07-04 08:00:56 +00:00
case 'post':
2012-12-10 08:00:21 +00:00
if (isset($LoggedUser['PostsPerPage'])) {
$PerPage = $LoggedUser['PostsPerPage'];
} else {
$PerPage = POSTS_PER_PAGE;
}
2013-05-21 08:01:09 +00:00
$DB->query("
SELECT
p.ID,
p.Body,
p.TopicID,
2013-11-17 08:00:47 +00:00
(
SELECT COUNT(p2.ID)
FROM forums_posts AS p2
WHERE p2.TopicID = p.TopicID
AND p2.ID <= p.ID
2013-05-21 08:01:09 +00:00
) AS PostNum
FROM forums_posts AS p
2013-11-17 08:00:47 +00:00
WHERE p.ID = $ThingID");
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) {
2013-05-21 08:01:09 +00:00
echo 'No forum post with the reported ID found';
2012-12-10 08:00:21 +00:00
} else {
list($PostID, $Body, $TopicID, $PostNum) = $DB->next_record();
2013-11-17 08:00:47 +00:00
echo "<a href=\"forums.php?action=viewthread&amp;threadid=$TopicID&amp;post=$PostNum#post$PostID\">FORUM POST ID #$PostID</a>";
2012-12-10 08:00:21 +00:00
}
break;
2013-08-28 23:08:41 +00:00
case 'comment':
2013-05-21 08:01:09 +00:00
$DB->query("
2013-08-28 23:08:41 +00:00
SELECT 1
2013-11-17 08:00:47 +00:00
FROM comments
2013-07-04 08:00:56 +00:00
WHERE ID = $ThingID");
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) {
2013-05-21 08:01:09 +00:00
echo 'No comment with the reported ID found';
2012-12-10 08:00:21 +00:00
} else {
2013-08-28 23:08:41 +00:00
echo "<a href=\"comments.php?action=jump&amp;postid=$ThingID\">COMMENT</a>";
2012-12-10 08:00:21 +00:00
}
break;
}
?>
2013-01-15 08:00:37 +00:00
</strong>
</td>
</tr>
<tr>
2013-12-12 08:01:01 +00:00
<td colspan="2"><?=Text::full_format($Reason)?></td>
2013-01-15 08:00:37 +00:00
</tr>
<tr>
<td colspan="2">
2013-04-17 08:00:58 +00:00
<? if ($ClaimerID == $LoggedUser['ID']) { ?>
2013-02-09 08:01:01 +00:00
<span id="claimed_<?=$ReportID?>">Claimed by <?=Users::format_username($ClaimerID, false, false, false, false)?> <a href="#" onclick="unClaim(<?=$ReportID?>); return false;" class="brackets">Unclaim</a></span>
2013-09-15 08:00:53 +00:00
<? } elseif ($ClaimerID) { ?>
2013-01-15 08:00:37 +00:00
<span id="claimed_<?=$ReportID?>">Claimed by <?=Users::format_username($ClaimerID, false, false, false, false)?></span>
2013-04-17 08:00:58 +00:00
<? } else { ?>
2013-02-09 08:01:01 +00:00
<a href="#" id="claim_<?=$ReportID?>" onclick="claim(<?=$ReportID?>); return false;" class="brackets">Claim</a>
2013-04-17 08:00:58 +00:00
<? } ?>
2013-01-15 08:00:37 +00:00
&nbsp;&nbsp;
2013-02-22 08:00:24 +00:00
<a href="#" onclick="toggleNotes(<?=$ReportID?>); return false;" class="brackets">Toggle notes</a>
2012-12-10 08:00:21 +00:00
2013-07-04 08:00:56 +00:00
<div id="notes_div_<?=$ReportID?>" style="display: <?=empty($Notes) ? 'none' : 'block'; ?>;">
2013-01-15 08:00:37 +00:00
<textarea cols="50" rows="3" id="notes_<?=$ReportID?>"><?=$Notes?></textarea>
<br />
<input type="submit" onclick="saveNotes(<?=$ReportID?>)" value="Save" />
</div>
</td>
</tr>
2013-05-21 08:01:09 +00:00
<? if ($Status != 'Resolved') { ?>
2013-01-15 08:00:37 +00:00
<tr>
<td class="center" colspan="2">
2013-03-09 08:00:18 +00:00
<form id="report_form_<?=$ReportID?>" action="">
2013-01-15 08:00:37 +00:00
<input type="hidden" name="reportid" value="<?=$ReportID?>" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
2013-05-21 08:01:09 +00:00
<input type="submit" onclick="return resolve(<?=$ReportID?>, <?=(($ClaimerID == $LoggedUser['ID'] || !$ClaimerID) ? 'true' : 'false')?>)" name="submit" value="Resolve" />
2013-01-15 08:00:37 +00:00
</form>
</td>
</tr>
2013-07-04 08:00:56 +00:00
<?
} else {
2013-04-17 08:00:58 +00:00
$ResolverInfo = Users::user_info($ResolverID);
2013-07-04 08:00:56 +00:00
?>
2013-03-09 08:00:18 +00:00
<tr>
<td colspan="2">
Resolved by <a href="users.php?id=<?=$ResolverID?>"><?=$ResolverInfo['Username']?></a>
</td>
</tr>
2013-04-17 08:00:58 +00:00
<? } ?>
2013-01-15 08:00:37 +00:00
</table>
</div>
2013-04-17 08:00:58 +00:00
<?
2012-12-10 08:00:21 +00:00
$DB->set_query_id($Reports);
2011-03-28 14:21:28 +00:00
}
2012-12-10 08:00:21 +00:00
?>
2013-01-15 08:00:37 +00:00
<div class="linkbox">
2013-04-17 08:00:58 +00:00
<?
2012-12-10 08:00:21 +00:00
echo $Pages;
?>
2013-01-15 08:00:37 +00:00
</div>
2011-03-28 14:21:28 +00:00
</div>
<?
2012-10-11 08:00:15 +00:00
View::show_footer();
2011-03-28 14:21:28 +00:00
?>