Completed
Pull Request — master (#49)
by Jesus
04:54
created

base::get_legacy_logdata()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
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
/**
18
 * The mod_bigbluebuttonbn abstract base event.
19
 *
20
 * @package   mod_bigbluebuttonbn
21
 * @copyright 2010 onwards, Blindside Networks Inc
22
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 * @author    Jesus Federico  (jesus [at] blindsidenetworks [dt] com)
24
 */
25
26
namespace mod_bigbluebuttonbn\event;
27
28
defined('MOODLE_INTERNAL') || die();
29
30
/**
31
 * The mod_bigbluebuttonbn abstract base event class. Most mod_bigbluebuttonbn events can extend this class.
32
 *
33
 * @package   mod_bigbluebuttonbn
34
 * @copyright 2010 onwards, Blindside Networks Inc
35
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36
 */
37
abstract class base extends \core\event\base {
38
39
    /** @var \bigbluebuttonbn */
40
    protected $bigbluebuttonbn;
41
42
    /**
43
     * Description.
44
     *
45
     * @var string
46
     */
47
    protected $description;
48
49
    /**
50
     * Object Id Mapping.
51
     *
52
     * @var array
53
     */
54
    protected static $objectidmapping = array('db' => 'bigbluebuttonbn', 'restore' => 'bigbluebuttonbn');
55
56
    /**
57
     * Legacy log data.
58
     *
59
     * @var array
60
     */
61
    protected $legacylogdata;
62
63
    /**
64
     * Init method.
65
     */
66
    protected function init($crud = 'r', $edulevel = self::LEVEL_PARTICIPATING) {
67
        protected function init() {
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_PROTECTED
Loading history...
68
        $this->data['crud'] = $crud;	        $this->data['crud'] = 'r';
69
        $this->data['edulevel'] = $edulevel;
70
        $this->data['objecttable'] = 'bigbluebuttonbn';
71
    }
72
73
    /**
74
     * Returns description of what happened.
75
     *
76
     * @return string
77
     */
78
    public function get_description() {
79
        $vars = array(
80
            'userid' => $this->userid,
81
            'courseid' => $this->courseid,
82
            'objectid' => $this->objectid,
83
            'contextinstanceid' => $this->contextinstanceid,
84
            'other' => $this->other
85
          );
86
        $string = $this->description;
87
        foreach ($vars as $key => $value) {
88
            $string = str_replace("##" . $key, $value, $string);
89
        }
90
        return $string;
91
    }
92
93
    /**
94
     * Returns relevant URL.
95
     *
96
     * @return \moodle_url
97
     */
98
    public function get_url() {
99
        return new \moodle_url('/mod/bigbluebuttonbn/view.php', array('id' => $this->contextinstanceid));
100
    }
101
102
    /**
103
     * Sets the legacy event log data.
104
     *
105
     * @param string $action The current action
106
     * @param string $info A detailed description of the change. But no more than 255 characters.
107
     * @param string $url The url to the assign module instance.
108
     */
109
    public function set_legacy_logdata($action = '', $info = '', $url = '') {
110
        $fullurl = 'view.php?id=' . $this->contextinstanceid;
111
        if ($url != '') {
112
            $fullurl .= '&' . $url;
113
        }
114
115
        $this->legacylogdata = array($this->courseid, 'bigbluebuttonbn', $action, $fullurl, $info, $this->contextinstanceid);
116
    }
117
118
    /**
119
     * Return legacy data for add_to_log().
120
     *
121
     * @return array
122
     */
123
    protected function get_legacy_logdata() {
124
        if (isset($this->legacylogdata)) {
125
            return $this->legacylogdata;
126
        }
127
128
        return null;
129
    }
130
131
    /**
132
     * Custom validation.
133
     *
134
     * @throws \coding_exception
135
     */
136
    protected function validate_data() {
137
        parent::validate_data();
138
139
        if ($this->contextlevel != CONTEXT_MODULE) {
140
            throw new \coding_exception('Context level must be CONTEXT_MODULE.');
141
        }
142
    }
143
}
144