mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-44746 core_events: removed incorrect uses of snapshots
This commit is contained in:
parent
578645aadf
commit
601c998c64
4 changed files with 63 additions and 24 deletions
|
@ -60,11 +60,8 @@ class mnet_access_control_created extends base {
|
|||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
$mnetaccesscontrol = $this->get_record_snapshot('mnet_sso_access_control', $this->objectid);
|
||||
$mnethost = $this->get_record_snapshot('mnet_host', $mnetaccesscontrol->mnet_host_id);
|
||||
|
||||
return 'Access control created for the user with the username \'' . $mnetaccesscontrol->username . '\' belonging
|
||||
to the mnet host \'' . $mnethost->name . '\'';
|
||||
return 'Access control created for the user with the username \'' . $this->other['username'] . '\' belonging
|
||||
to the mnet host \'' . $this->other['hostname'] . '\'';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,11 +70,29 @@ class mnet_access_control_created extends base {
|
|||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
$mnetaccesscontrol = $this->get_record_snapshot('mnet_sso_access_control', $this->objectid);
|
||||
$mnethost = $this->get_record_snapshot('mnet_host', $mnetaccesscontrol->mnet_host_id);
|
||||
return array(SITEID, 'admin/mnet', 'add', 'admin/mnet/access_control.php', 'SSO ACL: ' . $this->other['accessctrl'] .
|
||||
' user \'' . $this->other['username'] . '\' from ' . $this->other['hostname']);
|
||||
}
|
||||
|
||||
return array(SITEID, 'admin/mnet', 'add', 'admin/mnet/access_control.php', 'SSO ACL: ' .
|
||||
$mnetaccesscontrol->accessctrl . ' user \'' . $mnetaccesscontrol->username . '\' from ' .
|
||||
$mnethost->name);
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
* @throws \coding_exception
|
||||
* @return void
|
||||
*/
|
||||
protected function validate_data() {
|
||||
parent::validate_data();
|
||||
|
||||
if (!isset($this->other['username'])) {
|
||||
throw new \coding_exception('The \'username\' must be set in other.');
|
||||
}
|
||||
|
||||
if (!isset($this->other['hostname'])) {
|
||||
throw new \coding_exception('The \'hostname\' must be set in other.');
|
||||
}
|
||||
|
||||
if (!isset($this->other['accessctrl'])) {
|
||||
throw new \coding_exception('The \'accessctrl\' must be set in other.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,11 +60,8 @@ class mnet_access_control_updated extends base {
|
|||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
$mnetaccesscontrol = $this->get_record_snapshot('mnet_sso_access_control', $this->objectid);
|
||||
$mnethost = $this->get_record_snapshot('mnet_host', $mnetaccesscontrol->mnet_host_id);
|
||||
|
||||
return 'Access control created for the user with the username \'' . $mnetaccesscontrol->username . '\' belonging
|
||||
to the mnet host \'' . $mnethost->name . '\'';
|
||||
return 'Access control created for the user with the username \'' . $this->other['username'] . '\' belonging
|
||||
to the mnet host \'' . $this->other['hostname'] . '\'';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,11 +70,29 @@ class mnet_access_control_updated extends base {
|
|||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
$mnetaccesscontrol = $this->get_record_snapshot('mnet_sso_access_control', $this->objectid);
|
||||
$mnethost = $this->get_record_snapshot('mnet_host', $mnetaccesscontrol->mnet_host_id);
|
||||
return array(SITEID, 'admin/mnet', 'update', 'admin/mnet/access_control.php', 'SSO ACL: ' . $this->other['accessctrl'] .
|
||||
' user \'' . $this->other['username'] . '\' from ' . $this->other['hostname']);
|
||||
}
|
||||
|
||||
return array(SITEID, 'admin/mnet', 'update', 'admin/mnet/access_control.php', 'SSO ACL: ' .
|
||||
$mnetaccesscontrol->accessctrl . ' user \'' . $mnetaccesscontrol->username . '\' from ' .
|
||||
$mnethost->name);
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
* @throws \coding_exception
|
||||
* @return void
|
||||
*/
|
||||
protected function validate_data() {
|
||||
parent::validate_data();
|
||||
|
||||
if (!isset($this->other['username'])) {
|
||||
throw new \coding_exception('The \'username\' must be set in other.');
|
||||
}
|
||||
|
||||
if (!isset($this->other['hostname'])) {
|
||||
throw new \coding_exception('The \'hostname\' must be set in other.');
|
||||
}
|
||||
|
||||
if (!isset($this->other['accessctrl'])) {
|
||||
throw new \coding_exception('The \'accessctrl\' must be set in other.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,8 +68,7 @@ class user_deleted extends base {
|
|||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
$user = $this->get_record_snapshot('user', $this->data['objectid']);
|
||||
return 'User profile deleted for userid ' . $user->id;
|
||||
return 'User profile deleted for userid ' . $this->objectid;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
14
mnet/lib.php
14
mnet/lib.php
|
@ -447,7 +447,12 @@ function mnet_update_sso_access_control($username, $mnet_host_id, $accessctrl) {
|
|||
// Trigger access control updated event.
|
||||
$params = array(
|
||||
'objectid' => $aclrecord->id,
|
||||
'context' => context_system::instance()
|
||||
'context' => context_system::instance(),
|
||||
'other' => array(
|
||||
'username' => $username,
|
||||
'hostname' => $mnethost->name,
|
||||
'accessctrl' => $accessctrl
|
||||
)
|
||||
);
|
||||
$event = \core\event\mnet_access_control_updated::create($params);
|
||||
$event->add_record_snapshot('mnet_host', $mnethost);
|
||||
|
@ -463,7 +468,12 @@ function mnet_update_sso_access_control($username, $mnet_host_id, $accessctrl) {
|
|||
// Trigger access control created event.
|
||||
$params = array(
|
||||
'objectid' => $aclrecord->id,
|
||||
'context' => context_system::instance()
|
||||
'context' => context_system::instance(),
|
||||
'other' => array(
|
||||
'username' => $username,
|
||||
'hostname' => $mnethost->name,
|
||||
'accessctrl' => $accessctrl
|
||||
)
|
||||
);
|
||||
$event = \core\event\mnet_access_control_created::create($params);
|
||||
$event->add_record_snapshot('mnet_host', $mnethost);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue