Skip to content

Commit

Permalink
MDL-31426 forum: don't show/allow any subscription to not enrolled users
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 authored and wdjunaidi committed Feb 10, 2012
1 parent af5b355 commit 7dff05d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions mod/forum/index.php
Expand Up @@ -149,8 +149,13 @@
}
}

/// 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);
Expand Down Expand Up @@ -417,7 +422,8 @@
$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())),
Expand Down

0 comments on commit 7dff05d

Please sign in to comment.