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/>.
17 * Event for when blog entries are viewed.
20 * @copyright 2013 onwards Ankit Agarwal
21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') ||
die();
28 * Class for event to be triggered when blog entries are viewed.
30 * @property-read array $other {
31 * Extra information about event.
33 * - int entryid: (optional) id of the entry.
34 * - int tagid: (optional) id of the tag.
35 * - int userid: (optional) id of the user.
36 * - int modid: (optional) id of the mod.
37 * - int groupid: (optional) id of the group.
38 * - int courseid: (optional) id of associated course.
39 * - string search: (optional) the string used to search.
40 * - int fromstart: (optional) the time to search from.
45 * @copyright 2013 onwards Ankit Agarwal
46 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
48 class blog_entries_viewed
extends base
{
50 /** @var array List of url params accepted*/
51 private $validparams = array('entryid', 'tagid', 'userid', 'modid', 'groupid', 'courseid', 'search', 'fromstart');
54 * Set basic properties for the event.
56 protected function init() {
57 $this->context
= \context_system
::instance();
58 $this->data
['crud'] = 'r';
59 $this->data
['edulevel'] = self
::LEVEL_PARTICIPATING
;
63 * Returns localised general event name.
67 public static function get_name() {
68 return get_string('eventblogentriesviewed', 'core_blog');
72 * Returns non-localised event description with id's for admin use only.
76 public function get_description() {
77 return "The user with id '$this->userid' viewed blog entries.";
81 * Returns relevant URL.
84 public function get_url() {
86 foreach ($this->validparams
as $param) {
87 if (!empty($this->other
[$param])) {
88 $params[$param] = $this->other
[$param];
91 return new \
moodle_url('/blog/index.php', $params);
95 * replace add_to_log() statement.
97 * @return array of parameters to be passed to legacy add_to_log() function.
99 protected function get_legacy_logdata() {
101 foreach ($this->validparams
as $param) {
102 if (!empty($this->other
[$param])) {
103 $params[$param] = $this->other
[$param];
106 $url = new \
moodle_url('index.php', $params);
107 return array (SITEID
, 'blog', 'view', $url->out(), 'view blog entry');