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 * Event to be triggered when a blog entry is updated.
21 * @copyright 2013 Ankit Agarwal
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') || die();
28 * Class blog_entry_updated
30 * Event to be triggered when a blog entry is updated.
33 * @copyright 2013 Ankit Agarwal
34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36 class blog_entry_updated extends base {
38 /** @var \blog_entry A reference to the active blog_entry object. */
39 protected $customobject;
42 * Set basic event properties.
44 protected function init() {
45 $this->context = \context_system::instance();
46 $this->data['objecttable'] = 'post';
47 $this->data['crud'] = 'u';
48 $this->data['level'] = self::LEVEL_PARTICIPATING;
52 * Set custom data of the event.
54 * @param \blog_entry $data A reference to the active blog_entry object.
56 public function set_custom_data($data) {
57 $this->customobject = $data;
61 * Returns localised general event name.
65 public static function get_name() {
66 return get_string('evententryupdated', 'core_blog');
70 * Returns non-localised description of what happened.
74 public function get_description() {
75 return 'User with id {$this->userid} updated blog entry {$this->other["subject"]';
79 * Returns relevant URL.
82 public function get_url() {
83 return new \moodle_url('/blog/index.php', array('entryid' => $this->objectid, 'userid' => $this->userid));
87 * Legacy event data if get_legacy_eventname() is not empty.
91 protected function get_legacy_eventdata() {
92 return $this->customobject;
98 * @return string legacy event name
100 public static function get_legacy_eventname() {
101 return 'blog_entry_edited';
105 * Replace legacy add_to_log() statement.
107 * @return array of parameters to be passed to legacy add_to_log() function.
109 protected function get_legacy_logdata() {
110 return array(SITEID, 'blog', 'update', 'index.php?userid=' . $this->relateduserid . '&entryid=' . $this->objectid,
111 $this->other['subject']);