2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * User profile field deleted event.
21 * @copyright 2017 Web Courseworks, Ltd. {@link http://www.webcourseworks.com}
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 defined('MOODLE_INTERNAL') ||
die();
29 * User deleted event class.
31 * @property-read array $other {
32 * Extra information about event.
34 * - string name: the name of the field.
38 * @copyright 2017 Web Courseworks, Ltd. {@link http://www.webcourseworks.com}
40 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
42 class user_info_category_deleted
extends base
{
45 * Initialise required event data properties.
47 protected function init() {
48 $this->data
['objecttable'] = 'user_info_category';
49 $this->data
['crud'] = 'd';
50 $this->data
['edulevel'] = self
::LEVEL_OTHER
;
54 * Creates an event from a profile info category.
57 * @param \stdClass $category A snapshot of the deleted category.
58 * @return \core\event\base
60 public static function create_from_category($category) {
61 $event = self
::create(array(
62 'objectid' => $category->id
,
63 'context' => \context_system
::instance(),
65 'name' => $category->name
,
69 $event->add_record_snapshot('user_info_category', $category);
75 * Returns localised event name.
79 public static function get_name() {
80 return get_string('eventuserinfocategorydeleted');
84 * Returns non-localised event description with id's for admin use only.
88 public function get_description() {
89 $name = s($this->other
['name']);
90 return "The user with id '$this->userid' deleted the user profile field category '$name' with id '$this->objectid'.";
96 * @throws \coding_exception
99 protected function validate_data() {
100 parent
::validate_data();
102 if (!isset($this->other
['name'])) {
103 throw new \
coding_exception('The \'name\' value must be set in other.');
108 * Get the backup/restore table mapping for this event.
112 public static function get_objectid_mapping() {
113 return base
::NOT_MAPPED
;