See Release Notes
Long Term Support Release
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 /** 18 * Badge deleted event. 19 * 20 * @package core 21 * @copyright 2016 Stephen Bourget 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace core\event; 26 defined('MOODLE_INTERNAL') || die(); 27 require_once($CFG->libdir . '/badgeslib.php'); 28 29 30 /** 31 * Event triggered after a badge is deleted. 32 * 33 * @package core 34 * @since Moodle 3.2 35 * @copyright 2016 Stephen Bourget 36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 37 */ 38 class badge_deleted extends base { 39 40 /** 41 * Set basic properties for the event. 42 */ 43 protected function init() { 44 $this->data['objecttable'] = 'badge'; 45 $this->data['crud'] = 'd'; 46 $this->data['edulevel'] = self::LEVEL_TEACHING; 47 } 48 49 /** 50 * Returns localised general event name. 51 * 52 * @return string 53 */ 54 public static function get_name() { 55 return get_string('eventbadgedeleted', 'badges'); 56 } 57 58 /** 59 * Returns non-localised event description with id's for admin use only. 60 * 61 * @return string 62 */ 63 public function get_description() { 64 return "The user with id '$this->userid' has deleted the badge with id '$this->objectid'."; 65 } 66 67 /** 68 * Returns relevant URL. 69 * @return \moodle_url 70 */ 71 public function get_url() { 72 if ($this->other['badgetype'] == BADGE_TYPE_COURSE) { 73 // Course badge. 74 $return = new \moodle_url('/badges/index.php', 75 array('type' => BADGE_TYPE_COURSE, 'id' => $this->other['courseid'])); 76 } else { 77 // Site badge. 78 $return = new \moodle_url('/badges/index.php', array('type' => BADGE_TYPE_SITE)); 79 } 80 return $return; 81 } 82 83 /** 84 * Custom validations. 85 * 86 * @throws \coding_exception 87 * @return void 88 */ 89 protected function validate_data() { 90 parent::validate_data(); 91 92 if (!isset($this->objectid)) { 93 throw new \coding_exception('The \'objectid\' must be set.'); 94 } 95 if (!isset($this->other['badgetype'])) { 96 throw new \coding_exception('The \'badgetype\' value must be set in other.'); 97 } else { 98 if (($this->other['badgetype'] != BADGE_TYPE_COURSE) && ($this->other['badgetype'] != BADGE_TYPE_SITE)) { 99 throw new \coding_exception('Invalid \'badgetype\' value.'); 100 } 101 } 102 if ($this->other['badgetype'] == BADGE_TYPE_COURSE) { 103 if (!isset($this->other['courseid'])) { 104 throw new \coding_exception('The \'courseid\' value must be set in other.'); 105 } 106 } 107 } 108 109 /** 110 * Used for maping events on restore 111 * @return array 112 */ 113 public static function get_objectid_mapping() { 114 return array('db' => 'badge', 'restore' => 'badge'); 115 } 116 117 } 118 119
title
Description
Body
title
Description
Body
title
Description
Body
title
Body