1 |
efrain |
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 blog entries are viewed.
|
|
|
18 |
*
|
|
|
19 |
* @package core
|
|
|
20 |
* @copyright 2013 onwards 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 for event to be triggered when blog entries are viewed.
|
|
|
29 |
*
|
|
|
30 |
* @property-read array $other {
|
|
|
31 |
* Extra information about event.
|
|
|
32 |
*
|
|
|
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 |
* }
|
|
|
42 |
*
|
|
|
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
|
|
|
47 |
*/
|
|
|
48 |
class blog_entries_viewed extends base {
|
|
|
49 |
|
|
|
50 |
/** @var array List of url params accepted*/
|
|
|
51 |
private $validparams = array('entryid', 'tagid', 'userid', 'modid', 'groupid', 'courseid', 'search', 'fromstart');
|
|
|
52 |
|
|
|
53 |
/**
|
|
|
54 |
* Set basic properties for the event.
|
|
|
55 |
*/
|
|
|
56 |
protected function init() {
|
|
|
57 |
$this->context = \context_system::instance();
|
|
|
58 |
$this->data['crud'] = 'r';
|
|
|
59 |
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
/**
|
|
|
63 |
* Returns localised general event name.
|
|
|
64 |
*
|
|
|
65 |
* @return string
|
|
|
66 |
*/
|
|
|
67 |
public static function get_name() {
|
|
|
68 |
return get_string('eventblogentriesviewed', 'core_blog');
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
/**
|
|
|
72 |
* Returns non-localised event description with id's for admin use only.
|
|
|
73 |
*
|
|
|
74 |
* @return string
|
|
|
75 |
*/
|
|
|
76 |
public function get_description() {
|
|
|
77 |
return "The user with id '$this->userid' viewed blog entries.";
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
/**
|
|
|
81 |
* Returns relevant URL.
|
|
|
82 |
* @return \moodle_url
|
|
|
83 |
*/
|
|
|
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];
|
|
|
89 |
}
|
|
|
90 |
}
|
|
|
91 |
return new \moodle_url('/blog/index.php', $params);
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
public static function get_other_mapping() {
|
|
|
95 |
$othermapped = array();
|
|
|
96 |
$othermapped['entryid'] = array('db' => 'post', 'restore' => base::NOT_MAPPED);
|
|
|
97 |
$othermapped['tagid'] = array('db' => 'tag', 'restore' => base::NOT_MAPPED);
|
|
|
98 |
$othermapped['userid'] = array('db' => 'user', 'restore' => 'user');
|
|
|
99 |
$othermapped['modid'] = array('db' => 'course_modules', 'restore' => 'course_module');
|
|
|
100 |
$othermapped['groupid'] = array('db' => 'groups', 'restore' => 'group');
|
|
|
101 |
$othermapped['courseid'] = array('db' => 'course', 'restore' => 'course');
|
|
|
102 |
|
|
|
103 |
return $othermapped;
|
|
|
104 |
}
|
|
|
105 |
}
|