MDL-15317, when forum is invisible, only users with 'mod/forum:managesubscriptions' capability can subscrib forum, merged from MOODLE_19_STABLE.

This commit is contained in:
dongsheng 2008-07-21 09:20:40 +00:00
parent 6559096f2c
commit 2c1363e622

View File

@ -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);