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()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user