Merged enrolment-related fixes from stable

This commit is contained in:
moodler
2006-10-20 17:53:50 +00:00
parent a954633875
commit bd4128e91f
4 changed files with 33 additions and 19 deletions
+8 -1
View File
@@ -376,10 +376,17 @@
if (! $course = get_record("course", "id", $discussion->course)) {
error("The course number was incorrect ($discussion->course)");
}
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
if (! forum_user_can_post($forum)) {
error("Sorry, but you can not post in this forum.");
if (has_capability('moodle/legacy:guest', $coursecontext, NULL, false)) { // User is a guest here!
$SESSION->wantsurl = $FULLME;
$SESSION->enrolcancel = $_SERVER['HTTP_REFERER'];
redirect($CFG->wwwroot.'/course/enrol.php?id='.$course->id, get_string('youneedtoenrol'));
} else {
print_error('nopostforum', 'forum');
}
}
if ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {