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 locallib/config. |
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\locallib; |
27
|
|
|
|
28
|
|
|
defined('MOODLE_INTERNAL') || die(); |
29
|
|
|
|
30
|
|
|
require_once($CFG->dirroot . '/mod/bigbluebuttonbn/locallib.php'); |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Handles the global configuration based on config.php. |
34
|
|
|
* |
35
|
|
|
* @copyright 2010 onwards, Blindside Networks Inc |
36
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
37
|
|
|
*/ |
38
|
|
|
class config { |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Returns moodle version. |
42
|
|
|
* |
43
|
|
|
* @return string |
44
|
|
|
*/ |
45
|
|
|
public static function get_moodle_version_major() { |
46
|
|
|
global $CFG; |
47
|
|
|
$versionarray = explode('.', $CFG->version); |
48
|
|
|
return $versionarray[0]; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Returns configuration default values. |
53
|
|
|
* |
54
|
|
|
* @return array |
55
|
|
|
*/ |
56
|
|
|
public static function defaultvalues() { |
57
|
|
|
return array( |
58
|
|
|
'server_url' => (string) BIGBLUEBUTTONBN_DEFAULT_SERVER_URL, |
59
|
|
|
'shared_secret' => (string) BIGBLUEBUTTONBN_DEFAULT_SHARED_SECRET, |
60
|
|
|
'voicebridge_editable' => false, |
61
|
|
|
'importrecordings_enabled' => false, |
62
|
|
|
'importrecordings_from_deleted_enabled' => false, |
63
|
|
|
'waitformoderator_default' => false, |
64
|
|
|
'waitformoderator_editable' => true, |
65
|
|
|
'waitformoderator_ping_interval' => '10', |
66
|
|
|
'waitformoderator_cache_ttl' => '60', |
67
|
|
|
'userlimit_default' => '0', |
68
|
|
|
'userlimit_editable' => false, |
69
|
|
|
'preuploadpresentation_enabled' => false, |
70
|
|
|
'sendnotifications_enabled' => false, |
71
|
|
|
'recordingready_enabled' => false, |
72
|
|
|
'recordingstatus_enabled' => false, |
73
|
|
|
'meetingevents_enabled' => false, |
74
|
|
|
'participant_moderator_default' => '0', |
75
|
|
|
'scheduled_duration_enabled' => false, |
76
|
|
|
'scheduled_duration_compensation' => '10', |
77
|
|
|
'scheduled_pre_opening' => '10', |
78
|
|
|
'recordings_enabled' => true, |
79
|
|
|
'recordings_html_default' => false, |
80
|
|
|
'recordings_html_editable' => false, |
81
|
|
|
'recordings_deleted_default' => false, |
82
|
|
|
'recordings_deleted_editable' => false, |
83
|
|
|
'recordings_imported_default' => false, |
84
|
|
|
'recordings_imported_editable' => false, |
85
|
|
|
'recordings_preview_default' => true, |
86
|
|
|
'recordings_preview_editable' => false, |
87
|
|
|
'recordings_validate_url' => true, |
88
|
|
|
'recording_default' => true, |
89
|
|
|
'recording_editable' => true, |
90
|
|
|
'recording_icons_enabled' => true, |
91
|
|
|
'recording_all_from_start_default' => false, |
92
|
|
|
'recording_all_from_start_editable' => false, |
93
|
|
|
'recording_hide_button_default' => false, |
94
|
|
|
'recording_hide_button_editable' => false, |
95
|
|
|
'general_warning_message' => '', |
96
|
|
|
'general_warning_roles' => 'editingteacher,teacher', |
97
|
|
|
'general_warning_box_type' => 'info', |
98
|
|
|
'general_warning_button_text' => '', |
99
|
|
|
'general_warning_button_href' => '', |
100
|
|
|
'general_warning_button_class' => '', |
101
|
|
|
'clienttype_enabled' => false, |
102
|
|
|
'clienttype_default' => '0', |
103
|
|
|
'clienttype_editable' => true, |
104
|
|
|
'muteonstart_default' => false, |
105
|
|
|
'muteonstart_editable' => false, |
106
|
|
|
'disablecam_default' => false, |
107
|
|
|
'disablecam_editable' => true, |
108
|
|
|
'disablemic_default' => false, |
109
|
|
|
'disablemic_editable' => true, |
110
|
|
|
'disableprivatechat_default' => false, |
111
|
|
|
'disableprivatechat_editable' => true, |
112
|
|
|
'disablepublicchat_default' => false, |
113
|
|
|
'disablepublicchat_editable' => true, |
114
|
|
|
'disablenote_default' => false, |
115
|
|
|
'disablenote_editable' => true, |
116
|
|
|
'hideuserlist_default' => false, |
117
|
|
|
'hideuserlist_editable' => true, |
118
|
|
|
'lockedlayout_default' => false, |
119
|
|
|
'lockedlayout_editable' => true, |
120
|
|
|
'lockonjoin_default' => false, |
121
|
|
|
'lockonjoin_editable' => true, |
122
|
|
|
'lockonjoinconfigurable_default' => false, |
123
|
|
|
'lockonjoinconfigurable_editable' => true, |
124
|
|
|
'welcome_default' => '', |
125
|
|
|
); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Returns default value for an specific setting. |
130
|
|
|
* |
131
|
|
|
* @param string $setting |
132
|
|
|
* @return string |
133
|
|
|
*/ |
134
|
|
|
public static function defaultvalue($setting) { |
135
|
|
|
$defaultvalues = self::defaultvalues(); |
136
|
|
|
if (!array_key_exists($setting, $defaultvalues)) { |
137
|
|
|
return; |
138
|
|
|
} |
139
|
|
|
return $defaultvalues[$setting]; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Returns value for an specific setting. |
144
|
|
|
* |
145
|
|
|
* @param string $setting |
146
|
|
|
* @return string |
147
|
|
|
*/ |
148
|
|
|
public static function get($setting) { |
149
|
|
|
global $CFG; |
150
|
|
|
|
151
|
|
|
// if cluster is enable and server config is not empty |
152
|
|
|
if (self::clusterEnabled()) { |
153
|
|
|
if (!empty($CFG->{'bigbluebuttonbn_server'}) && !empty($CFG->{'bigbluebuttonbn_server'})) { |
154
|
|
|
$cluster = self::getCluster(); |
155
|
|
|
if (!empty($cluster)) { |
156
|
|
|
$serverName = $CFG->{'bigbluebuttonbn_server'}; |
157
|
|
|
if (isset($cluster->$serverName)) { |
158
|
|
|
if (isset($cluster->$serverName->$setting) && !empty($cluster->$serverName->$setting)) { |
159
|
|
|
return $cluster->$serverName->$setting; |
160
|
|
|
} |
161
|
|
|
} |
162
|
|
|
} |
163
|
|
|
} |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
if (isset($CFG->bigbluebuttonbn[$setting])) { |
167
|
|
|
return (string)$CFG->bigbluebuttonbn[$setting]; |
168
|
|
|
} |
169
|
|
|
if (isset($CFG->{'bigbluebuttonbn_'.$setting})) { |
170
|
|
|
return (string)$CFG->{'bigbluebuttonbn_'.$setting}; |
171
|
|
|
} |
172
|
|
|
return self::defaultvalue($setting); |
|
|
|
|
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
public static function getCluster() { |
176
|
|
|
global $CFG; |
177
|
|
|
if (isset($CFG->{'bigbluebuttonbn_cluster'})) { |
178
|
|
|
return json_decode($CFG->{'bigbluebuttonbn_cluster'}); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
return null; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
public static function clusterEnabled() { |
185
|
|
|
global $CFG; |
186
|
|
|
return (isset($CFG->{'bigbluebuttonbn_enable_cluster'}) && !empty($CFG->{'bigbluebuttonbn_enable_cluster'})); |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
public static function getServers() { |
190
|
|
|
$servers = []; |
191
|
|
|
$cluster = self::getCluster(); |
192
|
|
|
foreach ($cluster as $key => $clusterData) { |
193
|
|
|
$servers[$key] = $key; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
return $servers; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
public static function setCurrentServer($serverName) { |
200
|
|
|
set_config('bigbluebuttonbn_server', $serverName, ''); |
201
|
|
|
|
202
|
|
|
$cluster = self::getCluster(); |
203
|
|
|
if (!empty($cluster)) { |
204
|
|
|
foreach ($cluster as $key => $clusterData) { |
205
|
|
|
if ($serverName === $key) { |
206
|
|
|
self::setCurrentServerUrl($cluster->$serverName->server_url); |
207
|
|
|
self::setCurrentServerSharedSecret($cluster->$serverName->shared_secret); |
208
|
|
|
} |
209
|
|
|
} |
210
|
|
|
} |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
public static function setCurrentServerUrl($serverUrl) { |
214
|
|
|
set_config('bigbluebuttonbn_server_url', $serverUrl, ''); |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
public static function setCurrentServerSharedSecret($serverSharedSecret) { |
218
|
|
|
set_config('bigbluebuttonbn_shared_secret', $serverSharedSecret, ''); |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* Validates if recording settings are enabled. |
223
|
|
|
* |
224
|
|
|
* @return boolean |
225
|
|
|
*/ |
226
|
|
|
public static function recordings_enabled() { |
227
|
|
|
return (boolean)self::get('recordings_enabled'); |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* Validates if imported recording settings are enabled. |
232
|
|
|
* |
233
|
|
|
* @return boolean |
234
|
|
|
*/ |
235
|
|
|
public static function importrecordings_enabled() { |
236
|
|
|
return (boolean)self::get('importrecordings_enabled'); |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
/** |
240
|
|
|
* Validates if clienttype settings are enabled. |
241
|
|
|
* |
242
|
|
|
* @return boolean |
243
|
|
|
*/ |
244
|
|
|
public static function clienttype_enabled() { |
245
|
|
|
return (boolean)self::get('clienttype_enabled'); |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
/** |
249
|
|
|
* Wraps current settings in an array. |
250
|
|
|
* |
251
|
|
|
* @return array |
252
|
|
|
*/ |
253
|
|
|
public static function get_options() { |
254
|
|
|
return array( |
255
|
|
|
'version_major' => self::get_moodle_version_major(), |
256
|
|
|
'voicebridge_editable' => self::get('voicebridge_editable'), |
257
|
|
|
'importrecordings_enabled' => self::get('importrecordings_enabled'), |
258
|
|
|
'importrecordings_from_deleted_enabled' => self::get('importrecordings_from_deleted_enabled'), |
259
|
|
|
'waitformoderator_default' => self::get('waitformoderator_default'), |
260
|
|
|
'waitformoderator_editable' => self::get('waitformoderator_editable'), |
261
|
|
|
'userlimit_default' => self::get('userlimit_default'), |
262
|
|
|
'userlimit_editable' => self::get('userlimit_editable'), |
263
|
|
|
'preuploadpresentation_enabled' => self::get('preuploadpresentation_enabled'), |
264
|
|
|
'sendnotifications_enabled' => self::get('sendnotifications_enabled'), |
265
|
|
|
'recordings_enabled' => self::get('recordings_enabled'), |
266
|
|
|
'meetingevents_enabled' => self::get('meetingevents_enabled'), |
267
|
|
|
'recordings_html_default' => self::get('recordings_html_default'), |
268
|
|
|
'recordings_html_editable' => self::get('recordings_html_editable'), |
269
|
|
|
'recordings_deleted_default' => self::get('recordings_deleted_default'), |
270
|
|
|
'recordings_deleted_editable' => self::get('recordings_deleted_editable'), |
271
|
|
|
'recordings_imported_default' => self::get('recordings_imported_default'), |
272
|
|
|
'recordings_imported_editable' => self::get('recordings_imported_editable'), |
273
|
|
|
'recordings_preview_default' => self::get('recordings_preview_default'), |
274
|
|
|
'recordings_preview_editable' => self::get('recordings_preview_editable'), |
275
|
|
|
'recordings_validate_url' => self::get('recordings_validate_url'), |
276
|
|
|
'recording_default' => self::get('recording_default'), |
277
|
|
|
'recording_editable' => self::get('recording_editable'), |
278
|
|
|
'recording_icons_enabled' => self::get('recording_icons_enabled'), |
279
|
|
|
'recording_all_from_start_default' => self::get('recording_all_from_start_default'), |
280
|
|
|
'recording_all_from_start_editable' => self::get('recording_all_from_start_editable'), |
281
|
|
|
'recording_hide_button_default' => self::get('recording_hide_button_default'), |
282
|
|
|
'recording_hide_button_editable' => self::get('recording_hide_button_editable'), |
283
|
|
|
'general_warning_message' => self::get('general_warning_message'), |
284
|
|
|
'general_warning_box_type' => self::get('general_warning_box_type'), |
285
|
|
|
'general_warning_button_text' => self::get('general_warning_button_text'), |
286
|
|
|
'general_warning_button_href' => self::get('general_warning_button_href'), |
287
|
|
|
'general_warning_button_class' => self::get('general_warning_button_class'), |
288
|
|
|
'clienttype_enabled' => self::get('clienttype_enabled'), |
289
|
|
|
'clienttype_editable' => self::get('clienttype_editable'), |
290
|
|
|
'clienttype_default' => self::get('clienttype_default'), |
291
|
|
|
'muteonstart_editable' => self::get('muteonstart_editable'), |
292
|
|
|
'muteonstart_default' => self::get('muteonstart_default'), |
293
|
|
|
'disablecam_editable' => self::get('disablecam_editable'), |
294
|
|
|
'disablecam_default' => self::get('disablecam_default'), |
295
|
|
|
'disablemic_editable' => self::get('disablemic_editable'), |
296
|
|
|
'disablemic_default' => self::get('disablemic_default'), |
297
|
|
|
'disableprivatechat_editable' => self::get('disableprivatechat_editable'), |
298
|
|
|
'disableprivatechat_default' => self::get('disableprivatechat_default'), |
299
|
|
|
'disablepublicchat_editable' => self::get('disablepublicchat_editable'), |
300
|
|
|
'disablepublicchat_default' => self::get('disablepublicchat_default'), |
301
|
|
|
'disablenote_editable' => self::get('disablenote_editable'), |
302
|
|
|
'disablenote_default' => self::get('disablenote_default'), |
303
|
|
|
'hideuserlist_editable' => self::get('hideuserlist_editable'), |
304
|
|
|
'hideuserlist_default' => self::get('hideuserlist_default'), |
305
|
|
|
'lockedlayout_editable' => self::get('lockedlayout_editable'), |
306
|
|
|
'lockedlayout_default' => self::get('lockedlayout_default'), |
307
|
|
|
'lockonjoin_editable' => self::get('lockonjoin_editable'), |
308
|
|
|
'lockonjoin_default' => self::get('lockonjoin_default'), |
309
|
|
|
'lockonjoinconfigurable_editable' => self::get('lockonjoinconfigurable_editable'), |
310
|
|
|
'lockonjoinconfigurable_default' => self::get('lockonjoinconfigurable_default'), |
311
|
|
|
'welcome_default' => self::get('welcome_default'), |
312
|
|
|
); |
313
|
|
|
} |
314
|
|
|
} |
315
|
|
|
|