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
|
|
|
// Validates if the BigBlueButton server is running. |
48
|
|
|
$serverversion = bigbluebuttonbn_get_server_version(); |
49
|
|
|
if (is_null($serverversion)) { |
50
|
|
|
print_error('general_error_unable_connect', 'bigbluebuttonbn', |
51
|
|
|
$CFG->wwwroot.'/admin/settings.php?section=modsettingbigbluebuttonbn'); |
52
|
|
|
return; |
53
|
|
|
} |
54
|
|
|
// Context. |
55
|
|
|
$bigbluebuttonbn = null; |
56
|
|
|
$course = null; |
57
|
|
|
$courseid = optional_param('course', 0, PARAM_INT); |
58
|
|
|
if ($courseid) { |
59
|
|
|
$course = get_course($courseid); |
60
|
|
|
} |
61
|
|
|
if (!$course) { |
62
|
|
|
$cm = get_coursemodule_from_id('bigbluebuttonbn', |
63
|
|
|
optional_param('update', 0, PARAM_INT), 0, false, MUST_EXIST); |
64
|
|
|
$course = $DB->get_record('course', array('id' => $cm->course), |
65
|
|
|
'*', MUST_EXIST); |
66
|
|
|
$bigbluebuttonbn = $DB->get_record('bigbluebuttonbn', |
67
|
|
|
array('id' => $cm->instance), '*', MUST_EXIST); |
68
|
|
|
} |
69
|
|
|
$context = context_course::instance($course->id); |
70
|
|
|
// UI configuration options. |
71
|
|
|
$cfg = \mod_bigbluebuttonbn\locallib\config::get_options(); |
72
|
|
|
$mform = &$this->_form; |
73
|
|
|
$jsvars = array(); |
74
|
|
|
// Get only those that are allowed. |
75
|
|
|
$createroom = has_capability('mod/bigbluebuttonbn:meeting', $context); |
76
|
|
|
$createrecording = has_capability('mod/bigbluebuttonbn:recording', $context); |
77
|
|
|
$jsvars['instanceTypeProfiles'] = bigbluebuttonbn_get_instance_type_profiles_create_allowed( |
78
|
|
|
$createroom, $createrecording); |
79
|
|
|
$jsvars['instanceTypeDefault'] = array_keys($jsvars['instanceTypeProfiles'])[0]; |
80
|
|
|
// If 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
|
|
|
$this->bigbluebuttonbn_mform_add_block_profiles($mform, $jsvars['instanceTypeProfiles']); |
87
|
|
|
// Data for participant selection. |
88
|
|
|
$participantlist = bigbluebuttonbn_get_participant_list($bigbluebuttonbn, $context); |
89
|
|
|
// Add block 'General'. |
90
|
|
|
$this->bigbluebuttonbn_mform_add_block_general($mform, $cfg); |
91
|
|
|
// Add block 'Room'. |
92
|
|
|
$this->bigbluebuttonbn_mform_add_block_room($mform, $cfg); |
93
|
|
|
// Add block 'Preuploads'. |
94
|
|
|
$this->bigbluebuttonbn_mform_add_block_preuploads($mform, $cfg); |
95
|
|
|
// Add block 'Participant List'. |
96
|
|
|
$this->bigbluebuttonbn_mform_add_block_participants($mform, $participantlist); |
97
|
|
|
// Add block 'Schedule'. |
98
|
|
|
$this->bigbluebuttonbn_mform_add_block_schedule($mform, $this->current); |
99
|
|
|
// Add block 'client Type'. |
100
|
|
|
$this->bigbluebuttonbn_mform_add_block_clienttype($mform, $cfg); |
101
|
|
|
// Add standard elements, common to all modules. |
102
|
|
|
$this->standard_coursemodule_elements(); |
103
|
|
|
// Add standard buttons, common to all modules. |
104
|
|
|
$this->add_action_buttons(); |
105
|
|
|
// JavaScript for locales. |
106
|
|
|
$PAGE->requires->strings_for_js(array_keys(bigbluebuttonbn_get_strings_for_js()), 'bigbluebuttonbn'); |
107
|
|
|
$jsvars['participantData'] = bigbluebuttonbn_get_participant_data($context); |
108
|
|
|
$jsvars['participantList'] = $participantlist; |
109
|
|
|
$jsvars['iconsEnabled'] = (boolean)$cfg['recording_icons_enabled']; |
110
|
|
|
$jsvars['pixIconDelete'] = (string)$OUTPUT->pix_icon('t/delete', get_string('delete'), 'moodle'); |
111
|
|
|
$PAGE->requires->yui_module('moodle-mod_bigbluebuttonbn-modform', |
112
|
|
|
'M.mod_bigbluebuttonbn.modform.init', array($jsvars)); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Prepare the attachment for being stored. |
117
|
|
|
* |
118
|
|
|
* @param array $defaultvalues |
119
|
|
|
* @return void |
120
|
|
|
*/ |
121
|
|
|
public function data_preprocessing(&$defaultvalues) { |
122
|
|
|
if ($this->current->instance) { |
123
|
|
|
// Editing existing instance - copy existing files into draft area. |
124
|
|
|
try { |
125
|
|
|
$draftitemid = file_get_submitted_draft_itemid('presentation'); |
126
|
|
|
file_prepare_draft_area($draftitemid, $this->context->id, 'mod_bigbluebuttonbn', 'presentation', 0, |
127
|
|
|
array('subdirs' => 0, 'maxbytes' => 0, 'maxfiles' => 1, 'mainfile' => true) |
128
|
|
|
); |
129
|
|
|
$defaultvalues['presentation'] = $draftitemid; |
130
|
|
|
} catch (Exception $e) { |
131
|
|
|
debugging('Presentation could not be loaded: '.$e->getMessage(), DEBUG_DEVELOPER); |
132
|
|
|
return; |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Validates the data processed by the form. |
139
|
|
|
* |
140
|
|
|
* @param array $data |
141
|
|
|
* @param array $files |
142
|
|
|
* @return void |
143
|
|
|
*/ |
144
|
|
|
public function validation($data, $files) { |
145
|
|
|
$errors = parent::validation($data, $files); |
146
|
|
|
if (isset($data['openingtime']) && isset($data['closingtime'])) { |
147
|
|
|
if ($data['openingtime'] != 0 && $data['closingtime'] != 0 && |
148
|
|
|
$data['closingtime'] < $data['openingtime']) { |
149
|
|
|
$errors['closingtime'] = get_string('bbbduetimeoverstartingtime', 'bigbluebuttonbn'); |
150
|
|
|
} |
151
|
|
|
} |
152
|
|
|
if (isset($data['voicebridge'])) { |
153
|
|
|
if (!bigbluebuttonbn_voicebridge_unique($data['instance'], $data['voicebridge'])) { |
154
|
|
|
$errors['voicebridge'] = get_string('mod_form_field_voicebridge_notunique_error', 'bigbluebuttonbn'); |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
return $errors; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Function for showing the block for selecting profiles. |
162
|
|
|
* |
163
|
|
|
* @param object $mform |
164
|
|
|
* @param array $profiles |
165
|
|
|
* @return void |
166
|
|
|
*/ |
167
|
|
|
private function bigbluebuttonbn_mform_add_block_profiles(&$mform, $profiles) { |
168
|
|
|
if ((boolean)\mod_bigbluebuttonbn\locallib\config::recordings_enabled()) { |
169
|
|
|
$mform->addElement('select', 'type', get_string('mod_form_field_instanceprofiles', 'bigbluebuttonbn'), |
170
|
|
|
bigbluebuttonbn_get_instance_profiles_array($profiles), |
171
|
|
|
array('onchange' => 'M.mod_bigbluebuttonbn.modform.updateInstanceTypeProfile(this);')); |
172
|
|
|
$mform->addHelpButton('type', 'mod_form_field_instanceprofiles', 'bigbluebuttonbn'); |
173
|
|
|
} |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* Function for showing the block for general settings. |
178
|
|
|
* |
179
|
|
|
* @param object $mform |
180
|
|
|
* @param array $cfg |
181
|
|
|
* @return void |
182
|
|
|
*/ |
183
|
|
|
private function bigbluebuttonbn_mform_add_block_general(&$mform, $cfg) { |
184
|
|
|
global $CFG; |
185
|
|
|
$mform->addElement('header', 'general', get_string('mod_form_block_general', 'bigbluebuttonbn')); |
186
|
|
|
$mform->addElement('text', 'name', get_string('mod_form_field_name', 'bigbluebuttonbn'), |
187
|
|
|
'maxlength="64" size="32"'); |
188
|
|
|
$mform->setType('name', empty($CFG->formatstringstriptags) ? PARAM_CLEANHTML : PARAM_TEXT); |
189
|
|
|
$mform->addRule('name', null, 'required', null, 'client'); |
190
|
|
|
$this->standard_intro_elements(get_string('mod_form_field_intro', 'bigbluebuttonbn')); |
191
|
|
|
$mform->setAdvanced('introeditor'); |
192
|
|
|
$mform->setAdvanced('showdescription'); |
193
|
|
|
if ($cfg['sendnotifications_enabled']) { |
194
|
|
|
$field = ['type' => 'checkbox', 'name' => 'notification', 'data_type' => PARAM_INT, |
195
|
|
|
'description_key' => 'mod_form_field_notification']; |
196
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
197
|
|
|
$field['description_key'], 0); |
198
|
|
|
} |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* Function for showing details of the room settings for the room. |
203
|
|
|
* |
204
|
|
|
* @param object $mform |
205
|
|
|
* @param array $cfg |
206
|
|
|
* @return void |
207
|
|
|
*/ |
208
|
|
|
private function bigbluebuttonbn_mform_add_block_room_room(&$mform, $cfg) { |
209
|
|
|
$field = ['type' => 'textarea', 'name' => 'welcome', 'data_type' => PARAM_TEXT, |
210
|
|
|
'description_key' => 'mod_form_field_welcome']; |
211
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
212
|
|
|
$field['description_key'], '', ['wrap' => 'virtual', 'rows' => 5, 'cols' => '60']); |
213
|
|
|
$field = ['type' => 'hidden', 'name' => 'voicebridge', 'data_type' => PARAM_INT, |
214
|
|
|
'description_key' => null]; |
215
|
|
|
if ($cfg['voicebridge_editable']) { |
216
|
|
|
$field['type'] = 'text'; |
217
|
|
|
$field['data_type'] = PARAM_TEXT; |
218
|
|
|
$field['description_key'] = 'mod_form_field_voicebridge'; |
219
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
220
|
|
|
$field['description_key'], 0, ['maxlength' => 4, 'size' => 6], |
221
|
|
|
['message' => get_string('mod_form_field_voicebridge_format_error', 'bigbluebuttonbn'), |
222
|
|
|
'type' => 'numeric', 'rule' => '####', 'validator' => 'server'] |
223
|
|
|
); |
224
|
|
|
} else { |
225
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
226
|
|
|
$field['description_key'], 0, ['maxlength' => 4, 'size' => 6]); |
227
|
|
|
} |
228
|
|
|
$field = ['type' => 'hidden', 'name' => 'wait', 'data_type' => PARAM_INT, 'description_key' => null]; |
229
|
|
|
if ($cfg['waitformoderator_editable']) { |
230
|
|
|
$field['type'] = 'checkbox'; |
231
|
|
|
$field['description_key'] = 'mod_form_field_wait'; |
232
|
|
|
} |
233
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
234
|
|
|
$field['description_key'], $cfg['waitformoderator_default']); |
235
|
|
|
$field = ['type' => 'hidden', 'name' => 'userlimit', 'data_type' => PARAM_INT, 'description_key' => null]; |
236
|
|
|
if ($cfg['userlimit_editable']) { |
237
|
|
|
$field['type'] = 'text'; |
238
|
|
|
$field['data_type'] = PARAM_TEXT; |
239
|
|
|
$field['description_key'] = 'mod_form_field_userlimit'; |
240
|
|
|
} |
241
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
242
|
|
|
$field['description_key'], $cfg['userlimit_default']); |
243
|
|
|
$field = ['type' => 'hidden', 'name' => 'record', 'data_type' => PARAM_INT, 'description_key' => null]; |
244
|
|
|
if ($cfg['recording_editable']) { |
245
|
|
|
$field['type'] = 'checkbox'; |
246
|
|
|
$field['description_key'] = 'mod_form_field_record'; |
247
|
|
|
} |
248
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
249
|
|
|
$field['description_key'], $cfg['recording_default']); |
250
|
|
|
|
251
|
|
|
// Record all from start and hide button. |
252
|
|
|
$field = ['type' => 'hidden', 'name' => 'recordallfromstart', 'data_type' => PARAM_INT, 'description_key' => null]; |
253
|
|
|
if ($cfg['recording_all_from_start_editable']) { |
254
|
|
|
$field['type'] = 'checkbox'; |
255
|
|
|
$field['description_key'] = 'mod_form_field_recordallfromstart'; |
256
|
|
|
} |
257
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
258
|
|
|
$field['description_key'], $cfg['recording_all_from_start_default']); |
259
|
|
|
|
260
|
|
|
$field = ['type' => 'hidden', 'name' => 'recordhidebutton', 'data_type' => PARAM_INT, 'description_key' => null]; |
261
|
|
|
if ($cfg['recording_hide_button_editable']) { |
262
|
|
|
$field['type'] = 'checkbox'; |
263
|
|
|
$field['description_key'] = 'mod_form_field_recordhidebutton'; |
264
|
|
|
} |
265
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
266
|
|
|
$field['description_key'], $cfg['recording_hide_button_default']); |
267
|
|
|
|
268
|
|
|
$mform->disabledIf('recordallfromstart', 'record', $condition = 'notchecked', $value = '0'); |
269
|
|
|
$mform->disabledIf('recordhidebutton', 'record', $condition = 'notchecked', $value = '0'); |
270
|
|
|
$mform->disabledIf('recordhidebutton', 'recordallfromstart', $condition = 'notchecked', $value = '0'); |
271
|
|
|
// End Record all from start and hide button. |
272
|
|
|
|
273
|
|
|
$field = ['type' => 'hidden', 'name' => 'muteonstart', 'data_type' => PARAM_INT, 'description_key' => null]; |
274
|
|
|
if ($cfg['muteonstart_editable']) { |
275
|
|
|
$field['type'] = 'checkbox'; |
276
|
|
|
$field['description_key'] = 'mod_form_field_muteonstart'; |
277
|
|
|
} |
278
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
279
|
|
|
$field['description_key'], $cfg['muteonstart_default']); |
280
|
|
|
|
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* Function for showing details of the recording settings for the room. |
285
|
|
|
* |
286
|
|
|
* @param object $mform |
287
|
|
|
* @param array $cfg |
288
|
|
|
* @return void |
289
|
|
|
*/ |
290
|
|
|
private function bigbluebuttonbn_mform_add_block_room_recordings(&$mform, $cfg) { |
291
|
|
|
$field = ['type' => 'hidden', 'name' => 'recordings_html', 'data_type' => PARAM_INT, |
292
|
|
|
'description_key' => null]; |
293
|
|
|
if ($cfg['recordings_html_editable']) { |
294
|
|
|
$field['type'] = 'checkbox'; |
295
|
|
|
$field['description_key'] = 'mod_form_field_recordings_html'; |
296
|
|
|
} |
297
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
298
|
|
|
$field['description_key'], $cfg['recordings_html_default']); |
299
|
|
|
$field = ['type' => 'hidden', 'name' => 'recordings_deleted', 'data_type' => PARAM_INT, |
300
|
|
|
'description_key' => null]; |
301
|
|
|
if ($cfg['recordings_deleted_editable']) { |
302
|
|
|
$field['type'] = 'checkbox'; |
303
|
|
|
$field['description_key'] = 'mod_form_field_recordings_deleted'; |
304
|
|
|
} |
305
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
306
|
|
|
$field['description_key'], $cfg['recordings_deleted_default']); |
307
|
|
|
$field = ['type' => 'hidden', 'name' => 'recordings_imported', 'data_type' => PARAM_INT, |
308
|
|
|
'description_key' => null]; |
309
|
|
|
if ($cfg['importrecordings_enabled'] && $cfg['recordings_imported_editable']) { |
310
|
|
|
$field['type'] = 'checkbox'; |
311
|
|
|
$field['description_key'] = 'mod_form_field_recordings_imported'; |
312
|
|
|
} |
313
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
314
|
|
|
$field['description_key'], $cfg['recordings_imported_default']); |
315
|
|
|
$field = ['type' => 'hidden', 'name' => 'recordings_preview', 'data_type' => PARAM_INT, |
316
|
|
|
'description_key' => null]; |
317
|
|
|
if ($cfg['recordings_preview_editable']) { |
318
|
|
|
$field['type'] = 'checkbox'; |
319
|
|
|
$field['description_key'] = 'mod_form_field_recordings_preview'; |
320
|
|
|
} |
321
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
322
|
|
|
$field['description_key'], $cfg['recordings_preview_default']); |
323
|
|
|
|
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
/** |
327
|
|
|
* Function for showing the block for room settings. |
328
|
|
|
* |
329
|
|
|
* @param object $mform |
330
|
|
|
* @param array $cfg |
331
|
|
|
* @return void |
332
|
|
|
*/ |
333
|
|
|
private function bigbluebuttonbn_mform_add_block_room(&$mform, $cfg) { |
334
|
|
|
if ($cfg['voicebridge_editable'] || $cfg['waitformoderator_editable'] || |
335
|
|
|
$cfg['userlimit_editable'] || $cfg['recording_editable']) { |
336
|
|
|
$mform->addElement('header', 'room', get_string('mod_form_block_room', 'bigbluebuttonbn')); |
337
|
|
|
$this->bigbluebuttonbn_mform_add_block_room_room($mform, $cfg); |
338
|
|
|
} |
339
|
|
|
if ($cfg['recordings_html_editable'] || $cfg['recordings_deleted_editable'] || |
340
|
|
|
$cfg['recordings_imported_editable'] || $cfg['recordings_preview_editable']) { |
341
|
|
|
$mform->addElement('header', 'recordings', get_string('mod_form_block_recordings', 'bigbluebuttonbn')); |
342
|
|
|
$this->bigbluebuttonbn_mform_add_block_room_recordings($mform, $cfg); |
343
|
|
|
} |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
/** |
347
|
|
|
* Function for showing the block for preuploaded presentation. |
348
|
|
|
* |
349
|
|
|
* @param object $mform |
350
|
|
|
* @param array $cfg |
351
|
|
|
* @return void |
352
|
|
|
*/ |
353
|
|
|
private function bigbluebuttonbn_mform_add_block_preuploads(&$mform, $cfg) { |
354
|
|
|
if ($cfg['preuploadpresentation_enabled']) { |
355
|
|
|
$mform->addElement('header', 'preuploadpresentation', |
356
|
|
|
get_string('mod_form_block_presentation', 'bigbluebuttonbn')); |
357
|
|
|
$mform->setExpanded('preuploadpresentation'); |
358
|
|
|
$filemanageroptions = array(); |
359
|
|
|
$filemanageroptions['accepted_types'] = '*'; |
360
|
|
|
$filemanageroptions['maxbytes'] = 0; |
361
|
|
|
$filemanageroptions['subdirs'] = 0; |
362
|
|
|
$filemanageroptions['maxfiles'] = 1; |
363
|
|
|
$filemanageroptions['mainfile'] = true; |
364
|
|
|
$mform->addElement('filemanager', 'presentation', get_string('selectfiles'), |
365
|
|
|
null, $filemanageroptions); |
366
|
|
|
} |
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
/** |
370
|
|
|
* Function for showing the block for setting participant roles. |
371
|
|
|
* |
372
|
|
|
* @param object $mform |
373
|
|
|
* @param string $participantlist |
374
|
|
|
* @return void |
375
|
|
|
*/ |
376
|
|
|
private function bigbluebuttonbn_mform_add_block_participants(&$mform, $participantlist) { |
377
|
|
|
$participantselection = bigbluebuttonbn_get_participant_selection_data(); |
378
|
|
|
$mform->addElement('header', 'permissions', get_string('mod_form_block_participants', 'bigbluebuttonbn')); |
379
|
|
|
$mform->setExpanded('permissions'); |
380
|
|
|
$mform->addElement('hidden', 'participants', json_encode($participantlist)); |
381
|
|
|
$mform->setType('participants', PARAM_TEXT); |
382
|
|
|
// Render elements for participant selection. |
383
|
|
|
$htmlselectiontype = html_writer::select($participantselection['type_options'], |
384
|
|
|
'bigbluebuttonbn_participant_selection_type', $participantselection['type_selected'], array(), |
385
|
|
|
array('id' => 'bigbluebuttonbn_participant_selection_type', |
386
|
|
|
'onchange' => 'M.mod_bigbluebuttonbn.modform.participantSelectionSet(); return 0;')); |
387
|
|
|
$htmlselectionoptions = html_writer::select($participantselection['options'], 'bigbluebuttonbn_participant_selection', |
388
|
|
|
$participantselection['selected'], array(), |
389
|
|
|
array('id' => 'bigbluebuttonbn_participant_selection', 'disabled' => 'disabled')); |
390
|
|
|
$htmlselectioninput = html_writer::tag('input', '', array('id' => 'id_addselectionid', |
391
|
|
|
'type' => 'button', 'class' => 'btn btn-secondary', |
392
|
|
|
'value' => get_string('mod_form_field_participant_list_action_add', 'bigbluebuttonbn'), |
393
|
|
|
'onclick' => 'M.mod_bigbluebuttonbn.modform.participantAdd(); return 0;' |
394
|
|
|
)); |
395
|
|
|
$htmladdparticipant = html_writer::tag('div', |
396
|
|
|
$htmlselectiontype . ' ' . $htmlselectionoptions . ' ' . $htmlselectioninput, null); |
397
|
|
|
$mform->addElement('html', "\n\n"); |
398
|
|
|
$mform->addElement('static', 'static_add_participant', |
399
|
|
|
get_string('mod_form_field_participant_add', 'bigbluebuttonbn'), $htmladdparticipant); |
400
|
|
|
$mform->addElement('html', "\n\n"); |
401
|
|
|
// Declare the table. |
402
|
|
|
$htmltable = new html_table(); |
403
|
|
|
$htmltable->align = array('left', 'left', 'left', 'left'); |
404
|
|
|
$htmltable->id = 'participant_list_table'; |
405
|
|
|
$htmltable->data = array(array()); |
406
|
|
|
// Render elements for participant list. |
407
|
|
|
$htmlparticipantlist = html_writer::table($htmltable); |
408
|
|
|
$mform->addElement('html', "\n\n"); |
409
|
|
|
$mform->addElement('static', 'static_participant_list', |
410
|
|
|
get_string('mod_form_field_participant_list', 'bigbluebuttonbn'), $htmlparticipantlist); |
411
|
|
|
$mform->addElement('html', "\n\n"); |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
/** |
415
|
|
|
* Function for showing the client type |
416
|
|
|
* |
417
|
|
|
* @param object $mform |
418
|
|
|
* @param object $cfg |
419
|
|
|
* @return void |
420
|
|
|
*/ |
421
|
|
|
private function bigbluebuttonbn_mform_add_block_clienttype(&$mform, &$cfg) { |
422
|
|
|
// Validates if clienttype capability is enabled. |
423
|
|
|
if (!$cfg['clienttype_enabled']) { |
424
|
|
|
return; |
425
|
|
|
} |
426
|
|
|
// Validates if the html5client is supported by the BigBlueButton Server. |
427
|
|
|
if (!bigbluebuttonbn_has_html5_client()) { |
428
|
|
|
return; |
429
|
|
|
} |
430
|
|
|
$field = ['type' => 'hidden', 'name' => 'clienttype', 'data_type' => PARAM_INT, |
431
|
|
|
'description_key' => null]; |
432
|
|
|
if ($cfg['clienttype_editable']) { |
433
|
|
|
$field['type'] = 'select'; |
434
|
|
|
$field['data_type'] = PARAM_TEXT; |
435
|
|
|
$field['description_key'] = 'mod_form_field_block_clienttype'; |
436
|
|
|
$choices = array(BIGBLUEBUTTON_CLIENTTYPE_FLASH => get_string('mod_form_block_clienttype_flash', 'bigbluebuttonbn'), |
437
|
|
|
BIGBLUEBUTTON_CLIENTTYPE_HTML5 => get_string('mod_form_block_clienttype_html5', 'bigbluebuttonbn')); |
438
|
|
|
$mform->addElement('header', 'clienttypeselection', get_string('mod_form_block_clienttype', 'bigbluebuttonbn')); |
439
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
440
|
|
|
$field['description_key'], $cfg['clienttype_default'], $choices); |
441
|
|
|
return; |
442
|
|
|
} |
443
|
|
|
$this->bigbluebuttonbn_mform_add_element($mform, $field['type'], $field['name'], $field['data_type'], |
444
|
|
|
null, $cfg['clienttype_default']); |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
/** |
448
|
|
|
* Function for showing the block for integration with the calendar. |
449
|
|
|
* |
450
|
|
|
* @param object $mform |
451
|
|
|
* @param object $activity |
452
|
|
|
* @return void |
453
|
|
|
*/ |
454
|
|
|
private function bigbluebuttonbn_mform_add_block_schedule(&$mform, &$activity) { |
455
|
|
|
$mform->addElement('header', 'schedule', get_string('mod_form_block_schedule', 'bigbluebuttonbn')); |
456
|
|
|
if (isset($activity->openingtime) && $activity->openingtime != 0 || |
457
|
|
|
isset($activity->closingtime) && $activity->closingtime != 0) { |
458
|
|
|
$mform->setExpanded('schedule'); |
459
|
|
|
} |
460
|
|
|
$mform->addElement('date_time_selector', 'openingtime', |
461
|
|
|
get_string('mod_form_field_openingtime', 'bigbluebuttonbn'), array('optional' => true)); |
462
|
|
|
$mform->setDefault('openingtime', 0); |
463
|
|
|
$mform->addElement('date_time_selector', 'closingtime', |
464
|
|
|
get_string('mod_form_field_closingtime', 'bigbluebuttonbn'), array('optional' => true)); |
465
|
|
|
$mform->setDefault('closingtime', 0); |
466
|
|
|
} |
467
|
|
|
|
468
|
|
|
/** |
469
|
|
|
* Function for showing an element. |
470
|
|
|
* |
471
|
|
|
* @param object $mform |
472
|
|
|
* @param string $type |
473
|
|
|
* @param string $name |
474
|
|
|
* @param string $datatype |
475
|
|
|
* @param string $descriptionkey |
476
|
|
|
* @param string $defaultvalue |
477
|
|
|
* @param array $options |
478
|
|
|
* @param string $rule |
479
|
|
|
* @return void |
480
|
|
|
*/ |
481
|
|
|
private function bigbluebuttonbn_mform_add_element(&$mform, $type, $name, $datatype, |
482
|
|
|
$descriptionkey, $defaultvalue = null, $options = null, $rule = null) { |
483
|
|
|
if ($type === 'hidden') { |
484
|
|
|
$mform->addElement($type, $name, $defaultvalue); |
485
|
|
|
$mform->setType($name, $datatype); |
486
|
|
|
return; |
487
|
|
|
} |
488
|
|
|
$mform->addElement($type, $name, get_string($descriptionkey, 'bigbluebuttonbn'), $options); |
489
|
|
|
if (get_string_manager()->string_exists($descriptionkey.'_help', 'bigbluebuttonbn')) { |
490
|
|
|
$mform->addHelpButton($name, $descriptionkey, 'bigbluebuttonbn'); |
491
|
|
|
} |
492
|
|
|
if (!empty($rule)) { |
493
|
|
|
$mform->addRule($name, $rule['message'], $rule['type'], $rule['rule'], $rule['validator']); |
494
|
|
|
} |
495
|
|
|
$mform->setDefault($name, $defaultvalue); |
496
|
|
|
$mform->setType($name, $datatype); |
497
|
|
|
} |
498
|
|
|
} |
499
|
|
|
|