Gazelle/sections/artist/delete.php

94 lines
2.3 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
/************************************************************************
||------------|| Delete artist ||--------------------------------------||
This is a very powerful page - it deletes an artist, and all associated
requests and torrents. It is called when $_GET['action'] == 'delete'.
************************************************************************/
authorize();
$ArtistID = $_GET['artistid'];
2013-05-05 08:00:31 +00:00
if (!is_number($ArtistID) || empty($ArtistID)) {
error(0);
}
2011-03-28 14:21:28 +00:00
2013-05-05 08:00:31 +00:00
if (!check_perms('site_delete_artist') || !check_perms('torrents_delete')) {
error(403);
}
2011-03-28 14:21:28 +00:00
2012-10-11 08:00:15 +00:00
View::show_header('Artist deleted');
2011-03-28 14:21:28 +00:00
2013-07-10 00:08:53 +00:00
$DB->query("
SELECT Name
FROM artists_group
WHERE ArtistID = $ArtistID");
2011-03-28 14:21:28 +00:00
list($Name) = $DB->next_record();
2013-07-10 00:08:53 +00:00
$DB->query("
2013-05-05 08:00:31 +00:00
SELECT tg.Name, tg.ID
FROM torrents_group AS tg
2013-07-10 00:08:53 +00:00
LEFT JOIN torrents_artists AS ta ON ta.GroupID = tg.ID
WHERE ta.ArtistID = $ArtistID");
2011-03-28 14:21:28 +00:00
$Count = $DB->record_count();
2013-07-10 00:08:53 +00:00
if ($DB->has_results()) {
2011-03-28 14:21:28 +00:00
?>
<div class="thin">
2013-08-28 23:08:41 +00:00
There are still torrents that have <a href="artist.php?id=<?=$ArtistID?>" class="tooltip" title="View artist"><?=$Name?></a> as an artist.<br />
2012-09-23 08:00:25 +00:00
Please remove the artist from these torrents manually before attempting to delete.<br />
2011-03-28 14:21:28 +00:00
<div class="box pad">
<ul>
<?
2013-05-05 08:00:31 +00:00
while (list($GroupName, $GroupID) = $DB->next_record(MYSQLI_NUM, true)) {
2011-03-28 14:21:28 +00:00
?>
<li>
<a href="torrents.php?id=<?=$GroupID?>" title="View Torrent"><?=$GroupName?></a>
</li>
<?
}
?>
</ul>
</div>
</div>
<?
}
2013-07-10 00:08:53 +00:00
$DB->query("
2013-05-05 08:00:31 +00:00
SELECT r.Title, r.ID
FROM requests AS r
2013-07-10 00:08:53 +00:00
LEFT JOIN requests_artists AS ra ON ra.RequestID = r.ID
WHERE ra.ArtistID = $ArtistID");
2011-03-28 14:21:28 +00:00
$Count += $DB->record_count();
2013-07-10 00:08:53 +00:00
if ($DB->has_results()) {
2011-03-28 14:21:28 +00:00
?>
<div class="thin">
2013-08-28 23:08:41 +00:00
There are still requests that have <a href="artist.php?id=<?=$ArtistID?>" class="tooltip" title="View artist"><?=$Name?></a> as an artist.<br />
2012-09-23 08:00:25 +00:00
Please remove the artist from these requests manually before attempting to delete.<br />
2011-03-28 14:21:28 +00:00
<div class="box pad">
<ul>
<?
2013-05-05 08:00:31 +00:00
while (list($RequestName, $RequestID) = $DB->next_record(MYSQLI_NUM, true)) {
2011-03-28 14:21:28 +00:00
?>
<li>
<a href="requests.php?action=view&amp;id=<?=$RequestID?>" title="View Torrent"><?=$RequestName?></a>
</li>
<?
}
?>
</ul>
</div>
</div>
<?
}
2013-05-05 08:00:31 +00:00
if ($Count == 0) {
2012-10-11 08:00:15 +00:00
Artists::delete_artist($ArtistID);
2011-03-28 14:21:28 +00:00
?>
2013-05-05 08:00:31 +00:00
<div class="thin box pad">
Artist "<?=$Name?>" deleted!
</div>
2011-03-28 14:21:28 +00:00
<?
}
2012-10-11 08:00:15 +00:00
View::show_footer();?>