Commit f1f4f4fd authored by Mark Nelson's avatar Mark Nelson
Browse files

MDL-40909 core_enrol: removed 'enrol' add_to_log calls

Before each of these calls a call to enrol_user() is made, which
triggers the event 'user_enrolment_created'. Nothing more is needed.
parent 63245172
......@@ -123,7 +123,6 @@ if ($canenrol && optional_param('add', false, PARAM_BOOL) && confirm_sesskey())
$timeend = $timestart + $extendperiod;
}
$enrol_manual->enrol_user($instance, $adduser->id, $roleid, $timestart, $timeend);
add_to_log($course->id, 'course', 'enrol', '../enrol/users.php?id='.$course->id, $course->id); //there should be userid somewhere!
}
$potentialuserselector->invalidate_selected_users();
......
......@@ -195,7 +195,6 @@ class enrol_self_plugin extends enrol_plugin {
}
$this->enrol_user($instance, $USER->id, $instance->roleid, $timestart, $timeend);
add_to_log($instance->courseid, 'course', 'enrol', '../enrol/users.php?id='.$instance->courseid, $instance->courseid); //TODO: There should be userid somewhere!
if ($instance->password and $instance->customint1 and $data->enrolpassword !== $instance->password) {
// It must be a group enrolment, let's assign group too.
......
......@@ -310,11 +310,14 @@ class core_enrollib_testcase extends advanced_testcase {
$dbuserenrolled = $DB->get_record('user_enrolments', array('userid' => $admin->id));
$this->assertInstanceOf('\core\event\user_enrolment_created', $event);
$this->assertEquals($dbuserenrolled->id, $event->objectid);
$this->assertEquals(context_course::instance($course1->id), $event->get_context());
$this->assertEquals('user_enrolled', $event->get_legacy_eventname());
$expectedlegacyeventdata = $dbuserenrolled;
$expectedlegacyeventdata->enrol = $manual->get_name();
$expectedlegacyeventdata->courseid = $course1->id;
$this->assertEventLegacyData($expectedlegacyeventdata, $event);
$expected = array($course1->id, 'course', 'enrol', '../enrol/users.php?id=' . $course1->id, $course1->id);
$this->assertEventLegacyLogData($expected, $event);
}
/**
......
......@@ -97,6 +97,15 @@ class user_enrolment_created extends base {
return $legacyeventdata;
}
/**
* Return legacy data for add_to_log().
*
* @return array
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'course', 'enrol', '../enrol/users.php?id=' . $this->courseid, $this->courseid);
}
/**
* Custom validation.
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment