See Release Notes
Long Term Support Release
Differences Between: [Versions 401 and 402] [Versions 401 and 403]
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 * Event for when a new blog entry is deleted. 18 * 19 * @package core 20 * @copyright 2013 Ankit Agarwal 21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 22 */ 23 namespace core\event; 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 /** 28 * Class blog_entry_deleted 29 * 30 * Event for when a new blog entry is deleted. 31 * 32 * @package core 33 * @since Moodle 2.6 34 * @copyright 2013 Ankit Agarwal 35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 36 */ 37 38 class blog_entry_deleted extends base { 39 40 /** @var \blog_entry A reference to the active blog_entry object. */ 41 protected $blogentry; 42 43 /** 44 * Set basic event properties. 45 */ 46 protected function init() { 47 $this->context = \context_system::instance(); 48 $this->data['objecttable'] = 'post'; 49 $this->data['crud'] = 'd'; 50 $this->data['edulevel'] = self::LEVEL_PARTICIPATING; 51 } 52 53 /** 54 * Returns localised general event name. 55 * 56 * @return string 57 */ 58 public static function get_name() { 59 return get_string("evententrydeleted", "core_blog"); 60 } 61 62 /** 63 * Sets blog_entry object to be used by observers. 64 * 65 * @param \blog_entry $blogentry A reference to the active blog_entry object. 66 */ 67 public function set_blog_entry(\blog_entry $blogentry) { 68 $this->blogentry = $blogentry; 69 } 70 71 /** 72 * Returns deleted blog entry for event observers. 73 * 74 * @throws \coding_exception 75 * @return \blog_entry 76 */ 77 public function get_blog_entry() { 78 if ($this->is_restored()) { 79 throw new \coding_exception('Function get_blog_entry() can not be used on restored events.'); 80 } 81 return $this->blogentry; 82 } 83 84 /** 85 * Returns non-localised description of what happened. 86 * 87 * @return string 88 */ 89 public function get_description() { 90 return "The user with id '$this->userid' deleted the blog entry with id '$this->objectid'."; 91 } 92 93 /** 94 * Does this event replace legacy event? 95 * 96 * @return string legacy event name 97 */ 98 public static function get_legacy_eventname() { 99 return 'blog_entry_deleted'; 100 } 101 102 /** 103 * Legacy event data if get_legacy_eventname() is not empty. 104 * 105 * @return \blog_entry 106 */ 107 protected function get_legacy_eventdata() { 108 return $this->blogentry; 109 } 110 111 /** 112 * replace add_to_log() statement. 113 * 114 * @return array of parameters to be passed to legacy add_to_log() function. 115 */ 116 protected function get_legacy_logdata() { 117 return array (SITEID, 'blog', 'delete', 'index.php?userid=' . $this->relateduserid, 'deleted blog entry with entry id# '. 118 $this->objectid); 119 } 120 121 /** 122 * Custom validations. 123 * 124 * @throws \coding_exception 125 * @return void 126 */ 127 protected function validate_data() { 128 parent::validate_data(); 129 130 if (!isset($this->relateduserid)) { 131 throw new \coding_exception('The \'relateduserid\' must be set.'); 132 } 133 } 134 135 public static function get_objectid_mapping() { 136 // Blogs are not backed up, so no need for mapping for restore. 137 return array('db' => 'post', 'restore' => base::NOT_MAPPED); 138 } 139 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body