Skip to content
Snippets Groups Projects
Commit 67badd77 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by Jan-Hendrik Willms
Browse files

allow disabling of notifications for institute blubber threads, fixes #1021

Closes #1021

Merge request studip/studip!996
parent 7e236280
No related branches found
No related tags found
No related merge requests found
......@@ -520,6 +520,7 @@ class BlubberThread extends SimpleORMap implements PrivacyObject
$template = $GLOBALS['template_factory']->open('blubber/institute_context');
$template->thread = $this;
$template->institute = Institute::find($this['context_id']);
$template->unfollowed = !$this->isFollowedByUser();
return $template;
}
}
......@@ -848,7 +849,7 @@ class BlubberThread extends SimpleORMap implements PrivacyObject
$this->getLastVisit() ?: object_get_visit_threshold(),
$user_id
]),
'notifications' => $this->id === 'global' || ($this->context_type === 'course' && !$GLOBALS['perm']->have_perm('admin')),
'notifications' => $this->mayDisableNotifications(),
'followed' => $this->isFollowedByUser(),
];
$context_info = $this->getContextTemplate();
......@@ -1041,4 +1042,26 @@ class BlubberThread extends SimpleORMap implements PrivacyObject
}
return $institut_ids;
}
/**
* Returns whether the notifications for this thread may be disabled.
*
* @return bool
*/
public function mayDisableNotifications(): bool
{
// Notifications may always be disabled for global blubber stream
if ($this->id === 'global') {
return true;
}
// Notifications may not be disabled outside of course and institute
// streams
if (!in_array($this->context_type, ['course', 'institute'])) {
return false;
}
// Only users with permission below admin may disable the notifications.
return !$GLOBALS['perm']->have_perm('admin');
}
}
......@@ -10,7 +10,7 @@
:class="{unfollowed: !thread_data.followed}"
:title="$gettext('Benachrichtigungen für diese Konversation abstellen.')"
:data-thread_id="thread_data.thread_posting.thread_id">
<StudipIcon shape="remove/notification2" :size="20" class="follow text-bottom"></StudipIcon>
<StudipIcon shape="decline" :size="20" class="follow text-bottom"></StudipIcon>
<StudipIcon shape="notification2" :size="20" class="unfollow text-bottom"></StudipIcon>
{{ $gettext('Benachrichtigungen aktiviert') }}
</a>
......
......@@ -58,16 +58,4 @@
</div>
</div>
<?= $this->render_partial("blubber/_tagcloud") ?>
<? if (!$GLOBALS['perm']->have_perm("admin")) : ?>
<div class="indented new_section">
<a href="#"
onClick="STUDIP.Blubber.followunfollow('<?= htmlReady($thread->id) ?>'); return false;"
class="followunfollow<?= $unfollowed ? " unfollowed" : "" ?>"
title="<?= _("Benachrichtigungen für diese Konversation abstellen.") ?>"
data-thread_id="<?= htmlReady($thread->id) ?>">
<?= Icon::create("notification2+remove")->asImg(20, ['class' => "follow text-bottom"]) ?>
<?= Icon::create("notification2")->asImg(20, ['class' => "unfollow text-bottom"]) ?>
<?= _("Benachrichtigungen aktiviert") ?>
</a>
</div>
<? endif ?>
<?= $this->render_partial('blubber/disable-notifications', compact('thread', 'unfollowed')) ?>
<? if (!$GLOBALS['perm']->have_perm("admin")) : ?>
<div class="indented new_section">
<a href="#"
onClick="STUDIP.Blubber.followunfollow('<?= htmlReady($thread->id) ?>'); return false;"
class="followunfollow<?= $unfollowed ? " unfollowed" : "" ?>"
title="<?= _("Benachrichtigungen für diese Konversation abstellen.") ?>"
data-thread_id="<?= htmlReady($thread->id) ?>">
<?= Icon::create("notification2+remove")->asImg(20, ['class' => "follow text-bottom"]) ?>
<?= Icon::create("notification2")->asImg(20, ['class' => "unfollow text-bottom"]) ?>
<?= _("Benachrichtigungen aktiviert") ?>
</a>
</div>
<? endif ?>
......@@ -11,3 +11,4 @@
</div>
</div>
</div>
<?= $this->render_partial('blubber/disable-notifications', compact('thread', 'unfollowed')) ?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment