Gazelle/sections/requests/takedelete.php

63 lines
2.0 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
//******************************************************************************//
//--------------- Delete request -----------------------------------------------//
authorize();
$RequestID = $_POST['id'];
if(!is_number($RequestID)) {
error(0);
}
$DB->query("SELECT UserID,
Title,
2012-02-05 08:00:20 +00:00
CategoryID,
GroupID
2011-03-28 14:21:28 +00:00
FROM requests
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
if($LoggedUser['ID'] != $UserID && !check_perms('site_moderate_requests')) {
error(403);
}
$CategoryName = $Categories[$CategoryID - 1];
//Do we need to get artists?
if($CategoryName == "Music") {
$ArtistForm = get_request_artists($RequestID);
2012-10-11 08:00:15 +00:00
$ArtistName = Artists::display_artists($ArtistForm, false, true);
2011-03-28 14:21:28 +00:00
$FullName = $ArtistName.$Title;
} else {
$FullName = $Title;
}
// Delete request, votes and tags
$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'");
$DB->query("SELECT ArtistID FROM requests_artists WHERE RequestID = ".$RequestID);
$RequestArtists = $DB->to_array();
foreach($RequestArtists as $RequestArtist) {
$Cache->delete_value('artists_requests_'.$RequestArtist);
}
$DB->query("DELETE FROM requests_artists WHERE RequestID='$RequestID'");
if($UserID != $LoggedUser['ID']) {
2012-10-11 08:00:15 +00:00
Misc::send_pm($UserID, 0, db_string("A request you created has been deleted"), db_string("The request '".$FullName."' was deleted by [url=http://".NONSSL_SITE_URL."/user.php?id=".$LoggedUser['ID']."]".$LoggedUser['Username']."[/url] for the reason: ".$_POST['reason']));
2011-03-28 14:21:28 +00:00
}
2012-10-11 08:00:15 +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
$Cache->delete_value('request_'.$RequestID);
$Cache->delete_value('request_votes_'.$RequestID);
2012-02-05 08:00:20 +00:00
if ($GroupID) {
$Cache->delete_value('requests_group_'.$GroupID);
}
2012-10-11 08:00:15 +00:00
Requests::update_sphinx_requests($RequestID);
2011-03-28 14:21:28 +00:00
header('Location: requests.php');
?>