Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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) {
70
            $string = str_replace("##" . $key, $value, $string);
71
        }
72
        return $string;
73
    }
74
 
75
    /**
76
     * Returns relevant URL.
77
     *
78
     * @return moodle_url
79
     */
80
    public function get_url() {
81
        return new moodle_url('/mod/bigbluebuttonbn/view.php', ['id' => $this->contextinstanceid]);
82
    }
83
 
84
    /**
85
     * Init method.
86
     *
87
     * @param string $crud
88
     * @param int $edulevel
89
     */
90
    protected function init($crud = 'r', $edulevel = self::LEVEL_PARTICIPATING) {
91
        $this->data['crud'] = $crud;
92
        $this->data['edulevel'] = $edulevel;
93
        $this->data['objecttable'] = 'bigbluebuttonbn';
94
    }
95
 
96
    /**
97
     * Custom validation.
98
     *
99
     * @throws coding_exception
100
     */
101
    protected function validate_data() {
102
        parent::validate_data();
103
 
104
        if ($this->contextlevel != CONTEXT_MODULE) {
105
            throw new coding_exception('Context level must be CONTEXT_MODULE.');
106
        }
107
    }
108
}