Gazelle/sections/collages/take_delete.php

56 lines
1.4 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
authorize();
$CollageID = $_POST['collageid'];
2013-05-02 08:00:23 +00:00
if (!is_number($CollageID) || !$CollageID) {
2013-02-22 08:00:24 +00:00
error(404);
2011-03-28 14:21:28 +00:00
}
2013-07-13 08:00:46 +00:00
$DB->query("
SELECT Name, CategoryID, UserID
FROM collages
WHERE ID = '$CollageID'");
2012-07-25 08:00:15 +00:00
list($Name, $CategoryID, $UserID) = $DB->next_record(MYSQLI_NUM, false);
2011-03-28 14:21:28 +00:00
2013-07-13 08:00:46 +00:00
if (!check_perms('site_collages_delete') && $UserID !== $LoggedUser['ID']) {
2011-03-28 14:21:28 +00:00
error(403);
}
$Reason = trim($_POST['reason']);
2013-05-02 08:00:23 +00:00
if (!$Reason) {
error('You must enter a reason!');
2011-03-28 14:21:28 +00:00
}
2013-07-13 08:00:46 +00:00
$DB->query("
SELECT GroupID
FROM collages_torrents
WHERE CollageID = '$CollageID'");
2013-05-02 08:00:23 +00:00
while (list($GroupID) = $DB->next_record()) {
2013-07-13 08:00:46 +00:00
$Cache->delete_value("torrents_details_$GroupID");
$Cache->delete_value("torrent_collages_$GroupID");
$Cache->delete_value("torrent_collages_personal_$GroupID");
2011-03-28 14:21:28 +00:00
}
//Personal collages have CategoryID 0
2013-08-28 23:08:41 +00:00
if ($CategoryID == 0) {
2013-11-23 08:01:14 +00:00
$DB->query("
DELETE FROM collages
WHERE ID = '$CollageID'");
$DB->query("
DELETE FROM collages_torrents
WHERE CollageID = '$CollageID'");
2013-08-28 23:08:41 +00:00
Comments::delete_page('collages', $CollageID);
2011-03-28 14:21:28 +00:00
} else {
2013-07-13 08:00:46 +00:00
$DB->query("
UPDATE collages
SET Deleted = '1'
WHERE ID = '$CollageID'");
2013-08-28 23:08:41 +00:00
Subscriptions::flush_subscriptions('collages', $CollageID);
Subscriptions::flush_quote_notifications('collages', $CollageID);
2011-03-28 14:21:28 +00:00
}
2013-07-13 08:00:46 +00:00
Misc::write_log("Collage $CollageID ($Name) was deleted by ".$LoggedUser['Username'].": $Reason");
2011-03-28 14:21:28 +00:00
2013-07-13 08:00:46 +00:00
$Cache->delete_value("collage_$CollageID");
2011-03-28 14:21:28 +00:00
header('Location: collages.php');