Skip to content
Snippets Groups Projects
Commit 28be9e0d authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

ensure forum likes and options are posted, fixes #4692

Closes #4692

Merge request studip/studip!3489
parent 74b6877e
No related branches found
No related tags found
No related merge requests found
......@@ -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(
......
......@@ -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);
......
......@@ -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>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment