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