diff --git a/app/controllers/calendar/schedule.php b/app/controllers/calendar/schedule.php index 33c9f6dd00beb118d8e106e0b96f3c1396e0f11e..c1652f7e6b72b5b00910546e36e06bd90c2d66bc 100644 --- a/app/controllers/calendar/schedule.php +++ b/app/controllers/calendar/schedule.php @@ -58,7 +58,7 @@ class Calendar_ScheduleController extends AuthenticatedController _('Ausgeblendete Veranstaltungen verstecken'), $this->indexURL(['semester_id' => Request::get('semester_id')]), Icon::create('visibility-invisible') - ); + )->asButton(); } else { $actions->addLink( _('Ausgeblendete Veranstaltungen anzeigen'), @@ -67,7 +67,7 @@ class Calendar_ScheduleController extends AuthenticatedController 'semester_id' => Request::get('semester_id'), ]), Icon::create('visibility-visible') - ); + )->asButton(); } $actions->addLink( diff --git a/app/controllers/course/forum/index.php b/app/controllers/course/forum/index.php index bb1b49cb25e43bcea34a7c294798ee687b106f9f..d3be08ebe79caedd3509d27e3a20c0613cfc7941 100644 --- a/app/controllers/course/forum/index.php +++ b/app/controllers/course/forum/index.php @@ -561,6 +561,10 @@ class Course_Forum_IndexController extends ForumController */ function like_action($topic_id) { + if (!Request::isPost()) { + throw new MethodNotAllowedException(); + } + ForumPerm::check('like_entry', $this->getId(), $topic_id); ForumLike::like($topic_id); @@ -580,6 +584,10 @@ class Course_Forum_IndexController extends ForumController */ function dislike_action($topic_id) { + if (!Request::isPost()) { + throw new MethodNotAllowedException(); + } + ForumPerm::check('like_entry', $this->getId(), $topic_id); ForumLike::dislike($topic_id); diff --git a/app/views/course/forum/index/_like.php b/app/views/course/forum/index/_like.php index 6d11acbfadda61a13222ffb1e87c4e74a661b3a2..da1c5115d1e610ab3892cfae50a65ce4d2c12e4a 100644 --- a/app/views/course/forum/index/_like.php +++ b/app/views/course/forum/index/_like.php @@ -36,12 +36,13 @@ shuffle($likes); endif ?> <!-- like/dislike links --> -<? if (!in_array($GLOBALS['user']->id, $likes)) : ?> - <a href="<?= $controller->link_for('course/forum/index/like/'. $topic_id) ?>" onClick="jQuery('#like_<?= $topic_id ?>').load('<?= $controller->link_for('course/forum/index/like/'. $topic_id) ?>'); return false;"> - <?= _('Gefällt mir!'); ?> - </a> -<? else : ?> - <a href="<?= $controller->link_for('course/forum/index/dislike/'. $topic_id) ?>" onClick="jQuery('#like_<?= $topic_id ?>').load('<?= $controller->link_for('course/forum/index/dislike/'. $topic_id) ?>'); return false;"> - <?= _('Gefällt mir nicht mehr!'); ?> - </a> -<? endif ?> +<?php $has_liked = in_array($GLOBALS['user']->id, $likes); ?> +<button class="as-link" + onclick="$.post('<?= $controller->action_link($has_liked ? 'dislike' : 'like', $topic_id) ?>').done(response => $('#like_<?= htmlReady($topic_id) ?>').html(response));return false;" +> +<? if ($has_liked) : ?> + <?= _('Gefällt mir nicht mehr!'); ?> +<? else: ?> + <?= _('Gefällt mir!'); ?> +<? endif; ?> +</button>