Gazelle/sections/artist/delete_alias.php

53 lines
1.3 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
authorize();
2013-03-23 08:00:43 +00:00
if (!check_perms('torrents_edit')) {
error(403);
}
2011-03-28 14:21:28 +00:00
$AliasID = $_GET['aliasid'];
2013-03-23 08:00:43 +00:00
if (!is_number($AliasID)) {
2011-03-28 14:21:28 +00:00
error(0);
}
2013-05-27 08:00:58 +00:00
$DB->query("
SELECT aa.AliasID
FROM artists_alias AS aa
JOIN artists_alias AS aa2 ON aa.ArtistID=aa2.ArtistID
WHERE aa.AliasID=".$AliasID);
2011-03-28 14:21:28 +00:00
2013-07-10 00:08:53 +00:00
if ($DB->record_count() === 1) {
2011-03-28 14:21:28 +00:00
//This is the last alias on the artist
2013-03-23 08:00:43 +00:00
error("That alias is the last alias for that artist; removing it would cause bad things to happen.");
2011-03-28 14:21:28 +00:00
}
2013-05-27 08:00:58 +00:00
$DB->query("
SELECT GroupID
FROM torrents_artists
WHERE AliasID='$AliasID'");
2013-07-10 00:08:53 +00:00
if ($DB->has_results()) {
2011-03-28 14:21:28 +00:00
list($GroupID) = $DB->next_record();
2013-03-23 08:00:43 +00:00
if ($GroupID != 0) {
error("That alias still has the group (<a href=\"torrents.php?id=$GroupID\">$GroupID</a>) attached. Fix that first.");
2011-03-28 14:21:28 +00:00
}
}
2013-05-27 08:00:58 +00:00
$DB->query("
SELECT aa.ArtistID, ag.Name, aa.Name
FROM artists_alias AS aa
JOIN artists_group AS ag ON aa.ArtistID=ag.ArtistID
WHERE aa.AliasID=$AliasID");
2011-03-28 14:21:28 +00:00
list($ArtistID, $ArtistName, $AliasName) = $DB->next_record(MYSQLI_NUM, false);
2013-05-27 08:00:58 +00:00
$DB->query("
DELETE FROM artists_alias
WHERE AliasID='$AliasID'");
$DB->query("
UPDATE artists_alias
SET Redirect='0'
WHERE Redirect='$AliasID'");
2011-03-28 14:21:28 +00:00
2013-03-23 08:00:43 +00:00
Misc::write_log("The alias $AliasID ($AliasName) was removed from the artist $ArtistID ($ArtistName) by user $LoggedUser[ID] ($LoggedUser[Username])");
2011-03-28 14:21:28 +00:00
2013-03-23 08:00:43 +00:00
header("Location: $_SERVER[HTTP_REFERER]");