Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-15317, when forum is invisible, only users with 'mod/forum:manage…

…subscriptions' capability can subscrib forum.
  • Loading branch information...
commit e68f5a9bf6a016709f717a8789f074909144a33d 1 parent 497fe2b
dongsheng authored
Showing with 11 additions and 2 deletions.
  1. +11 −2 mod/forum/index.php
View
13 mod/forum/index.php
@@ -116,14 +116,23 @@
$learningforums[$forum->id] = $forum;
}
}
-
+
/// Do course wide subscribe/unsubscribe
if (!is_null($subscribe) and !isguestuser() and !isguest()) {
foreach ($modinfo->instances['forum'] as $forumid=>$cm) {
$forum = $forums[$forumid];
+ $cansub = false;
+ if (has_capability('mod/forum:viewdiscussion', $cm)) {
+ $cansub = true;
+ }
+ if ($cansub && $cm->visible == 0 &&
+ !has_capability('mod/forum:managesubscriptions', $cm))
+ {
+ $cansub = false;
+ }
if (!forum_is_forcesubscribed($forum)) {
$subscribed = forum_is_subscribed($USER->id, $forum);
- if ($subscribe && !$subscribed) {
+ if ($subscribe && !$subscribed && $cansub) {
forum_subscribe($USER->id, $forumid);
} else if (!$subscribe && $subscribed) {
forum_unsubscribe($USER->id, $forumid);
Please sign in to comment.
Something went wrong with that request. Please try again.