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
|
|
|
* Config all BigBlueButtonBN instances in this course. |
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
|
|
|
* @author Fred Dixon (ffdixon [at] blindsidenetworks [dt] com) |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
defined('MOODLE_INTERNAL') || die(); |
28
|
|
|
|
29
|
|
|
require_once(dirname(__FILE__).'/locallib.php'); |
30
|
|
|
require_once($CFG->dirroot.'/course/moodleform_mod.php'); |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Moodle class for mod_form. |
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 mod_bigbluebuttonbn_mod_form extends moodleform_mod { |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Define (add) particular settings this activity can have. |
42
|
|
|
* |
43
|
|
|
* @return void |
44
|
|
|
*/ |
45
|
|
|
public function definition() { |
46
|
|
|
global $CFG, $DB, $OUTPUT, $PAGE; |
47
|
|
|
$mform = &$this->_form; |
48
|
|
|
|
49
|
|
|
// Validates if the BigBlueButton server is running. |
50
|
|
|
$serverversion = bigbluebuttonbn_get_server_version(); |
51
|
|
|
if (is_null($serverversion)) { |
52
|
|
|
print_error('general_error_unable_connect', 'bigbluebuttonbn', |
53
|
|
|
$CFG->wwwroot.'/admin/settings.php?section=modsettingbigbluebuttonbn'); |
54
|
|
|
return; |
55
|
|
|
} |
56
|
|
|
$bigbluebuttonbn = null; |
57
|
|
|
if ($this->current->id) { |
58
|
|
|
$bigbluebuttonbn = $DB->get_record('bigbluebuttonbn', array('id' => $this->current->id), '*', MUST_EXIST); |
59
|
|
|
} |
60
|
|
|
// UI configuration options. |
61
|
|
|
$cfg = \mod_bigbluebuttonbn\locallib\config::get_options(); |
62
|
|
|
|
63
|
|
|
$jsvars = array(); |
64
|
|
|
|
65
|
|
|
// Get only those that are allowed. |
66
|
|
|
$course = get_course($this->current->course); |
67
|
|
|
$context = context_course::instance($course->id); |
68
|
|
|
$jsvars['instanceTypeProfiles'] = bigbluebuttonbn_get_instance_type_profiles_create_allowed( |
69
|
|
|
has_capability('mod/bigbluebuttonbn:meeting', $context), |
70
|
|
|
has_capability('mod/bigbluebuttonbn:recording', $context) |
71
|
|
|
); |
72
|
|
|
// If none is allowed, fail and return. |
73
|
|
|
if (empty($jsvars['instanceTypeProfiles'])) { |
74
|
|
|
// Also check module context for those that are allowed. |
75
|
|
|
$contextm = context_module::instance($this->_cm->id); |
76
|
|
|
$jsvars['instanceTypeProfiles'] = bigbluebuttonbn_get_instance_type_profiles_create_allowed( |
77
|
|
|
has_capability('mod/bigbluebuttonbn:meeting', $contextm), |
78
|
|
|
has_capability('mod/bigbluebuttonbn:recording', $contextm) |
79
|
|
|
); |
80
|
|
|
// If still none is allowed, fail and return. |
81
|
|
|
if (empty($jsvars['instanceTypeProfiles'])) { |
82
|
|
|
print_error('general_error_not_allowed_to_create_instances)', 'bigbluebuttonbn', |
83
|
|
|
$CFG->wwwroot.'/admin/settings.php?section=modsettingbigbluebuttonbn'); |
84
|
|
|
return; |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
$jsvars['instanceTypeDefault'] = array_keys($jsvars['instanceTypeProfiles'])[0]; |
88
|
|
|
$this->bigbluebuttonbn_mform_add_block_profiles($mform, $jsvars['instanceTypeProfiles']); |
89
|
|
|
// Data for participant selection. |
90
|
|
|
$participantlist = bigbluebuttonbn_get_participant_list($bigbluebuttonbn, $context); |
91
|
|
|
// Add block 'General'. |
92
|
|
|
$this->bigbluebuttonbn_mform_add_block_general($mform, $cfg); |
93
|
|
|
// Add block 'Room'. |
94
|
|
|
$this->bigbluebuttonbn_mform_add_block_room($mform, $cfg); |
95
|
|
|
// Add block 'Lock'. |
96
|
|
|
$this->bigbluebuttonbn_mform_add_block_locksettings($mform, $cfg); |
97
|
|
|
// Add block 'Preuploads'. |
98
|
|
|
$this->bigbluebuttonbn_mform_add_block_preuploads($mform, $cfg); |
99
|
|
|
// Add block 'Participant List'. |
100
|
|
|
$this->bigbluebuttonbn_mform_add_block_user_role_mapping($mform, $participantlist); |
101
|
|
|
// Add block 'Schedule'. |
102
|
|
|
$this->bigbluebuttonbn_mform_add_block_schedule($mform, $this->current); |
103
|
|
|
// Add block 'client Type'. |
104
|
|
|
$this->bigbluebuttonbn_mform_add_block_clienttype($mform, $cfg); |
105
|
|
|
// Add standard elements, common to all modules. |
106
|
|
|
$this->standard_coursemodule_elements(); |
107
|
|
|
// Add standard buttons, common to all modules. |
108
|
|
|
$this->add_action_buttons(); |
109
|
|
|
// JavaScript for locales. |
110
|
|
|
$PAGE->requires->strings_for_js(array_keys(bigbluebuttonbn_get_strings_for_js()), 'bigbluebuttonbn'); |
111
|
|
|
$jsvars['participantData'] = bigbluebuttonbn_get_participant_data($context, $bigbluebuttonbn); |
112
|
|
|
$jsvars['participantList'] = $participantlist; |
113
|
|
|
$jsvars['iconsEnabled'] = (boolean)$cfg['recording_icons_enabled']; |
114
|
|
|
$jsvars['pixIconDelete'] = (string)$OUTPUT->pix_icon('t/delete', get_string('delete'), 'moodle'); |
115
|
|
|
$PAGE->requires->yui_module('moodle-mod_bigbluebuttonbn-modform', |
116
|
|
|
'M.mod_bigbluebuttonbn.modform.init', array($jsvars)); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Prepare the attachment for being stored. |
121
|
|
|
* |
122
|
|
|
* @param array $defaultvalues |
123
|
|
|
* @return void |
124
|
|
|
*/ |
125
|
|
|
public function data_preprocessing(&$defaultvalues) { |
126
|
|
|
parent::data_preprocessing($defaultvalues); |
127
|
|
|
|
128
|
|
|
// Completion: tick by default if completion attendance settings is set to 1 or more. |
129
|
|
|
$defaultvalues['completionattendanceenabled'] = 0; |
130
|
|
|
if (!empty($defaultvalues['completionattendance'])) { |
131
|
|
|
$defaultvalues['completionattendanceenabled'] = 1; |
132
|
|
|
} |
133
|
|
|
// Check if we are Editing an existing instance. |
134
|
|
|
if ($this->current->instance) { |
135
|
|
|
// Pre-uploaded presentation: copy existing files into draft area. |
136
|
|
|
try { |
137
|
|
|
$draftitemid = file_get_submitted_draft_itemid('presentation'); |
138
|
|
|
file_prepare_draft_area($draftitemid, $this->context->id, 'mod_bigbluebuttonbn', 'presentation', 0, |
139
|
|
|
array('subdirs' => 0, 'maxbytes' => 0, 'maxfiles' => 1, 'mainfile' => true) |
140
|
|
|
); |
141
|
|
|
$defaultvalues['presentation'] = $draftitemid; |
142
|
|
|
} catch (Exception $e) { |
143
|
|
|
debugging('Presentation could not be loaded: '.$e->getMessage(), DEBUG_DEVELOPER); |
144
|
|
|
return; |
145
|
|
|
} |
146
|
|
|
// Completion: tick if completion attendance settings is set to 1 or more. |
147
|
|
|
$defaultvalues['completionattendanceenabled'] = 0; |
148
|
|
|
if (!empty($this->current->completionattendance)) { |
149
|
|
|
$defaultvalues['completionattendanceenabled'] = 1; |
150
|
|
|
} |
151
|
|
|
} |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* Validates the data processed by the form. |
156
|
|
|
* |
157
|
|
|
* @param array $data |
158
|
|
|
* @param array $files |
159
|
|
|
* @return void |
160
|
|
|
*/ |
161
|
|
|
public function validation($data, $files) { |
162
|
|
|
$errors = parent::validation($data, $files); |
163
|
|
|
if (isset($data['openingtime']) && isset($data['closingtime'])) { |
164
|
|
|
if ($data['openingtime'] != 0 && $data['closingtime'] != 0 && |
165
|
|
|
$data['closingtime'] < $data['openingtime']) { |
166
|
|
|
$errors['closingtime'] = get_string('bbbduetimeoverstartingtime', 'bigbluebuttonbn'); |
167
|
|
|
} |
168
|
|
|
} |
169
|
|
|
if (isset($data['voicebridge'])) { |
170
|
|
|
if (!bigbluebuttonbn_voicebridge_unique($data['instance'], $data['voicebridge'])) { |
171
|
|
|
$errors['voicebridge'] = get_string('mod_form_field_voicebridge_notunique_error', 'bigbluebuttonbn'); |
172
|
|
|
} |
173
|
|
|
} |
174
|
|
|
return $errors; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Add elements for setting the custom completion rules. |
179
|
|
|
* |
180
|
|
|
* @category completion |
181
|
|
|
* @return array List of added element names, or names of wrapping group elements. |
182
|
|
|
*/ |
183
|
|
|
public function add_completion_rules() { |
184
|
|
|
$mform = $this->_form; |
185
|
|
|
if (!(boolean)\mod_bigbluebuttonbn\locallib\config::get('meetingevents_enabled')) { |
186
|
|
|
return []; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
// Elements for completion by Attendance. |
190
|
|
|
$attendance['grouplabel'] = get_string('completionattendancegroup', 'bigbluebuttonbn'); |
|
|
|
|
191
|
|
|
$attendance['rulelabel'] = get_string('completionattendance', 'bigbluebuttonbn'); |
192
|
|
|
$attendance['group'] = [ |
193
|
|
|
$mform->createElement('advcheckbox', 'completionattendanceenabled', '', $attendance['rulelabel'] . ' '), |
194
|
|
|
$mform->createElement('text', 'completionattendance', '', ['size' => 3]), |
195
|
|
|
$mform->createElement('static', 'completionattendanceunit', ' ', get_string('minutes', 'bigbluebuttonbn')) |
196
|
|
|
]; |
197
|
|
|
$mform->setType('completionattendance', PARAM_INT); |
198
|
|
|
$mform->addGroup($attendance['group'], 'completionattendancegroup', $attendance['grouplabel'], [' '], false); |
199
|
|
|
$mform->addHelpButton('completionattendancegroup', 'completionattendancegroup', 'bigbluebuttonbn'); |
200
|
|
|
$mform->disabledIf('completionattendancegroup', 'completionview', 'notchecked'); |
201
|
|
|
$mform->disabledIf('completionattendance', 'completionattendanceenabled', 'notchecked'); |
202
|
|
|
|
203
|
|
|
// Elements for completion by Engagement. |
204
|
|
|
$engagement['grouplabel'] = get_string('completionengagementgroup', 'bigbluebuttonbn'); |
|
|
|
|
205
|
|
|
$engagement['chatlabel'] = get_string('completionengagementchats', 'bigbluebuttonbn'); |
206
|
|
|
$engagement['talklabel'] = get_string('completionengagementtalks', 'bigbluebuttonbn'); |
207
|
|
|
$engagement['raisehand'] = get_string('completionengagementraisehand', 'bigbluebuttonbn'); |
208
|
|
|
$engagement['pollvotes'] = get_string('completionengagementpollvotes', 'bigbluebuttonbn'); |
209
|
|
|
$engagement['emojis'] = get_string('completionengagementemojis', 'bigbluebuttonbn'); |
210
|
|
|
$engagement['group'] = [ |
211
|
|
|
$mform->createElement('advcheckbox', 'completionengagementchats', '', $engagement['chatlabel'] . ' '), |
212
|
|
|
$mform->createElement('advcheckbox', 'completionengagementtalks', '', $engagement['talklabel'] . ' '), |
213
|
|
|
$mform->createElement('advcheckbox', 'completionengagementraisehand', '', $engagement['raisehand'] . ' '), |
214
|
|
|
$mform->createElement('advcheckbox', 'completionengagementpollvotes', '', $engagement['pollvotes'] . ' '), |
215
|
|
|
$mform->createElement('advcheckbox', 'completionengagementemojis', '', $engagement['emojis'] . ' '), |
216
|
|
|
]; |
217
|
|
|
$mform->addGroup($engagement['group'], 'completionengagementgroup', $engagement['grouplabel'], [' '], false); |
218
|
|
|
$mform->addHelpButton('completionengagementgroup', 'completionengagementgroup', 'bigbluebuttonbn'); |
219
|
|
|
$mform->disabledIf('completionengagementgroup', 'completionview', 'notchecked'); |
220
|
|
|
|
221
|
|
|
return ['completionattendancegroup', 'completionengagementgroup']; |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* Called during validation to see whether some module-specific completion rules are selected. |
226
|
|
|
* |
227
|
|
|
* @param array $data Input data not yet validated. |
228
|
|
|
* @return bool True if one or more rules is enabled, false if none are. |
229
|
|
|
*/ |
230
|
|
|
public function completion_rule_enabled($data) { |
231
|
|
|
return (!empty($data['completionattendanceenabled']) && $data['completionattendance'] != 0); |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* Allows module to modify the data returned by form get_data(). |
236
|
|
|
* This method is also called in the bulk activity completion form. |
237
|
|
|
* |
238
|
|
|
* Only available on moodleform_mod. |
239
|
|
|
* |
240
|
|
|
* @param stdClass $data the form data to be modified. |
241
|
|
|
*/ |
242
|
|
|
public function data_postprocessing($data) { |
243
|
|
|
parent::data_postprocessing($data); |
244
|
|
|
// Turn off completion settings if the checkboxes aren't ticked. |
245
|
|
|
if (!empty($data->completionunlocked)) { |
246
|
|
|
$autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC; |
247
|
|
|
if (empty($data->completionattendanceenabled) || !$autocompletion) { |
248
|
|
|
$data->completionattendance = 0; |
249
|
|
|
} |
250
|
|
|
} |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
|
254
|
|
|
/** |
255
|
|
|
* Function for showing the block for selecting profiles. |
256
|
|
|
* |
257
|
|
|
* @param object $mform |
258
|
|
|
* @param array $profiles |
259
|
|
|
* @return void |
260
|
|
|
*/ |
261
|
|
|
private function bigbluebuttonbn_mform_add_block_profiles(&$mform, $profiles) { |
262
|
|
|
if ((boolean)\mod_bigbluebuttonbn\locallib\config::recordings_enabled()) { |
263
|
|
|
$mform->addElement('select', 'type', get_string('mod_form_field_instanceprofiles', 'bigbluebuttonbn'), |
264
|
|
|
bigbluebuttonbn_get_instance_profiles_array($profiles), |
265
|
|
|
array('onchange' => 'M.mod_bigbluebuttonbn.modform.updateInstanceTypeProfile(this);')); |
266
|
|
|
$mform->addHelpButton('type', 'mod_form_field_instanceprofiles', 'bigbluebuttonbn'); |
267
|
|
|
} |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
/** |
271
|
|
|
* Function for showing the block for general settings. |
272
|
|
|
* |
273
|
|
|
* @param object $mform |
274
|
|
|
* @param array $cfg |
275
|
|
|
* @return void |
276
|
|
|
*/ |
277
|
|
|
private function bigbluebuttonbn_mform_add_block_general(&$mform, $cfg) { |
278
|
|
|
global $CFG; |
279
|
|
|
$mform->addElement('header', 'general', get_string('mod_form_block_general', 'bigbluebuttonbn')); |
280
|
|
|
$mform->addElement('text', 'name', get_string('mod_form_field_name', 'bigbluebuttonbn'), |
281
|
|
|
'maxlength="64" size="32"'); |
282
|
|
|
$mform->setType('name', empty($CFG->formatstringstriptags) ? PARAM_CLEANHTML : PARAM_TEXT); |
283
|
|
|
$mform->addRule('name', null, 'required', null, 'client'); |
284
|
|
|
$this->standard_intro_elements(get_string('mod_form_field_intro', 'bigbluebuttonbn')); |
285
|
|
|
$mform->setAdvanced('introeditor'); |
286
|
|
|
$mform->setAdvanced('showdescription'); |
287
|
|
|
if ($cfg['sendnotifications_enabled']) { |
288
|
|
|
$field = ['type' => 'checkbox', 'name' => 'notification', 'data_type' => PARAM_INT, |
289
|
|
|
'description_key' => 'mod_form_field_notification']; |
290
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
291
|
|
|
$field['description_key'], 0); |
292
|
|
|
} |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
/** |
296
|
|
|
* Function for showing details of the room settings for the room. |
297
|
|
|
* |
298
|
|
|
* @param object $mform |
299
|
|
|
* @param array $cfg |
300
|
|
|
* @return void |
301
|
|
|
*/ |
302
|
|
|
private function bigbluebuttonbn_mform_add_block_room_room(&$mform, $cfg) { |
303
|
|
|
$field = ['type' => 'textarea', 'name' => 'welcome', 'data_type' => PARAM_CLEANHTML, |
304
|
|
|
'description_key' => 'mod_form_field_welcome']; |
305
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
306
|
|
|
$field['description_key'], $cfg['welcome_default'], ['wrap' => 'virtual', 'rows' => 5, 'cols' => '60']); |
307
|
|
|
$field = ['type' => 'hidden', 'name' => 'voicebridge', 'data_type' => PARAM_INT, |
308
|
|
|
'description_key' => null]; |
309
|
|
|
if ($cfg['voicebridge_editable']) { |
310
|
|
|
$field['type'] = 'text'; |
311
|
|
|
$field['data_type'] = PARAM_TEXT; |
312
|
|
|
$field['description_key'] = 'mod_form_field_voicebridge'; |
313
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
314
|
|
|
$field['description_key'], 0, ['maxlength' => 4, 'size' => 6], |
315
|
|
|
['message' => get_string('mod_form_field_voicebridge_format_error', 'bigbluebuttonbn'), |
316
|
|
|
'type' => 'numeric', 'rule' => '####', 'validator' => 'server'] |
317
|
|
|
); |
318
|
|
|
} else { |
319
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
320
|
|
|
$field['description_key'], 0, ['maxlength' => 4, 'size' => 6]); |
321
|
|
|
} |
322
|
|
|
$field = ['type' => 'hidden', 'name' => 'wait', 'data_type' => PARAM_INT, 'description_key' => null]; |
323
|
|
|
if ($cfg['waitformoderator_editable']) { |
324
|
|
|
$field['type'] = 'checkbox'; |
325
|
|
|
$field['description_key'] = 'mod_form_field_wait'; |
326
|
|
|
} |
327
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
328
|
|
|
$field['description_key'], $cfg['waitformoderator_default']); |
329
|
|
|
$field = ['type' => 'hidden', 'name' => 'userlimit', 'data_type' => PARAM_INT, 'description_key' => null]; |
330
|
|
|
if ($cfg['userlimit_editable']) { |
331
|
|
|
$field['type'] = 'text'; |
332
|
|
|
$field['data_type'] = PARAM_TEXT; |
333
|
|
|
$field['description_key'] = 'mod_form_field_userlimit'; |
334
|
|
|
} |
335
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
336
|
|
|
$field['description_key'], $cfg['userlimit_default']); |
337
|
|
|
$field = ['type' => 'hidden', 'name' => 'record', 'data_type' => PARAM_INT, 'description_key' => null]; |
338
|
|
|
if ($cfg['recording_editable']) { |
339
|
|
|
$field['type'] = 'checkbox'; |
340
|
|
|
$field['description_key'] = 'mod_form_field_record'; |
341
|
|
|
} |
342
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
343
|
|
|
$field['description_key'], $cfg['recording_default']); |
344
|
|
|
|
345
|
|
|
// Record all from start and hide button. |
346
|
|
|
$field = ['type' => 'hidden', 'name' => 'recordallfromstart', 'data_type' => PARAM_INT, 'description_key' => null]; |
347
|
|
|
if ($cfg['recording_all_from_start_editable']) { |
348
|
|
|
$field['type'] = 'checkbox'; |
349
|
|
|
$field['description_key'] = 'mod_form_field_recordallfromstart'; |
350
|
|
|
} |
351
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
352
|
|
|
$field['description_key'], $cfg['recording_all_from_start_default']); |
353
|
|
|
|
354
|
|
|
$field = ['type' => 'hidden', 'name' => 'recordhidebutton', 'data_type' => PARAM_INT, 'description_key' => null]; |
355
|
|
|
if ($cfg['recording_hide_button_editable']) { |
356
|
|
|
$field['type'] = 'checkbox'; |
357
|
|
|
$field['description_key'] = 'mod_form_field_recordhidebutton'; |
358
|
|
|
} |
359
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
360
|
|
|
$field['description_key'], $cfg['recording_hide_button_default']); |
361
|
|
|
|
362
|
|
|
$mform->disabledIf('recordallfromstart', 'record', $condition = 'notchecked', $value = '0'); |
363
|
|
|
$mform->disabledIf('recordhidebutton', 'record', $condition = 'notchecked', $value = '0'); |
364
|
|
|
$mform->disabledIf('recordhidebutton', 'recordallfromstart', $condition = 'notchecked', $value = '0'); |
365
|
|
|
// End Record all from start and hide button. |
366
|
|
|
|
367
|
|
|
$field = ['type' => 'hidden', 'name' => 'muteonstart', 'data_type' => PARAM_INT, 'description_key' => null]; |
368
|
|
|
if ($cfg['muteonstart_editable']) { |
369
|
|
|
$field['type'] = 'checkbox'; |
370
|
|
|
$field['description_key'] = 'mod_form_field_muteonstart'; |
371
|
|
|
} |
372
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
373
|
|
|
$field['description_key'], $cfg['muteonstart_default']); |
374
|
|
|
|
375
|
|
|
} |
376
|
|
|
|
377
|
|
|
/** |
378
|
|
|
* Function for showing details of the lock settings for the room. |
379
|
|
|
* |
380
|
|
|
* @param object $mform |
381
|
|
|
* @param array $cfg |
382
|
|
|
* @return void |
383
|
|
|
*/ |
384
|
|
|
private function bigbluebuttonbn_mform_add_block_locksettings(&$mform, $cfg) { |
385
|
|
|
$mform->addElement('header', 'lock', get_string('mod_form_locksettings', 'bigbluebuttonbn')); |
386
|
|
|
|
387
|
|
|
$locksettings = false; |
388
|
|
|
|
389
|
|
|
$field = ['type' => 'hidden', 'name' => 'disablecam', 'data_type' => PARAM_INT, 'description_key' => null]; |
390
|
|
|
if ($cfg['disablecam_editable']) { |
391
|
|
|
$field['type'] = 'checkbox'; |
392
|
|
|
$field['description_key'] = 'mod_form_field_disablecam'; |
393
|
|
|
$locksettings = true; |
394
|
|
|
} |
395
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
396
|
|
|
$field['description_key'], $cfg['disablecam_default']); |
397
|
|
|
|
398
|
|
|
$field = ['type' => 'hidden', 'name' => 'disablemic', 'data_type' => PARAM_INT, 'description_key' => null]; |
399
|
|
|
if ($cfg['disablemic_editable']) { |
400
|
|
|
$field['type'] = 'checkbox'; |
401
|
|
|
$field['description_key'] = 'mod_form_field_disablemic'; |
402
|
|
|
$locksettings = true; |
403
|
|
|
} |
404
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
405
|
|
|
$field['description_key'], $cfg['disablemic_default']); |
406
|
|
|
|
407
|
|
|
$field = ['type' => 'hidden', 'name' => 'disableprivatechat', 'data_type' => PARAM_INT, 'description_key' => null]; |
408
|
|
|
if ($cfg['disableprivatechat_editable']) { |
409
|
|
|
$field['type'] = 'checkbox'; |
410
|
|
|
$field['description_key'] = 'mod_form_field_disableprivatechat'; |
411
|
|
|
$locksettings = true; |
412
|
|
|
} |
413
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
414
|
|
|
$field['description_key'], $cfg['disableprivatechat_default']); |
415
|
|
|
|
416
|
|
|
$field = ['type' => 'hidden', 'name' => 'disablepublicchat', 'data_type' => PARAM_INT, 'description_key' => null]; |
417
|
|
|
if ($cfg['disablepublicchat_editable']) { |
418
|
|
|
$field['type'] = 'checkbox'; |
419
|
|
|
$field['description_key'] = 'mod_form_field_disablepublicchat'; |
420
|
|
|
$locksettings = true; |
421
|
|
|
} |
422
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
423
|
|
|
$field['description_key'], $cfg['disablepublicchat_default']); |
424
|
|
|
|
425
|
|
|
$field = ['type' => 'hidden', 'name' => 'disablenote', 'data_type' => PARAM_INT, 'description_key' => null]; |
426
|
|
|
if ($cfg['disablenote_editable']) { |
427
|
|
|
$field['type'] = 'checkbox'; |
428
|
|
|
$field['description_key'] = 'mod_form_field_disablenote'; |
429
|
|
|
$locksettings = true; |
430
|
|
|
} |
431
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
432
|
|
|
$field['description_key'], $cfg['disablenote_default']); |
433
|
|
|
|
434
|
|
|
$field = ['type' => 'hidden', 'name' => 'hideuserlist', 'data_type' => PARAM_INT, 'description_key' => null]; |
435
|
|
|
if ($cfg['hideuserlist_editable']) { |
436
|
|
|
$field['type'] = 'checkbox'; |
437
|
|
|
$field['description_key'] = 'mod_form_field_hideuserlist'; |
438
|
|
|
$locksettings = true; |
439
|
|
|
} |
440
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
441
|
|
|
$field['description_key'], $cfg['hideuserlist_default']); |
442
|
|
|
|
443
|
|
|
$field = ['type' => 'hidden', 'name' => 'lockedlayout', 'data_type' => PARAM_INT, 'description_key' => null]; |
444
|
|
|
if ($cfg['lockedlayout_editable']) { |
445
|
|
|
$field['type'] = 'checkbox'; |
446
|
|
|
$field['description_key'] = 'mod_form_field_lockedlayout'; |
447
|
|
|
$locksettings = true; |
448
|
|
|
} |
449
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
450
|
|
|
$field['description_key'], $cfg['lockedlayout_default']); |
451
|
|
|
|
452
|
|
|
$field = ['type' => 'hidden', 'name' => 'lockonjoin', 'data_type' => PARAM_INT, 'description_key' => null]; |
453
|
|
|
if ($cfg['lockonjoin_editable']) { |
454
|
|
|
$field['type'] = 'checkbox'; |
455
|
|
|
$field['description_key'] = 'mod_form_field_lockonjoin'; |
456
|
|
|
$locksettings = true; |
457
|
|
|
} |
458
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
459
|
|
|
$field['description_key'], $cfg['lockonjoin_default']); |
460
|
|
|
|
461
|
|
|
$field = ['type' => 'hidden', 'name' => 'lockonjoinconfigurable', 'data_type' => PARAM_INT, 'description_key' => null]; |
462
|
|
|
if ($cfg['lockonjoinconfigurable_editable']) { |
463
|
|
|
$field['type'] = 'checkbox'; |
464
|
|
|
$field['description_key'] = 'mod_form_field_lockonjoinconfigurable'; |
465
|
|
|
$locksettings = true; |
466
|
|
|
} |
467
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
468
|
|
|
$field['description_key'], $cfg['lockonjoinconfigurable_default']); |
469
|
|
|
|
470
|
|
|
// Output message if no settings. |
471
|
|
View Code Duplication |
if (!$locksettings) { |
|
|
|
|
472
|
|
|
$field = ['type' => 'static', 'name' => 'no_locksettings', |
473
|
|
|
'defaultvalue' => get_string('mod_form_field_nosettings', 'bigbluebuttonbn')]; |
474
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], null, null, |
475
|
|
|
$field['defaultvalue']); |
476
|
|
|
} |
477
|
|
|
} |
478
|
|
|
|
479
|
|
|
/** |
480
|
|
|
* Function for showing details of the recording settings for the room. |
481
|
|
|
* |
482
|
|
|
* @param object $mform |
483
|
|
|
* @param array $cfg |
484
|
|
|
* @return void |
485
|
|
|
*/ |
486
|
|
|
private function bigbluebuttonbn_mform_add_block_room_recordings(&$mform, $cfg) { |
487
|
|
|
$recordingsettings = false; |
488
|
|
|
$field = ['type' => 'hidden', 'name' => 'recordings_html', 'data_type' => PARAM_INT, |
489
|
|
|
'description_key' => null]; |
490
|
|
|
if ($cfg['recordings_html_editable']) { |
491
|
|
|
$field['type'] = 'checkbox'; |
492
|
|
|
$field['description_key'] = 'mod_form_field_recordings_html'; |
493
|
|
|
$recordingsettings = true; |
494
|
|
|
} |
495
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
496
|
|
|
$field['description_key'], $cfg['recordings_html_default']); |
497
|
|
|
$field = ['type' => 'hidden', 'name' => 'recordings_deleted', 'data_type' => PARAM_INT, |
498
|
|
|
'description_key' => null]; |
499
|
|
|
if ($cfg['recordings_deleted_editable']) { |
500
|
|
|
$field['type'] = 'checkbox'; |
501
|
|
|
$field['description_key'] = 'mod_form_field_recordings_deleted'; |
502
|
|
|
$recordingsettings = true; |
503
|
|
|
} |
504
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
505
|
|
|
$field['description_key'], $cfg['recordings_deleted_default']); |
506
|
|
|
$field = ['type' => 'hidden', 'name' => 'recordings_imported', 'data_type' => PARAM_INT, |
507
|
|
|
'description_key' => null]; |
508
|
|
|
if ($cfg['importrecordings_enabled'] && $cfg['recordings_imported_editable']) { |
509
|
|
|
$field['type'] = 'checkbox'; |
510
|
|
|
$field['description_key'] = 'mod_form_field_recordings_imported'; |
511
|
|
|
$recordingsettings = true; |
512
|
|
|
} |
513
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
514
|
|
|
$field['description_key'], $cfg['recordings_imported_default']); |
515
|
|
|
$field = ['type' => 'hidden', 'name' => 'recordings_preview', 'data_type' => PARAM_INT, |
516
|
|
|
'description_key' => null]; |
517
|
|
|
if ($cfg['recordings_preview_editable']) { |
518
|
|
|
$field['type'] = 'checkbox'; |
519
|
|
|
$field['description_key'] = 'mod_form_field_recordings_preview'; |
520
|
|
|
$recordingsettings = true; |
521
|
|
|
} |
522
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
523
|
|
|
$field['description_key'], $cfg['recordings_preview_default']); |
524
|
|
|
|
525
|
|
View Code Duplication |
if (!$recordingsettings) { |
|
|
|
|
526
|
|
|
$field = ['type' => 'static', 'name' => 'no_recordings', |
527
|
|
|
'defaultvalue' => get_string('mod_form_field_nosettings', 'bigbluebuttonbn')]; |
528
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], null, null, |
529
|
|
|
$field['defaultvalue']); |
530
|
|
|
} |
531
|
|
|
} |
532
|
|
|
|
533
|
|
|
/** |
534
|
|
|
* Function for showing the block for room settings. |
535
|
|
|
* |
536
|
|
|
* @param object $mform |
537
|
|
|
* @param array $cfg |
538
|
|
|
* @return void |
539
|
|
|
*/ |
540
|
|
|
private function bigbluebuttonbn_mform_add_block_room(&$mform, $cfg) { |
541
|
|
|
if ($cfg['voicebridge_editable'] || $cfg['waitformoderator_editable'] || |
542
|
|
|
$cfg['userlimit_editable'] || $cfg['recording_editable']) { |
543
|
|
|
$mform->addElement('header', 'room', get_string('mod_form_block_room', 'bigbluebuttonbn')); |
544
|
|
|
$this->bigbluebuttonbn_mform_add_block_room_room($mform, $cfg); |
545
|
|
|
} |
546
|
|
|
if ($cfg['recordings_html_editable'] || $cfg['recordings_deleted_editable'] || |
547
|
|
|
$cfg['recordings_imported_editable'] || $cfg['recordings_preview_editable']) { |
548
|
|
|
$mform->addElement('header', 'recordings', get_string('mod_form_block_recordings', 'bigbluebuttonbn')); |
549
|
|
|
$this->bigbluebuttonbn_mform_add_block_room_recordings($mform, $cfg); |
550
|
|
|
} |
551
|
|
|
} |
552
|
|
|
|
553
|
|
|
/** |
554
|
|
|
* Function for showing the block for preuploaded presentation. |
555
|
|
|
* |
556
|
|
|
* @param object $mform |
557
|
|
|
* @param array $cfg |
558
|
|
|
* @return void |
559
|
|
|
*/ |
560
|
|
|
private function bigbluebuttonbn_mform_add_block_preuploads(&$mform, $cfg) { |
561
|
|
|
if ($cfg['preuploadpresentation_enabled']) { |
562
|
|
|
$mform->addElement('header', 'preuploadpresentation', |
563
|
|
|
get_string('mod_form_block_presentation', 'bigbluebuttonbn')); |
564
|
|
|
$mform->setExpanded('preuploadpresentation'); |
565
|
|
|
$filemanageroptions = array(); |
566
|
|
|
$filemanageroptions['accepted_types'] = '*'; |
567
|
|
|
$filemanageroptions['maxbytes'] = 0; |
568
|
|
|
$filemanageroptions['subdirs'] = 0; |
569
|
|
|
$filemanageroptions['maxfiles'] = 1; |
570
|
|
|
$filemanageroptions['mainfile'] = true; |
571
|
|
|
$mform->addElement('filemanager', 'presentation', get_string('selectfiles'), |
572
|
|
|
null, $filemanageroptions); |
573
|
|
|
} |
574
|
|
|
} |
575
|
|
|
|
576
|
|
|
/** |
577
|
|
|
* Function for showing the block for setting participant roles. |
578
|
|
|
* |
579
|
|
|
* @param object $mform |
580
|
|
|
* @param string $participantlist |
581
|
|
|
* @return void |
582
|
|
|
*/ |
583
|
|
|
private function bigbluebuttonbn_mform_add_block_user_role_mapping(&$mform, $participantlist) { |
584
|
|
|
$participantselection = bigbluebuttonbn_get_participant_selection_data(); |
585
|
|
|
$mform->addElement('header', 'permissions', get_string('mod_form_block_participants', 'bigbluebuttonbn')); |
586
|
|
|
$mform->setExpanded('permissions'); |
587
|
|
|
$mform->addElement('hidden', 'participants', json_encode($participantlist)); |
588
|
|
|
$mform->setType('participants', PARAM_TEXT); |
589
|
|
|
// Render elements for participant selection. |
590
|
|
|
$htmlselectiontype = html_writer::select($participantselection['type_options'], |
591
|
|
|
'bigbluebuttonbn_participant_selection_type', $participantselection['type_selected'], array(), |
592
|
|
|
array('id' => 'bigbluebuttonbn_participant_selection_type', |
593
|
|
|
'onchange' => 'M.mod_bigbluebuttonbn.modform.participantSelectionSet(); return 0;')); |
594
|
|
|
$htmlselectionoptions = html_writer::select($participantselection['options'], 'bigbluebuttonbn_participant_selection', |
595
|
|
|
$participantselection['selected'], array(), |
596
|
|
|
array('id' => 'bigbluebuttonbn_participant_selection', 'disabled' => 'disabled')); |
597
|
|
|
$htmlselectioninput = html_writer::tag('input', '', array('id' => 'id_addselectionid', |
598
|
|
|
'type' => 'button', 'class' => 'btn btn-secondary', |
599
|
|
|
'value' => get_string('mod_form_field_participant_list_action_add', 'bigbluebuttonbn'), |
600
|
|
|
'onclick' => 'M.mod_bigbluebuttonbn.modform.participantAdd(); return 0;' |
601
|
|
|
)); |
602
|
|
|
$htmladdparticipant = html_writer::tag('div', |
603
|
|
|
$htmlselectiontype . ' ' . $htmlselectionoptions . ' ' . $htmlselectioninput, null); |
604
|
|
|
$mform->addElement('html', "\n\n"); |
605
|
|
|
$mform->addElement('static', 'static_add_participant', |
606
|
|
|
get_string('mod_form_field_participant_add', 'bigbluebuttonbn'), $htmladdparticipant); |
607
|
|
|
$mform->addElement('html', "\n\n"); |
608
|
|
|
// Declare the table. |
609
|
|
|
$htmltable = new html_table(); |
610
|
|
|
$htmltable->align = array('left', 'left', 'left', 'left'); |
611
|
|
|
$htmltable->id = 'participant_list_table'; |
612
|
|
|
$htmltable->data = array(array()); |
613
|
|
|
// Render elements for participant list. |
614
|
|
|
$htmlparticipantlist = html_writer::table($htmltable); |
615
|
|
|
$mform->addElement('html', "\n\n"); |
616
|
|
|
$mform->addElement('static', 'static_participant_list', |
617
|
|
|
get_string('mod_form_field_participant_list', 'bigbluebuttonbn'), $htmlparticipantlist); |
618
|
|
|
$mform->addElement('html', "\n\n"); |
619
|
|
|
} |
620
|
|
|
|
621
|
|
|
/** |
622
|
|
|
* Function for showing the client type |
623
|
|
|
* |
624
|
|
|
* @param object $mform |
625
|
|
|
* @param object $cfg |
626
|
|
|
* @return void |
627
|
|
|
*/ |
628
|
|
|
private function bigbluebuttonbn_mform_add_block_clienttype(&$mform, &$cfg) { |
629
|
|
|
// Validates if clienttype capability is enabled. |
630
|
|
|
if (!$cfg['clienttype_enabled']) { |
631
|
|
|
return; |
632
|
|
|
} |
633
|
|
|
// Validates if the html5client is supported by the BigBlueButton Server. |
634
|
|
|
if (!bigbluebuttonbn_has_html5_client()) { |
635
|
|
|
return; |
636
|
|
|
} |
637
|
|
|
$field = ['type' => 'hidden', 'name' => 'clienttype', 'data_type' => PARAM_INT, |
638
|
|
|
'description_key' => null]; |
639
|
|
|
if ($cfg['clienttype_editable']) { |
640
|
|
|
$field['type'] = 'select'; |
641
|
|
|
$field['data_type'] = PARAM_TEXT; |
642
|
|
|
$field['description_key'] = 'mod_form_field_block_clienttype'; |
643
|
|
|
$choices = array(BIGBLUEBUTTON_CLIENTTYPE_FLASH => get_string('mod_form_block_clienttype_flash', 'bigbluebuttonbn'), |
644
|
|
|
BIGBLUEBUTTON_CLIENTTYPE_HTML5 => get_string('mod_form_block_clienttype_html5', 'bigbluebuttonbn')); |
645
|
|
|
$mform->addElement('header', 'clienttypeselection', get_string('mod_form_block_clienttype', 'bigbluebuttonbn')); |
646
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
647
|
|
|
$field['description_key'], $cfg['clienttype_default'], $choices); |
648
|
|
|
return; |
649
|
|
|
} |
650
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
651
|
|
|
null, $cfg['clienttype_default']); |
652
|
|
|
} |
653
|
|
|
|
654
|
|
|
/** |
655
|
|
|
* Function for showing the block for integration with the calendar. |
656
|
|
|
* |
657
|
|
|
* @param object $mform |
658
|
|
|
* @param object $activity |
659
|
|
|
* @return void |
660
|
|
|
*/ |
661
|
|
|
private function bigbluebuttonbn_mform_add_block_schedule(&$mform, &$activity) { |
662
|
|
|
$mform->addElement('header', 'schedule', get_string('mod_form_block_schedule', 'bigbluebuttonbn')); |
663
|
|
|
if (isset($activity->openingtime) && $activity->openingtime != 0 || |
664
|
|
|
isset($activity->closingtime) && $activity->closingtime != 0) { |
665
|
|
|
$mform->setExpanded('schedule'); |
666
|
|
|
} |
667
|
|
|
$mform->addElement('date_time_selector', 'openingtime', |
668
|
|
|
get_string('mod_form_field_openingtime', 'bigbluebuttonbn'), array('optional' => true)); |
669
|
|
|
$mform->setDefault('openingtime', 0); |
670
|
|
|
$mform->addElement('date_time_selector', 'closingtime', |
671
|
|
|
get_string('mod_form_field_closingtime', 'bigbluebuttonbn'), array('optional' => true)); |
672
|
|
|
$mform->setDefault('closingtime', 0); |
673
|
|
|
} |
674
|
|
|
|
675
|
|
|
/** |
676
|
|
|
* Function for showing an element. |
677
|
|
|
* |
678
|
|
|
* @param object $mform |
679
|
|
|
* @param string $type |
680
|
|
|
* @param string $name |
681
|
|
|
* @param string $datatype |
682
|
|
|
* @param string $descriptionkey |
683
|
|
|
* @param string $defaultvalue |
684
|
|
|
* @param array $options |
685
|
|
|
* @param string $rule |
686
|
|
|
* @return void |
687
|
|
|
*/ |
688
|
|
|
private function bigbluebuttonbn_mform_add_element(&$mform, $type, $name, $datatype, |
689
|
|
|
$descriptionkey, $defaultvalue = null, $options = null, $rule = null) { |
690
|
|
|
if ($type === 'hidden' || $type === 'static') { |
691
|
|
|
$mform->addElement($type, $name, $defaultvalue); |
692
|
|
|
$mform->setType($name, $datatype); |
693
|
|
|
return; |
694
|
|
|
} |
695
|
|
|
$mform->addElement($type, $name, get_string($descriptionkey, 'bigbluebuttonbn'), $options); |
696
|
|
|
if (get_string_manager()->string_exists($descriptionkey.'_help', 'bigbluebuttonbn')) { |
697
|
|
|
$mform->addHelpButton($name, $descriptionkey, 'bigbluebuttonbn'); |
698
|
|
|
} |
699
|
|
|
if (!empty($rule)) { |
700
|
|
|
$mform->addRule($name, $rule['message'], $rule['type'], $rule['rule'], $rule['validator']); |
701
|
|
|
} |
702
|
|
|
$mform->setDefault($name, $defaultvalue); |
703
|
|
|
$mform->setType($name, $datatype); |
704
|
|
|
} |
705
|
|
|
} |
706
|
|
|
|
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArray
is initialized the first time when the foreach loop is entered. You can also see that the value of thebar
key is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.