mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-54030 enrol_lti: confirm tool exists before deleting users
This commit is contained in:
parent
8668796317
commit
a8abd53a32
@ -174,11 +174,12 @@ class enrol_lti_plugin extends enrol_plugin {
|
||||
public function unenrol_user(stdClass $instance, $userid) {
|
||||
global $DB;
|
||||
|
||||
// Get the tool associated with this instance.
|
||||
$tool = $DB->get_record('enrol_lti_tools', array('enrolid' => $instance->id), 'id', MUST_EXIST);
|
||||
|
||||
// Need to remove the user from the users table.
|
||||
$DB->delete_records('enrol_lti_users', array('userid' => $userid, 'toolid' => $tool->id));
|
||||
// Get the tool associated with this instance. Note - it may not exist if we have deleted
|
||||
// the tool. This is fine because we have already cleaned the 'enrol_lti_users' table.
|
||||
if ($tool = $DB->get_record('enrol_lti_tools', array('enrolid' => $instance->id), 'id')) {
|
||||
// Need to remove the user from the users table.
|
||||
$DB->delete_records('enrol_lti_users', array('userid' => $userid, 'toolid' => $tool->id));
|
||||
}
|
||||
|
||||
parent::unenrol_user($instance, $userid);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user