MDL-39961 Events: Replace Legacy events - User
This change includes: * Added user_updated event, replacing old event * Added user_created event, replacing old event * Added user_deleted event, replacing old event * Added user_loggedout event, replacing old event * Added user_enrolment_created event, replacing old event * Added user_enrolment_deleted event, replacing old event * Added user_enrolment_updated event, replacing old event
This commit is contained in:
committed by
Damyon Wiese
parent
80032fea02
commit
bb78e249cd
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User created event.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Rajesh Taneja <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace core\event;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Event when new user profile is created.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Rajesh Taneja <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_created extends base {
|
||||
|
||||
/**
|
||||
* Initialise required event data properties.
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['objecttable'] = 'user';
|
||||
$this->data['crud'] = 'c';
|
||||
$this->data['level'] = self::LEVEL_OTHER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns localised event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('eventusercreated');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns non-localised event description with id's for admin use only.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return 'Profile created for user '.$this->objectid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns relevant URL.
|
||||
*
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/user/view.php', array('id' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return name of the legacy event, which is replaced by this event.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'user_created';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return user_created legacy event data.
|
||||
*
|
||||
* @return \stdClass user data.
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->get_record_snapshot('user', $this->objectid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of parameters to be passed to legacy add_to_log() function.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array(SITEID, 'user', 'add', '/view.php?id='.$this->objectid, fullname($this->get_legacy_eventdata()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User deleted event.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Rajesh Taneja <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace core\event;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Event when user profile is deleted.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Rajesh Taneja <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_deleted extends base {
|
||||
|
||||
/**
|
||||
* Initialise required event data properties.
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['objecttable'] = 'user';
|
||||
$this->data['crud'] = 'd';
|
||||
$this->data['level'] = self::LEVEL_OTHER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns localised event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('eventuserdeleted');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns non-localised event description with id's for admin use only.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
$user = (object)$this->other['user'];
|
||||
return 'User profile deleted for user '.$user->firstname.' '.$user->lastname.' id ('.$user->id.')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return name of the legacy event, which is replaced by this event.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'user_deleted';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return user_deleted legacy event data.
|
||||
*
|
||||
* @return \stdClass user data.
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return (object)$this->other['user'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of parameters to be passed to legacy add_to_log() function.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
$user = (object)$this->other['user'];
|
||||
return array(SITEID, 'user', 'delete', "view.php?id=$user->id", $user->firstname.' '.$user->lastname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
* @throws \coding_exception
|
||||
* @return void
|
||||
*/
|
||||
protected function validate_data() {
|
||||
parent::validate_data();
|
||||
if (!isset($this->other['user'])) {
|
||||
throw new \coding_exception('user must be set in $other.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User enrolment created event.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Rajesh Taneja <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace core\event;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Event when user is enrolled in a course.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Rajesh Taneja <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_enrolment_created extends base {
|
||||
|
||||
/**
|
||||
* Initialise required event data properties.
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['objecttable'] = 'user_enrolments';
|
||||
$this->data['crud'] = 'c';
|
||||
$this->data['level'] = self::LEVEL_TEACHING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns localised event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('eventuserenrolmentcreated', 'core_enrol');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns non-localised event description with id's for admin use only.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return 'User '.$this->relateduserid. ' is enrolled in course '.$this->courseid.' by user '.$this->userid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns relevant URL.
|
||||
*
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/enrol/users.php', array('id' => $this->courseid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return name of the legacy event, which is replaced by this event.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'user_enrolled';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return user_enrolled legacy event data.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
$legacyeventdata = $this->get_record_snapshot('user_enrolments', $this->objectid);
|
||||
$legacyeventdata->enrol = $this->other['enrol'];
|
||||
$legacyeventdata->courseid = $this->courseid;
|
||||
return $legacyeventdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
* @throws \coding_exception
|
||||
* @return void
|
||||
*/
|
||||
protected function validate_data() {
|
||||
parent::validate_data();
|
||||
if (!isset($this->other['enrol'])) {
|
||||
throw new \coding_exception('Enrolment plugin name must be set in $other.');
|
||||
}
|
||||
if (!isset($this->relateduserid)) {
|
||||
throw new \coding_exception('Related user id must be set.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User enrolment deleted event.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Rajesh Taneja <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace core\event;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Event when user is unenrolled from a course.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Rajesh Taneja <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_enrolment_deleted extends base {
|
||||
|
||||
/**
|
||||
* Initialise required event data properties.
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['objecttable'] = 'user_enrolments';
|
||||
$this->data['crud'] = 'd';
|
||||
$this->data['level'] = self::LEVEL_TEACHING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns localised event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('eventuserenrolmentdeleted', 'core_enrol');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns non-localised event description with id's for admin use only.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return 'User '.$this->relateduserid. ' is enrolled in course '.$this->courseid.' by user '.$this->userid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns relevant URL.
|
||||
*
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/enrol/users.php', array('id' => $this->courseid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return name of the legacy event, which is replaced by this event.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'user_unenrolled';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return user_unenrolled legacy event data.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return (object)$this->other['userenrolment'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
* @throws \coding_exception
|
||||
* @return void
|
||||
*/
|
||||
protected function validate_data() {
|
||||
parent::validate_data();
|
||||
if (!isset($this->other['userenrolment'])) {
|
||||
throw new \coding_exception('User enrolment must be set in $other.');
|
||||
}
|
||||
if (!isset($this->other['enrol'])) {
|
||||
throw new \coding_exception('Enrolment plugin name must be set in $other.');
|
||||
}
|
||||
if (!isset($this->relateduserid)) {
|
||||
throw new \coding_exception('Related user id must be set.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User enrolment updated event.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Rajesh Taneja <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace core\event;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Event when user enrolment is updated.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Rajesh Taneja <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_enrolment_updated extends base {
|
||||
|
||||
/**
|
||||
* Initialise required event data properties.
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['objecttable'] = 'user_enrolments';
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['level'] = self::LEVEL_TEACHING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns localised event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('eventuserenrolmentupdated', 'core_enrol');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns non-localised event description with id's for admin use only.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return 'User '.$this->relateduserid. ' has updated enrolment for user '.$this->userid.' in course '.$this->courseid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns relevant URL.
|
||||
*
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/enrol/users.php', array('id' => $this->courseid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return name of the legacy event, which is replaced by this event.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'user_enrol_modified';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return user_enrol_modified legacy event data.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
$legacyeventdata = $this->get_record_snapshot('user_enrolments', $this->objectid);
|
||||
$legacyeventdata->enrol = $this->other['enrol'];
|
||||
$legacyeventdata->courseid = $this->courseid;
|
||||
return $legacyeventdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
* @throws \coding_exception
|
||||
* @return void
|
||||
*/
|
||||
protected function validate_data() {
|
||||
parent::validate_data();
|
||||
if (!isset($this->other['enrol'])) {
|
||||
throw new \coding_exception('Enrolment plugin name must be set in $other.');
|
||||
}
|
||||
if (!isset($this->relateduserid)) {
|
||||
throw new \coding_exception('Related user id must be set.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User logout event.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Rajesh Taneja <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace core\event;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Event when user logout.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Rajesh Taneja <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_loggedout extends base {
|
||||
|
||||
/**
|
||||
* Initialise required event data properties.
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['objecttable'] = 'user';
|
||||
$this->data['crud'] = 'r';
|
||||
$this->data['level'] = self::LEVEL_OTHER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns localised event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('eventuserloggedout');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns non-localised event description with id's for admin use only.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return 'User '.$this->objectid.' logged out.';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns relevant URL.
|
||||
*
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/user/view.php', array('id' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return name of the legacy event, which is replaced by this event.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'user_logout';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return user_logout legacy event data.
|
||||
*
|
||||
* @return \stdClass user data.
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->get_record_snapshot('user', $this->objectid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of parameters to be passed to legacy add_to_log() function.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array(SITEID, 'user', 'logout', 'view.php?id='.$this->objectid.'&course='.SITEID, $this->objectid, 0,
|
||||
$this->objectid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User updated event.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Rajesh Taneja <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace core\event;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Event when user profile is updated.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2013 Rajesh Taneja <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_updated extends base {
|
||||
|
||||
/**
|
||||
* Initialise required event data properties.
|
||||
*/
|
||||
protected function init() {
|
||||
$this->data['objecttable'] = 'user';
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['level'] = self::LEVEL_OTHER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns localised event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_name() {
|
||||
return get_string('eventuserupdated');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns non-localised event description with id's for admin use only.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
return 'User profile updated for userid '.$this->objectid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns relevant URL.
|
||||
*
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/user/view.php', array('id' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return name of the legacy event, which is replaced by this event.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'user_updated';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return user_updated legacy event data.
|
||||
*
|
||||
* @return \stdClass user data.
|
||||
*/
|
||||
protected function get_legacy_eventdata () {
|
||||
return $this->get_record_snapshot('user', $this->objectid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of parameters to be passed to legacy add_to_log() function.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array(SITEID, 'user', 'update', 'view.php?id='.$this->objectid, '');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user