From e68f5a9bf6a016709f717a8789f074909144a33d Mon Sep 17 00:00:00 2001 From: dongsheng Date: Mon, 21 Jul 2008 09:18:12 +0000 Subject: [PATCH] MDL-15317, when forum is invisible, only users with 'mod/forum:managesubscriptions' capability can subscrib forum. --- mod/forum/index.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mod/forum/index.php b/mod/forum/index.php index 2dc2a8c93..400ed8fea 100644 --- a/mod/forum/index.php +++ b/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); -- 2.11.4.GIT