mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-66034 core: delete role_capabilities_updated event triggers
This commit is contained in:
parent
e9b88bcb73
commit
3a18032dbf
@ -200,19 +200,6 @@ if (optional_param('cancel', false, PARAM_BOOL)) {
|
||||
if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey() && $definitiontable->is_submission_valid()) {
|
||||
$definitiontable->save_changes();
|
||||
$tableroleid = $definitiontable->get_role_id();
|
||||
// Trigger event.
|
||||
$event = \core\event\role_capabilities_updated::create(
|
||||
array(
|
||||
'context' => $systemcontext,
|
||||
'objectid' => $tableroleid
|
||||
)
|
||||
);
|
||||
$event->set_legacy_logdata(array(SITEID, 'role', $action, 'admin/roles/define.php?action=view&roleid=' . $tableroleid,
|
||||
$definitiontable->get_role_name(), '', $USER->id));
|
||||
if (!empty($role)) {
|
||||
$event->add_record_snapshot('role', $role);
|
||||
}
|
||||
$event->trigger();
|
||||
|
||||
if ($action === 'add') {
|
||||
redirect(new moodle_url('/admin/roles/define.php', array('action'=>'view', 'roleid'=>$definitiontable->get_role_id())));
|
||||
|
@ -134,22 +134,6 @@ $overridestable->read_submitted_permissions();
|
||||
if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) {
|
||||
$overridestable->save_changes();
|
||||
$rolename = $overridableroles[$roleid];
|
||||
// Trigger event.
|
||||
$event = \core\event\role_capabilities_updated::create(
|
||||
array(
|
||||
'context' => $context,
|
||||
'objectid' => $roleid,
|
||||
)
|
||||
);
|
||||
|
||||
$event->set_legacy_logdata(
|
||||
array(
|
||||
$course->id, 'role', 'override', 'admin/roles/override.php?contextid=' . $context->id . '&roleid=' . $roleid,
|
||||
$rolename, '', $USER->id
|
||||
)
|
||||
);
|
||||
$event->add_record_snapshot('role', $role);
|
||||
$event->trigger();
|
||||
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
@ -409,13 +409,13 @@ class core_accesslib_testcase extends advanced_testcase {
|
||||
$this->assertEmpty($permission);
|
||||
|
||||
// Test event trigger.
|
||||
$rolecapabilityevent = \core\event\role_capabilities_updated::create(array('context' => $syscontext,
|
||||
'objectid' => $student->id,
|
||||
'other' => array('name' => $student->shortname)
|
||||
));
|
||||
$expectedlegacylog = array(SITEID, 'role', 'view', 'admin/roles/define.php?action=view&roleid=' . $student->id,
|
||||
$student->shortname, '', $user->id);
|
||||
$rolecapabilityevent->set_legacy_logdata($expectedlegacylog);
|
||||
$rolecapabilityevent = \core\event\capability_assigned::create(['context' => $syscontext,
|
||||
'objectid' => $student->id,
|
||||
'other' => [
|
||||
'capability' => 'moodle/backup:backupcourse',
|
||||
'oldpermission' => $permission->permission ?? CAP_INHERIT,
|
||||
'permission' => CAP_ALLOW
|
||||
]]);
|
||||
$rolecapabilityevent->add_record_snapshot('role', $student);
|
||||
|
||||
$sink = $this->redirectEvents();
|
||||
@ -424,10 +424,9 @@ class core_accesslib_testcase extends advanced_testcase {
|
||||
$sink->close();
|
||||
$event = array_pop($events);
|
||||
|
||||
$this->assertInstanceOf('\core\event\role_capabilities_updated', $event);
|
||||
$this->assertInstanceOf('\core\event\capability_assigned', $event);
|
||||
$expectedurl = new moodle_url('/admin/roles/define.php', array('action' => 'view', 'roleid' => $student->id));
|
||||
$this->assertEquals($expectedurl, $event->get_url());
|
||||
$this->assertEventLegacyLogData($expectedlegacylog, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user