2013-01-19 08:00:51 +00:00
< ?
authorize ();
2015-11-20 08:00:28 +00:00
if ( ! check_perms ( 'admin_reports' ) && ! check_perms ( 'project_team' ) && ! check_perms ( 'site_moderate_forums' )) {
2013-01-19 08:00:51 +00:00
ajax_error ();
}
2015-11-20 08:00:28 +00:00
$ReportID = ( int ) $_POST [ 'reportid' ];
2013-01-19 08:00:51 +00:00
2013-07-04 08:00:56 +00:00
$DB -> query ( "
SELECT Type
FROM reports
WHERE ID = $ReportID " );
2013-01-19 08:00:51 +00:00
list ( $Type ) = $DB -> next_record ();
2013-04-15 08:00:54 +00:00
if ( ! check_perms ( 'admin_reports' )) {
if ( check_perms ( 'site_moderate_forums' )) {
2013-08-28 23:08:41 +00:00
if ( ! in_array ( $Type , array ( 'comment' , 'post' , 'thread' ))) {
2013-01-19 08:00:51 +00:00
ajax_error ();
}
2013-04-15 08:00:54 +00:00
} elseif ( check_perms ( 'project_team' )) {
if ( $Type != 'request_update' ) {
2013-01-19 08:00:51 +00:00
ajax_error ();
}
}
}
2013-05-15 08:00:54 +00:00
$DB -> query ( "
UPDATE reports
2013-07-04 08:00:56 +00:00
SET Status = 'Resolved' ,
ResolvedTime = '".sqltime()."' ,
ResolverID = '".$LoggedUser[' ID ']."'
WHERE ID = '".db_string($ReportID)."' " );
2013-01-19 08:00:51 +00:00
$Channels = array ();
2013-04-15 08:00:54 +00:00
if ( $Type == 'request_update' ) {
$Channels [] = '#requestedits' ;
2013-01-19 08:00:51 +00:00
$Cache -> decrement ( 'num_update_reports' );
}
2013-08-28 23:08:41 +00:00
if ( in_array ( $Type , array ( 'comment' , 'post' , 'thread' ))) {
2013-04-15 08:00:54 +00:00
$Channels [] = '#forumreports' ;
2013-01-19 08:00:51 +00:00
$Cache -> decrement ( 'num_forum_reports' );
}
2013-07-04 08:00:56 +00:00
$DB -> query ( "
SELECT COUNT ( ID )
FROM reports
WHERE Status = 'New' " );
2013-01-19 08:00:51 +00:00
list ( $Remaining ) = $DB -> next_record ();
2013-04-15 08:00:54 +00:00
foreach ( $Channels as $Channel ) {
2013-07-04 08:00:56 +00:00
send_irc ( " PRIVMSG $Channel :Report $ReportID resolved by " . preg_replace ( '/^(.{2})/' , '$1·' , $LoggedUser [ 'Username' ]) . ' on site (' . ( int ) $Remaining . ' remaining).' );
2013-01-19 08:00:51 +00:00
}
$Cache -> delete_value ( 'num_other_reports' );
ajax_success ();
2013-04-15 08:00:54 +00:00
function ajax_error ( $Error = 'error' ) {
2013-07-04 08:00:56 +00:00
echo json_encode ( array ( 'status' => $Error ));
2013-01-19 08:00:51 +00:00
die ();
}
function ajax_success () {
2013-07-04 08:00:56 +00:00
echo json_encode ( array ( 'status' => 'success' ));
2013-01-19 08:00:51 +00:00
die ();
}
?>