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\local;
|
|
|
18 |
|
|
|
19 |
use mod_bigbluebuttonbn\instance;
|
|
|
20 |
use mod_bigbluebuttonbn\local\proxy\bigbluebutton_proxy;
|
|
|
21 |
use mod_bigbluebuttonbn\recording;
|
|
|
22 |
|
|
|
23 |
/**
|
|
|
24 |
* Handles the global configuration based on config.php.
|
|
|
25 |
*
|
|
|
26 |
* @package mod_bigbluebuttonbn
|
|
|
27 |
* @copyright 2010 onwards, Blindside Networks Inc
|
|
|
28 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
29 |
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
|
|
30 |
*/
|
|
|
31 |
class config {
|
|
|
32 |
|
|
|
33 |
/** @var string Default bigbluebutton server url */
|
|
|
34 |
public const DEFAULT_SERVER_URL = 'https://test-moodle.blindsidenetworks.com/bigbluebutton/';
|
|
|
35 |
|
|
|
36 |
/** @var string Default bigbluebutton server shared secret */
|
|
|
37 |
public const DEFAULT_SHARED_SECRET = '0b21fcaf34673a8c3ec8ed877d76ae34';
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
/** @var string the default bigbluebutton checksum algorithm */
|
|
|
41 |
public const DEFAULT_CHECKSUM_ALGORITHM = 'SHA256';
|
|
|
42 |
|
|
|
43 |
/** @var array list of supported bigbluebutton checksum algorithm */
|
|
|
44 |
const CHECKSUM_ALGORITHMS = [
|
|
|
45 |
self::DEFAULT_CHECKSUM_ALGORITHM,
|
|
|
46 |
'SHA1',
|
|
|
47 |
'SHA512'
|
|
|
48 |
];
|
|
|
49 |
|
|
|
50 |
/**
|
|
|
51 |
* Returns moodle version.
|
|
|
52 |
*
|
|
|
53 |
* @return string
|
|
|
54 |
*/
|
|
|
55 |
protected static function get_moodle_version_major(): string {
|
|
|
56 |
global $CFG;
|
|
|
57 |
$versionarray = explode('.', $CFG->version);
|
|
|
58 |
return $versionarray[0];
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
/**
|
|
|
62 |
* Returns configuration default values.
|
|
|
63 |
*
|
|
|
64 |
* @return array
|
|
|
65 |
*/
|
|
|
66 |
protected static function defaultvalues(): array {
|
|
|
67 |
return [
|
|
|
68 |
'server_url' => '',
|
|
|
69 |
'shared_secret' => '',
|
|
|
70 |
'voicebridge_editable' => false,
|
|
|
71 |
'importrecordings_enabled' => false,
|
|
|
72 |
'importrecordings_from_deleted_enabled' => false,
|
|
|
73 |
'waitformoderator_default' => false,
|
|
|
74 |
'waitformoderator_editable' => true,
|
|
|
75 |
'waitformoderator_ping_interval' => '10',
|
|
|
76 |
'waitformoderator_cache_ttl' => '60',
|
|
|
77 |
'userlimit_default' => '0',
|
|
|
78 |
'userlimit_editable' => false,
|
|
|
79 |
'preuploadpresentation_editable' => false,
|
|
|
80 |
'recordingready_enabled' => false,
|
|
|
81 |
'recordingstatus_enabled' => false,
|
|
|
82 |
'meetingevents_enabled' => false,
|
|
|
83 |
'participant_moderator_default' => '0',
|
|
|
84 |
'profile_picture_enabled' => false,
|
|
|
85 |
'scheduled_pre_opening' => '10',
|
|
|
86 |
'recordings_enabled' => true,
|
|
|
87 |
'recordings_deleted_default' => false,
|
|
|
88 |
'recordings_deleted_editable' => false,
|
|
|
89 |
'recordings_imported_default' => false,
|
|
|
90 |
'recordings_imported_editable' => false,
|
|
|
91 |
'recordings_preview_default' => true,
|
|
|
92 |
'recordings_preview_editable' => false,
|
|
|
93 |
'recording_default' => true,
|
|
|
94 |
'recording_editable' => true,
|
|
|
95 |
'recording_refresh_period' => recording::RECORDING_REFRESH_DEFAULT_PERIOD,
|
|
|
96 |
'recording_all_from_start_default' => false,
|
|
|
97 |
'recording_all_from_start_editable' => false,
|
|
|
98 |
'recording_hide_button_default' => false,
|
|
|
99 |
'recording_hide_button_editable' => false,
|
|
|
100 |
'recording_protect_editable' => true,
|
|
|
101 |
'general_warning_message' => '',
|
|
|
102 |
'general_warning_roles' => 'editingteacher,teacher',
|
|
|
103 |
'general_warning_box_type' => 'info',
|
|
|
104 |
'general_warning_button_text' => '',
|
|
|
105 |
'general_warning_button_href' => '',
|
|
|
106 |
'general_warning_button_class' => '',
|
|
|
107 |
'muteonstart_default' => false,
|
|
|
108 |
'muteonstart_editable' => false,
|
|
|
109 |
'disablecam_default' => false,
|
|
|
110 |
'disablecam_editable' => true,
|
|
|
111 |
'disablemic_default' => false,
|
|
|
112 |
'disablemic_editable' => true,
|
|
|
113 |
'disableprivatechat_default' => false,
|
|
|
114 |
'disableprivatechat_editable' => true,
|
|
|
115 |
'disablepublicchat_default' => false,
|
|
|
116 |
'disablepublicchat_editable' => true,
|
|
|
117 |
'disablenote_default' => false,
|
|
|
118 |
'disablenote_editable' => true,
|
|
|
119 |
'hideuserlist_default' => false,
|
|
|
120 |
'hideuserlist_editable' => true,
|
|
|
121 |
'welcome_default' => '',
|
|
|
122 |
'welcome_editable' => true,
|
|
|
123 |
'default_dpa_accepted' => false,
|
|
|
124 |
'poll_interval' => bigbluebutton_proxy::DEFAULT_POLL_INTERVAL,
|
|
|
125 |
'checksum_algorithm' => self::DEFAULT_CHECKSUM_ALGORITHM,
|
|
|
126 |
];
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
/**
|
|
|
130 |
* Returns default value for an specific setting.
|
|
|
131 |
*
|
|
|
132 |
* @param string $setting
|
|
|
133 |
* @return string|null
|
|
|
134 |
*/
|
|
|
135 |
public static function defaultvalue(string $setting): ?string {
|
|
|
136 |
$defaultvalues = self::defaultvalues();
|
|
|
137 |
if (!array_key_exists($setting, $defaultvalues)) {
|
|
|
138 |
return null;
|
|
|
139 |
}
|
|
|
140 |
return $defaultvalues[$setting];
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
/**
|
|
|
144 |
* Returns value for an specific setting.
|
|
|
145 |
*
|
|
|
146 |
* @param string $setting
|
|
|
147 |
* @return string
|
|
|
148 |
*/
|
|
|
149 |
public static function get(string $setting): string {
|
|
|
150 |
global $CFG;
|
|
|
151 |
if (isset($CFG->bigbluebuttonbn[$setting])) {
|
|
|
152 |
return (string) $CFG->bigbluebuttonbn[$setting];
|
|
|
153 |
}
|
|
|
154 |
if (isset($CFG->{'bigbluebuttonbn_' . $setting})) {
|
|
|
155 |
return (string) $CFG->{'bigbluebuttonbn_' . $setting};
|
|
|
156 |
}
|
|
|
157 |
return (string) self::defaultvalue($setting);
|
|
|
158 |
}
|
|
|
159 |
|
|
|
160 |
/**
|
|
|
161 |
* Validates if recording settings are enabled.
|
|
|
162 |
*
|
|
|
163 |
* @return bool
|
|
|
164 |
*/
|
|
|
165 |
public static function recordings_enabled(): bool {
|
|
|
166 |
return (boolean) self::get('recordings_enabled');
|
|
|
167 |
}
|
|
|
168 |
|
|
|
169 |
/**
|
|
|
170 |
* Validates if imported recording settings are enabled.
|
|
|
171 |
*
|
|
|
172 |
* @return bool
|
|
|
173 |
*/
|
|
|
174 |
public static function importrecordings_enabled(): bool {
|
|
|
175 |
return (boolean) self::get('importrecordings_enabled');
|
|
|
176 |
}
|
|
|
177 |
|
|
|
178 |
/**
|
|
|
179 |
* Check if bbb server credentials are invalid.
|
|
|
180 |
*
|
|
|
181 |
* @return bool
|
|
|
182 |
*/
|
|
|
183 |
public static function server_credentials_invalid(): bool {
|
|
|
184 |
// Test server credentials across all versions of the plugin are flagged.
|
|
|
185 |
$parsedurl = parse_url(self::get('server_url'));
|
|
|
186 |
$defaultserverurl = parse_url(self::DEFAULT_SERVER_URL);
|
|
|
187 |
if (!isset($parsedurl['host'])) {
|
|
|
188 |
return false;
|
|
|
189 |
}
|
|
|
190 |
if (strpos($parsedurl['host'], $defaultserverurl['host']) === 0) {
|
|
|
191 |
return true;
|
|
|
192 |
}
|
|
|
193 |
if (strpos($parsedurl['host'], 'test-install.blindsidenetworks.com') === 0) {
|
|
|
194 |
return true;
|
|
|
195 |
}
|
|
|
196 |
return false;
|
|
|
197 |
}
|
|
|
198 |
|
|
|
199 |
/**
|
|
|
200 |
* Wraps current settings in an array.
|
|
|
201 |
*
|
|
|
202 |
* @return array
|
|
|
203 |
*/
|
|
|
204 |
public static function get_options(): array {
|
|
|
205 |
return [
|
|
|
206 |
'version_major' => self::get_moodle_version_major(),
|
|
|
207 |
'voicebridge_editable' => self::get('voicebridge_editable'),
|
|
|
208 |
'importrecordings_enabled' => self::get('importrecordings_enabled'),
|
|
|
209 |
'importrecordings_from_deleted_enabled' => self::get('importrecordings_from_deleted_enabled'),
|
|
|
210 |
'waitformoderator_default' => self::get('waitformoderator_default'),
|
|
|
211 |
'waitformoderator_editable' => self::get('waitformoderator_editable'),
|
|
|
212 |
'userlimit_default' => self::get('userlimit_default'),
|
|
|
213 |
'userlimit_editable' => self::get('userlimit_editable'),
|
|
|
214 |
'preuploadpresentation_editable' => self::get('preuploadpresentation_editable'),
|
|
|
215 |
'recordings_enabled' => self::get('recordings_enabled'),
|
|
|
216 |
'meetingevents_enabled' => self::get('meetingevents_enabled'),
|
|
|
217 |
'recordings_deleted_default' => self::get('recordings_deleted_default'),
|
|
|
218 |
'recordings_deleted_editable' => self::get('recordings_deleted_editable'),
|
|
|
219 |
'recordings_imported_default' => self::get('recordings_imported_default'),
|
|
|
220 |
'recordings_imported_editable' => self::get('recordings_imported_editable'),
|
|
|
221 |
'recordings_preview_default' => self::get('recordings_preview_default'),
|
|
|
222 |
'recordings_preview_editable' => self::get('recordings_preview_editable'),
|
|
|
223 |
'recording_default' => self::get('recording_default'),
|
|
|
224 |
'recording_editable' => self::get('recording_editable'),
|
|
|
225 |
'recording_refresh_period' => self::get('recording_refresh_period'),
|
|
|
226 |
'recording_all_from_start_default' => self::get('recording_all_from_start_default'),
|
|
|
227 |
'recording_all_from_start_editable' => self::get('recording_all_from_start_editable'),
|
|
|
228 |
'recording_hide_button_default' => self::get('recording_hide_button_default'),
|
|
|
229 |
'recording_hide_button_editable' => self::get('recording_hide_button_editable'),
|
|
|
230 |
'recording_protect_editable' => self::get('recording_protect_editable'),
|
|
|
231 |
'general_warning_message' => self::get('general_warning_message'),
|
|
|
232 |
'general_warning_box_type' => self::get('general_warning_box_type'),
|
|
|
233 |
'general_warning_button_text' => self::get('general_warning_button_text'),
|
|
|
234 |
'general_warning_button_href' => self::get('general_warning_button_href'),
|
|
|
235 |
'general_warning_button_class' => self::get('general_warning_button_class'),
|
|
|
236 |
'muteonstart_editable' => self::get('muteonstart_editable'),
|
|
|
237 |
'muteonstart_default' => self::get('muteonstart_default'),
|
|
|
238 |
'disablecam_editable' => self::get('disablecam_editable'),
|
|
|
239 |
'disablecam_default' => self::get('disablecam_default'),
|
|
|
240 |
'disablemic_editable' => self::get('disablemic_editable'),
|
|
|
241 |
'disablemic_default' => self::get('disablemic_default'),
|
|
|
242 |
'disableprivatechat_editable' => self::get('disableprivatechat_editable'),
|
|
|
243 |
'disableprivatechat_default' => self::get('disableprivatechat_default'),
|
|
|
244 |
'disablepublicchat_editable' => self::get('disablepublicchat_editable'),
|
|
|
245 |
'disablepublicchat_default' => self::get('disablepublicchat_default'),
|
|
|
246 |
'disablenote_editable' => self::get('disablenote_editable'),
|
|
|
247 |
'disablenote_default' => self::get('disablenote_default'),
|
|
|
248 |
'hideuserlist_editable' => self::get('hideuserlist_editable'),
|
|
|
249 |
'hideuserlist_default' => self::get('hideuserlist_default'),
|
|
|
250 |
'welcome_default' => self::get('welcome_default'),
|
|
|
251 |
'welcome_editable' => self::get('welcome_editable'),
|
|
|
252 |
'poll_interval' => self::get('poll_interval'),
|
|
|
253 |
'guestaccess_enabled' => self::get('guestaccess_enabled'),
|
|
|
254 |
];
|
|
|
255 |
}
|
|
|
256 |
|
|
|
257 |
/**
|
|
|
258 |
* Helper function returns an array with enabled features for an specific profile type.
|
|
|
259 |
*
|
|
|
260 |
* @param array $typeprofiles
|
|
|
261 |
* @param string|null $type
|
|
|
262 |
*
|
|
|
263 |
* @return array
|
|
|
264 |
*/
|
|
|
265 |
public static function get_enabled_features(array $typeprofiles, ?string $type = null): array {
|
|
|
266 |
$enabledfeatures = [];
|
|
|
267 |
$features = $typeprofiles[instance::TYPE_ALL]['features'];
|
|
|
268 |
if (!is_null($type) && key_exists($type, $typeprofiles)) {
|
|
|
269 |
$features = $typeprofiles[$type]['features'];
|
|
|
270 |
}
|
|
|
271 |
$enabledfeatures['showroom'] = (in_array('all', $features) || in_array('showroom', $features));
|
|
|
272 |
// Evaluates if recordings are enabled for the Moodle site.
|
|
|
273 |
$enabledfeatures['showrecordings'] = false;
|
|
|
274 |
if (self::recordings_enabled()) {
|
|
|
275 |
$enabledfeatures['showrecordings'] = (in_array('all', $features) || in_array('showrecordings', $features));
|
|
|
276 |
}
|
|
|
277 |
$enabledfeatures['importrecordings'] = false;
|
|
|
278 |
if (self::importrecordings_enabled()) {
|
|
|
279 |
$enabledfeatures['importrecordings'] = (in_array('all', $features) || in_array('importrecordings', $features));
|
|
|
280 |
}
|
|
|
281 |
return $enabledfeatures;
|
|
|
282 |
}
|
|
|
283 |
}
|