diff --git a/src/Controller/TorrentController.php b/src/Controller/TorrentController.php index a93b5ba..823f929 100644 --- a/src/Controller/TorrentController.php +++ b/src/Controller/TorrentController.php @@ -256,10 +256,14 @@ class TorrentController extends AbstractController 'default/torrent/edit/locales.html.twig', [ 'torrentId' => $torrent->getId(), - 'moderator' => $user->isModerator(), 'locales' => explode('|', $this->getParameter('app.locales')), 'editions' => $editions, 'form' => $form, + 'session' => + [ + 'moderator' => $user->isModerator(), + 'owner' => $user->getId() === $torrentLocales->getUserId(), + ] ] ); } @@ -289,15 +293,6 @@ class TorrentController extends AbstractController $request->getClientIp() ); - // Check permissions - if (!$user->isModerator()) - { - // @TODO - throw new \Exception( - $translator->trans('Access denied') - ); - } - // Init torrent if (!$torrent = $torrentService->getTorrent($request->get('torrentId'))) { @@ -310,6 +305,15 @@ class TorrentController extends AbstractController throw $this->createNotFoundException(); } + // Check permissions + if (!$user->isModerator()) + { + // @TODO + throw new \Exception( + $translator->trans('Access denied') + ); + } + // Update approved $torrentService->toggleTorrentLocalesApproved( $torrentLocales->getId() @@ -351,15 +355,6 @@ class TorrentController extends AbstractController $request->getClientIp() ); - // Check permissions - if (!$user->isModerator()) - { - // @TODO - throw new \Exception( - $translator->trans('Access denied') - ); - } - // Init torrent if (!$torrent = $torrentService->getTorrent($request->get('torrentId'))) { @@ -372,6 +367,15 @@ class TorrentController extends AbstractController throw $this->createNotFoundException(); } + // Check permissions + if (!($user->isModerator() || $user->getId() === $torrentLocales->getUserId())) + { + // @TODO + throw new \Exception( + $translator->trans('Access denied') + ); + } + // Update approved $torrentService->deleteTorrentLocales( $torrentLocales->getId() diff --git a/templates/default/torrent/edit/locales.html.twig b/templates/default/torrent/edit/locales.html.twig index 4b41b0c..e71ebab 100644 --- a/templates/default/torrent/edit/locales.html.twig +++ b/templates/default/torrent/edit/locales.html.twig @@ -66,8 +66,16 @@ {{'identicon'|trans }}
+ {% if session.moderator or session.owner %} + + + + + + + {% endif %} {% if edition.approved %} - {% if moderator %} + {% if session.moderator %} @@ -81,7 +89,7 @@ {% endif %} {% else %} - {% if moderator %} + {% if session.moderator %} @@ -95,14 +103,6 @@ {% endif %} {% endif %} - {% if moderator %} - - - - - - - {% endif %}
{% endfor %}