MDL-50891 useragent: Move web crawler checks to useragent class
[moodle.git] / lib / classes / event / blog_entries_viewed.php
blob632b892fcdbfa293d2a16a6ad2697ac5bbad9bc6
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.
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 blog entries are viewed.
19 * @package core
20 * @copyright 2013 onwards Ankit Agarwal
21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 namespace core\event;
25 defined('MOODLE_INTERNAL') || die();
27 /**
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.
41 * }
43 * @package core
44 * @since Moodle 2.7
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');
53 /**
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;
62 /**
63 * Returns localised general event name.
65 * @return string
67 public static function get_name() {
68 return get_string('eventblogentriesviewed', 'core_blog');
71 /**
72 * Returns non-localised event description with id's for admin use only.
74 * @return string
76 public function get_description() {
77 return "The user with id '$this->userid' viewed blog entries.";
80 /**
81 * Returns relevant URL.
82 * @return \moodle_url
84 public function get_url() {
85 $params = array();
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);
94 /**
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() {
100 $params = array();
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');