| 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 |
namespace mod_bigbluebuttonbn\event;
|
|
|
18 |
|
|
|
19 |
use coding_exception;
|
|
|
20 |
use moodle_url;
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* The mod_bigbluebuttonbn abstract base event class. Most mod_bigbluebuttonbn events can extend this class.
|
|
|
24 |
*
|
|
|
25 |
* @package mod_bigbluebuttonbn
|
|
|
26 |
* @copyright 2010 onwards, Blindside Networks Inc
|
|
|
27 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
28 |
*/
|
|
|
29 |
abstract class base extends \core\event\base {
|
|
|
30 |
|
|
|
31 |
/**
|
|
|
32 |
* Object Id Mapping.
|
|
|
33 |
*
|
|
|
34 |
* @var array
|
|
|
35 |
*/
|
|
|
36 |
protected static $objectidmapping = ['db' => 'bigbluebuttonbn', 'restore' => 'bigbluebuttonbn'];
|
|
|
37 |
|
|
|
38 |
/** @var $bigbluebuttonbn */
|
|
|
39 |
protected $bigbluebuttonbn;
|
|
|
40 |
|
|
|
41 |
/**
|
|
|
42 |
* Description.
|
|
|
43 |
*
|
|
|
44 |
* @var string
|
|
|
45 |
*/
|
|
|
46 |
protected $description;
|
|
|
47 |
|
|
|
48 |
/**
|
|
|
49 |
* Legacy log data.
|
|
|
50 |
*
|
|
|
51 |
* @var array
|
|
|
52 |
*/
|
|
|
53 |
protected $legacylogdata;
|
|
|
54 |
|
|
|
55 |
/**
|
|
|
56 |
* Returns description of what happened.
|
|
|
57 |
*
|
|
|
58 |
* @return string
|
|
|
59 |
*/
|
|
|
60 |
public function get_description() {
|
|
|
61 |
$vars = [
|
|
|
62 |
'userid' => $this->userid,
|
|
|
63 |
'courseid' => $this->courseid,
|
|
|
64 |
'objectid' => $this->objectid,
|
|
|
65 |
'contextinstanceid' => $this->contextinstanceid,
|
|
|
66 |
'other' => $this->other
|
|
|
67 |
];
|
|
|
68 |
$string = $this->description;
|
|
|
69 |
foreach ($vars as $key => $value) {
|
| 1441 |
ariadna |
70 |
if ($value !== null) {
|
|
|
71 |
$string = str_replace("##" . $key, $value, $string);
|
|
|
72 |
}
|
| 1 |
efrain |
73 |
}
|
|
|
74 |
return $string;
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
/**
|
|
|
78 |
* Returns relevant URL.
|
|
|
79 |
*
|
|
|
80 |
* @return moodle_url
|
|
|
81 |
*/
|
|
|
82 |
public function get_url() {
|
|
|
83 |
return new moodle_url('/mod/bigbluebuttonbn/view.php', ['id' => $this->contextinstanceid]);
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
/**
|
|
|
87 |
* Init method.
|
|
|
88 |
*
|
|
|
89 |
* @param string $crud
|
|
|
90 |
* @param int $edulevel
|
|
|
91 |
*/
|
|
|
92 |
protected function init($crud = 'r', $edulevel = self::LEVEL_PARTICIPATING) {
|
|
|
93 |
$this->data['crud'] = $crud;
|
|
|
94 |
$this->data['edulevel'] = $edulevel;
|
|
|
95 |
$this->data['objecttable'] = 'bigbluebuttonbn';
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
/**
|
|
|
99 |
* Custom validation.
|
|
|
100 |
*
|
|
|
101 |
* @throws coding_exception
|
|
|
102 |
*/
|
|
|
103 |
protected function validate_data() {
|
|
|
104 |
parent::validate_data();
|
|
|
105 |
|
|
|
106 |
if ($this->contextlevel != CONTEXT_MODULE) {
|
|
|
107 |
throw new coding_exception('Context level must be CONTEXT_MODULE.');
|
|
|
108 |
}
|
|
|
109 |
}
|
|
|
110 |
}
|