|
91 | 91 | continue; // Invalid userid. |
92 | 92 | } |
93 | 93 |
|
| 94 | + $user = $DB->get_record('user', ['id' => $adduser]); |
94 | 95 | // Make sure that the user is enroled in the course. |
95 | | - if (!has_capability('moodle/course:view', $context, $adduser)) { |
96 | | - $user = $DB->get_record('user', ['id' => $adduser]); |
97 | | - // Make sure that the user is enroled in the course. |
98 | | - if (!is_enrolled($context, $user)) { |
99 | | - $defaultroleid = null; |
100 | | - // Get default role ID for manual enrollment. |
101 | | - $conditions = ['courseid' => $course->id, 'enrol' => 'manual']; |
102 | | - $defaultroleid = $DB->get_field('enrol', 'roleid', $conditions, IGNORE_MISSING); |
103 | | - if (!enrol_try_internal_enrol($course->id, $user->id, $defaultroleid)) { |
104 | | - $errors[] = get_string('error:enrolmentfailed', 'facetoface', fullname($user)); |
105 | | - $errors[] = get_string('error:addattendee', 'facetoface', fullname($user)); |
106 | | - continue; // Don't sign the user up. |
107 | | - } |
| 96 | + if (!is_enrolled($context, $user)) { |
| 97 | + $defaultroleid = null; |
| 98 | + // Get default role ID for manual enrollment. |
| 99 | + $conditions = ['courseid' => $course->id, 'enrol' => 'manual']; |
| 100 | + $defaultroleid = $DB->get_field('enrol', 'roleid', $conditions, IGNORE_MISSING); |
| 101 | + if (!enrol_try_internal_enrol($course->id, $user->id, $defaultroleid)) { |
| 102 | + $errors[] = get_string('error:enrolmentfailed', 'facetoface', fullname($user)); |
| 103 | + $errors[] = get_string('error:addattendee', 'facetoface', fullname($user)); |
| 104 | + continue; // Don't sign the user up. |
108 | 105 | } |
109 | 106 | } |
110 | 107 |
|
|
0 commit comments