Skip to content

Commit

Permalink
Allow Moderators to edit charts
Browse files Browse the repository at this point in the history
  • Loading branch information
LauraWebdev committed Oct 26, 2023
1 parent 81a9295 commit 39c6bb7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/Controller/SongController.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,12 @@ public function songUpdate(Request $request, int $songId)
$em = $this->getDoctrine()->getManager();
$data = [];

$song = $em->getRepository(Song::class)->findOneBy(array('id' => $songId, 'uploader' => $user->getId()));
$song = null;
if($user->hasRole('ROLE_ADMIN') || $user->hasRole('ROLE_MODERATOR')) {
$song = $em->getRepository(Song::class)->findOneBy(array('id' => $songId));
} else {
$song = $em->getRepository(Song::class)->findOneBy(array('id' => $songId, 'uploader' => $user->getId()));
}

$dlcs = $em->getRepository(DLC::class)->findAll();
$dlcOptions = [
Expand Down
7 changes: 5 additions & 2 deletions templates/song/detail.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,21 @@
{% if is_granted('ROLE_USER') %}
</div>
<div class="action-row">
{% if uploader.id == app.user.id %}
{% if uploader.id == app.user.id or is_granted('ROLE_MODERATOR') %}
<a href="{{ path('song.update', {songId: song.id}) }}" class="action">
<div class="icon">
<i class="mdi mdi-pencil"></i>
</div>
</a>
{% endif %}
{% if uploader.id == app.user.id %}
<a href="{{ path('song.delete', {songId: song.id}) }}" class="action">
<div class="icon">
<i class="mdi mdi-delete"></i>
</div>
</a>
{% elseif is_granted('ROLE_MODERATOR') %}
{% endif %}
{% if is_granted('ROLE_MODERATOR') %}
<a href="{{ path('moderation.song.remove', {songId: song.id}) }}" onclick="return confirm('Are you sure? This action cannot be undone!')" class="action">
<div class="icon">
<i class="mdi mdi-delete"></i>
Expand Down

0 comments on commit 39c6bb7

Please sign in to comment.