1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 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. 8 // 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. 13 // 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/>. 16 17 namespace tool_mfa\event; 18 19 use stdClass; 20 21 /** 22 * Event for when user factor is deleted. 23 * 24 * @property-read array $other { 25 * Extra information about event. 26 * } 27 * 28 * @package tool_mfa 29 * @author Peter Burnett <peterburnett@catalyst-au.net> 30 * @copyright Catalyst IT 31 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 32 */ 33 class user_deleted_factor extends \core\event\base { 34 35 /** 36 * Create instance of event. 37 * 38 * @param stdClass $user the User object of the User who had the factor deleted. 39 * @param stdClass $deleteuser the user who performed the factor delete. 40 * @param string $factorname deleted factor 41 * 42 * @return \core\event\base the user_factor_deleted event 43 * 44 * @throws \coding_exception 45 */ 46 public static function user_deleted_factor_event(stdClass $user, $deleteuser, $factorname): \core\event\base { 47 48 $data = [ 49 'relateduserid' => $user->id, 50 'context' => \context_user::instance($user->id), 51 'other' => [ 52 'userid' => $user->id, 53 'factorname' => $factorname, 54 'delete' => $deleteuser->id, 55 ], 56 ]; 57 58 return self::create($data); 59 } 60 61 /** 62 * Init method. 63 * 64 * @return void 65 */ 66 protected function init(): void { 67 $this->data['crud'] = 'd'; 68 $this->data['edulevel'] = self::LEVEL_OTHER; 69 } 70 71 /** 72 * Returns description of what happened. 73 * 74 * @return string 75 */ 76 public function get_description(): string { 77 // The log message changed from logging the deleter user object to the ID. This must be kept for backwards compat 78 // With old log events. 79 if (is_object($this->other['delete'])) { 80 return "The user with id '{$this->other['delete']->id}' successfully deleted 81 {$this->other['factorname']} factor for user with id '{$this->other['userid']}'"; 82 } else { 83 return "The user with id '{$this->other['delete']}' successfully deleted 84 {$this->other['factorname']} factor for user with id '{$this->other['userid']}'"; 85 } 86 } 87 88 /** 89 * Return localised event name. 90 * 91 * @return string 92 * @throws \coding_exception 93 */ 94 public static function get_name(): string { 95 return get_string('event:userdeletedfactor', 'tool_mfa'); 96 } 97 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body