2011-03-28 14:21:28 +00:00
< ?
//******************************************************************************//
//--------------- Delete request -----------------------------------------------//
authorize ();
$RequestID = $_POST [ 'id' ];
2013-05-04 08:00:48 +00:00
if ( ! is_number ( $RequestID )) {
2011-03-28 14:21:28 +00:00
error ( 0 );
}
2013-05-04 08:00:48 +00:00
$DB -> query ( "
SELECT
UserID ,
Title ,
CategoryID ,
GroupID
FROM requests
2013-07-10 00:08:53 +00:00
WHERE ID = $RequestID " );
2012-02-05 08:00:20 +00:00
list ( $UserID , $Title , $CategoryID , $GroupID ) = $DB -> next_record ();
2011-03-28 14:21:28 +00:00
2013-05-04 08:00:48 +00:00
if ( $LoggedUser [ 'ID' ] != $UserID && ! check_perms ( 'site_moderate_requests' )) {
2011-03-28 14:21:28 +00:00
error ( 403 );
}
$CategoryName = $Categories [ $CategoryID - 1 ];
//Do we need to get artists?
2013-07-11 08:00:55 +00:00
if ( $CategoryName === 'Music' ) {
2013-05-13 08:00:33 +00:00
$ArtistForm = Requests :: get_artists ( $RequestID );
2012-10-11 08:00:15 +00:00
$ArtistName = Artists :: display_artists ( $ArtistForm , false , true );
2013-02-19 08:00:30 +00:00
$FullName = $ArtistName . $Title ;
2011-03-28 14:21:28 +00:00
} else {
$FullName = $Title ;
}
// Delete request, votes and tags
2013-07-11 08:00:55 +00:00
$DB -> query ( " DELETE FROM requests WHERE ID = ' $RequestID ' " );
$DB -> query ( " DELETE FROM requests_votes WHERE RequestID = ' $RequestID ' " );
$DB -> query ( " DELETE FROM requests_tags WHERE RequestID = ' $RequestID ' " );
2013-08-28 23:08:41 +00:00
Comments :: delete_page ( 'requests' , $RequestID );
2013-07-10 00:08:53 +00:00
$DB -> query ( "
SELECT ArtistID
FROM requests_artists
WHERE RequestID = $RequestID " );
2011-03-28 14:21:28 +00:00
$RequestArtists = $DB -> to_array ();
2013-05-06 08:00:32 +00:00
foreach ( $RequestArtists as $RequestArtist ) {
2013-07-10 00:08:53 +00:00
$Cache -> delete_value ( " artists_requests_ $RequestArtist " );
2011-03-28 14:21:28 +00:00
}
2013-07-10 00:08:53 +00:00
$DB -> query ( "
DELETE FROM requests_artists
WHERE RequestID = '$RequestID' " );
2013-12-10 08:00:51 +00:00
$Cache -> delete_value ( " request_artists_ $RequestID " );
2011-03-28 14:21:28 +00:00
2014-02-19 08:00:32 +00:00
G :: $DB -> query ( "
REPLACE INTO sphinx_requests_delta
( ID )
VALUES
( $RequestID ) " );
2013-05-04 08:00:48 +00:00
if ( $UserID != $LoggedUser [ 'ID' ]) {
2014-04-09 08:00:45 +00:00
Misc :: send_pm ( $UserID , 0 , 'A request you created has been deleted' , " The request \" $FullName\ " was deleted by [ url = " .site_url().'user.php?id='. $LoggedUser['ID'] .']'. $LoggedUser['Username'] .'[/url] for the reason: [quote]'. $_POST['reason'] .'[/quote]');
2011-03-28 14:21:28 +00:00
}
2013-05-04 08:00:48 +00:00
Misc :: write_log ( " Request $RequestID ( $FullName ) was deleted by user " . $LoggedUser [ 'ID' ] . ' (' . $LoggedUser [ 'Username' ] . ') for the reason: ' . $_POST [ 'reason' ]);
2011-03-28 14:21:28 +00:00
2013-07-10 00:08:53 +00:00
$Cache -> delete_value ( " request_ $RequestID " );
$Cache -> delete_value ( " request_votes_ $RequestID " );
2012-02-05 08:00:20 +00:00
if ( $GroupID ) {
2013-07-10 00:08:53 +00:00
$Cache -> delete_value ( " requests_group_ $GroupID " );
2012-02-05 08:00:20 +00:00
}
2011-03-28 14:21:28 +00:00
header ( 'Location: requests.php' );
?>