mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 01:46:45 +02:00
Merge branch 'w11_MDL-31790_m23_resetunenrol' of git://github.com/skodak/moodle
This commit is contained in:
commit
b39877ef10
2 changed files with 11 additions and 8 deletions
|
@ -4546,7 +4546,7 @@ function remove_course_contents($courseid, $showfeedback = true, array $options
|
|||
// Remove all roles and enrolments by default
|
||||
if (empty($options['keep_roles_and_enrolments'])) {
|
||||
// this hack is used in restore when deleting contents of existing course
|
||||
role_unassign_all(array('contextid'=>$coursecontext->id), true);
|
||||
role_unassign_all(array('contextid'=>$coursecontext->id, 'component'=>''), true);
|
||||
enrol_course_delete($course);
|
||||
if ($showfeedback) {
|
||||
echo $OUTPUT->notification($strdeleted.get_string('type_enrol_plural', 'plugin'), 'notifysuccess');
|
||||
|
@ -4772,14 +4772,10 @@ function reset_course_userdata($data) {
|
|||
unset($instances[$key]);
|
||||
continue;
|
||||
}
|
||||
if (!$plugins[$instance->enrol]->allow_unenrol($instance)) {
|
||||
unset($instances[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$sqlempty = $DB->sql_empty();
|
||||
foreach($data->unenrol_users as $withroleid) {
|
||||
$sql = "SELECT DISTINCT ue.userid, ue.enrolid
|
||||
$sql = "SELECT ue.*
|
||||
FROM {user_enrolments} ue
|
||||
JOIN {enrol} e ON (e.id = ue.enrolid AND e.courseid = :courseid)
|
||||
JOIN {context} c ON (c.contextlevel = :courselevel AND c.instanceid = e.courseid)
|
||||
|
@ -4791,9 +4787,16 @@ function reset_course_userdata($data) {
|
|||
if (!isset($instances[$ue->enrolid])) {
|
||||
continue;
|
||||
}
|
||||
$plugins[$instances[$ue->enrolid]->enrol]->unenrol_user($instances[$ue->enrolid], $ue->userid);
|
||||
$instance = $instances[$ue->enrolid];
|
||||
$plugin = $plugins[$instance->enrol];
|
||||
if (!$plugin->allow_unenrol($instance) and !$plugin->allow_unenrol_user($instance, $ue)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$plugin->unenrol_user($instance, $ue->userid);
|
||||
$data->unenrolled[$ue->userid] = $ue->userid;
|
||||
}
|
||||
$rs->close();
|
||||
}
|
||||
}
|
||||
if (!empty($data->unenrolled)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue