From 0a0bcdd2599aceed4bfcbc84fd8dfbe31f564a88 Mon Sep 17 00:00:00 2001 From: mjollnir_ Date: Thu, 23 Feb 2006 22:15:30 +0000 Subject: [PATCH] Merged from MOODLE_15_STABLE: Fixing a problem reported about self enrolment in child courses and not being able to access the parent without logging in and out again at http://moodle.org/mod/forum/post.php?reply=185699 --- lib/moodlelib.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index ce6d3985546..4a4e346784a 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2793,7 +2793,7 @@ function set_login_session_preferences() { */ function enrol_student($userid, $courseid, $timestart=0, $timeend=0, $enrol='manual') { - global $CFG; + global $CFG, $USER; if (!$course = get_record('course', 'id', $courseid)) { // Check course return false; @@ -2805,6 +2805,12 @@ function enrol_student($userid, $courseid, $timestart=0, $timeend=0, $enrol='man if ($parents = get_records('course_meta', 'child_course', $courseid)) { foreach ($parents as $parent) { enrol_student($userid, $parent->parent_course, $timestart, $timeend,'metacourse'); + // if we're enrolling ourselves in the child course, add the parent courses to USER too + // otherwise they'll have to logout and in again to get it + // http://moodle.org/mod/forum/post.php?reply=185699 + if (!empty($USER) && $userid == $USER->id) { + $USER->student[$parent->parent_course] = true; + } } }