mirror of
https://github.com/OPSnet/Gazelle.git
synced 2026-01-16 18:04:34 -05:00
40 lines
994 B
PHP
40 lines
994 B
PHP
<?php
|
|
/** @phpstan-var \Gazelle\User $Viewer */
|
|
/** @phpstan-var \Twig\Environment $Twig */
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Gazelle;
|
|
|
|
if (!($Viewer->permitted('site_delete_artist') && $Viewer->permitted('torrents_delete'))) {
|
|
Error403::error();
|
|
}
|
|
authorize();
|
|
|
|
$artist = new Manager\Artist()->findById((int)($_GET['artistid'] ?? 0));
|
|
if (is_null($artist)) {
|
|
Error404::error();
|
|
}
|
|
|
|
$tgMan = new Manager\TGroup();
|
|
$tgroupList = array_map(fn ($id) => $tgMan->findById($id), $artist->tgroupIdUsage());
|
|
|
|
$reqMan = new Manager\Request();
|
|
$requestList = array_map(fn ($id) => $reqMan->findById($id), $artist->requestIdUsage());
|
|
|
|
if (count($tgroupList) + count($requestList) > 0) {
|
|
echo $Twig->render('artist/remove-fail.twig', [
|
|
'artist' => $artist,
|
|
'request_list' => $requestList,
|
|
'tgroup_list' => $tgroupList,
|
|
]);
|
|
exit;
|
|
}
|
|
|
|
$name = $artist->name();
|
|
$artist->remove();
|
|
|
|
echo $Twig->render('artist/remove-success.twig', [
|
|
'name' => $name,
|
|
]);
|