Gazelle/sections/artist/delete_alias.php

40 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);
}
$DB->query("SELECT aa.AliasID
2013-02-22 08:00:24 +00:00
FROM artists_alias AS aa
JOIN artists_alias AS aa2 ON aa.ArtistID=aa2.ArtistID
2011-03-28 14:21:28 +00:00
WHERE aa.AliasID=".$AliasID);
2013-03-23 08:00:43 +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
}
$DB->query("SELECT GroupID FROM torrents_artists WHERE AliasID='$AliasID'");
2013-03-23 08:00:43 +00:00
if ($DB->record_count() > 0) {
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-03-23 08:00:43 +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);
$DB->query("DELETE FROM artists_alias WHERE AliasID='$AliasID'");
$DB->query("UPDATE artists_alias SET Redirect='0' WHERE Redirect='$AliasID'");
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]");