From e163fbc943c9c96da89939ff97813d5f7e94cbb1 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Mon, 30 Jan 2012 23:20:03 +0100 Subject: [PATCH] MDL-31426 forum: don't show/allow any subscription to not enrolled users --- mod/forum/index.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mod/forum/index.php b/mod/forum/index.php index 0ec460b25c0..c15b40b9000 100644 --- a/mod/forum/index.php +++ b/mod/forum/index.php @@ -149,8 +149,13 @@ foreach ($modinfo->instances['forum'] as $forumid=>$cm) { } } -/// Do course wide subscribe/unsubscribe -if (!is_null($subscribe) and !isguestuser()) { +// Do course wide subscribe/unsubscribe if requested +if (!is_null($subscribe)) { + if (isguestuser() or !$can_subscribe) { + // there should not be any links leading to this place, just redirect + redirect(new moodle_url('/mod/forum/index.php', array('id' => $id)), get_string('subscribeenrolledonly', 'forum')); + } + // Can proceed now, the user is not guest and is enrolled foreach ($modinfo->instances['forum'] as $forumid=>$cm) { $forum = $forums[$forumid]; $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); @@ -417,7 +422,8 @@ $PAGE->set_heading($course->fullname); $PAGE->set_button($searchform); echo $OUTPUT->header(); -if (!isguestuser() && isloggedin()) { +// Show the subscribe all options only to non-guest, enrolled users +if (!isguestuser() && isloggedin() && $can_subscribe) { echo $OUTPUT->box_start('subscription'); echo html_writer::tag('div', html_writer::link(new moodle_url('/mod/forum/index.php', array('id'=>$course->id, 'subscribe'=>1, 'sesskey'=>sesskey())),