mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-01-10 23:17:53 +00:00
allow users delete own content
This commit is contained in:
parent
d34ff8ecc6
commit
cbda078c38
@ -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()
|
||||
|
@ -66,8 +66,16 @@
|
||||
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ edition.user.identicon }}" alt="{{'identicon'|trans }}" />
|
||||
</a>
|
||||
<div class="float-right">
|
||||
{% if session.moderator or session.owner %}
|
||||
<a class="margin-r-8-px text-color-red" href="{{ path('torrent_delete_locales', { torrentId : torrentId, torrentLocalesId : edition.id }) }}" title="{{ 'Delete' | trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle" viewBox="0 0 16 16">
|
||||
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
|
||||
<path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"/>
|
||||
</svg>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if edition.approved %}
|
||||
{% if moderator %}
|
||||
{% if session.moderator %}
|
||||
<a href="{{ path('torrent_approve_locales', { torrentId : torrentId, torrentLocalesId : edition.id }) }}" title="{{ 'Approved' | trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
|
||||
@ -81,7 +89,7 @@
|
||||
</span>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if moderator %}
|
||||
{% if session.moderator %}
|
||||
<a href="{{ path('torrent_approve_locales', { torrentId : torrentId, torrentLocalesId : edition.id }) }}" title="{{ 'Approved' | trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-hourglass" viewBox="0 0 16 16">
|
||||
<path d="M2 1.5a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-1v1a4.5 4.5 0 0 1-2.557 4.06c-.29.139-.443.377-.443.59v.7c0 .213.154.451.443.59A4.5 4.5 0 0 1 12.5 13v1h1a.5.5 0 0 1 0 1h-11a.5.5 0 1 1 0-1h1v-1a4.5 4.5 0 0 1 2.557-4.06c.29-.139.443-.377.443-.59v-.7c0-.213-.154-.451-.443-.59A4.5 4.5 0 0 1 3.5 3V2h-1a.5.5 0 0 1-.5-.5zm2.5.5v1a3.5 3.5 0 0 0 1.989 3.158c.533.256 1.011.791 1.011 1.491v.702c0 .7-.478 1.235-1.011 1.491A3.5 3.5 0 0 0 4.5 13v1h7v-1a3.5 3.5 0 0 0-1.989-3.158C8.978 9.586 8.5 9.052 8.5 8.351v-.702c0-.7.478-1.235 1.011-1.491A3.5 3.5 0 0 0 11.5 3V2h-7z"/>
|
||||
@ -95,14 +103,6 @@
|
||||
</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if moderator %}
|
||||
<a class="margin-l-8-px text-color-red" href="{{ path('torrent_delete_locales', { torrentId : torrentId, torrentLocalesId : edition.id }) }}" title="{{ 'Delete' | trans }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle" viewBox="0 0 16 16">
|
||||
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
|
||||
<path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"/>
|
||||
</svg>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
Loading…
Reference in New Issue
Block a user