Skip to content

Commit

Permalink
Merged from MOODLE_15_STABLE: Fixing a problem reported about self en…
Browse files Browse the repository at this point in the history
…rolment 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
  • Loading branch information
mjollnir_ committed Feb 23, 2006
1 parent 4a2360a commit 0a0bcdd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/moodlelib.php
Expand Up @@ -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;
Expand All @@ -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;
}
}
}

Expand Down

0 comments on commit 0a0bcdd

Please sign in to comment.