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
|
|
|
* View a BigBlueButton room. |
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
|
|
|
require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); |
28
|
|
|
require_once(dirname(__FILE__).'/locallib.php'); |
29
|
|
|
|
30
|
|
|
$id = required_param('id', PARAM_INT); |
31
|
|
|
$bn = optional_param('n', 0, PARAM_INT); |
32
|
|
|
$group = optional_param('group', 0, PARAM_INT); |
33
|
|
|
|
34
|
|
|
$viewinstance = bigbluebuttonbn_views_validator($id, $bn); |
35
|
|
|
if (!$viewinstance) { |
36
|
|
|
print_error(get_string('view_error_url_missing_parameters', 'bigbluebuttonbn')); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
$cm = $viewinstance['cm']; |
40
|
|
|
$course = $viewinstance['course']; |
41
|
|
|
$bigbluebuttonbn = $viewinstance['bigbluebuttonbn']; |
42
|
|
|
|
43
|
|
|
require_login($course, true, $cm); |
44
|
|
|
|
45
|
|
|
$context = context_module::instance($cm->id); |
46
|
|
|
|
47
|
|
|
bigbluebuttonbn_event_log(BIGBLUEBUTTON_EVENT_ACTIVITY_VIEWED, $bigbluebuttonbn, $cm); |
48
|
|
|
|
49
|
|
|
// Additional info related to the course. |
50
|
|
|
$bbbsession['course'] = $course; |
51
|
|
|
$bbbsession['coursename'] = $course->fullname; |
52
|
|
|
$bbbsession['cm'] = $cm; |
53
|
|
|
// Hot-fix: Only for v2017101004, to be removed in the next release if db upgrade is added. |
54
|
|
|
bigbluebuttonbn_verify_passwords($bigbluebuttonbn); |
55
|
|
|
$bbbsession['bigbluebuttonbn'] = $bigbluebuttonbn; |
56
|
|
|
bigbluebuttonbn_view_bbbsession_set($context, $bbbsession); |
57
|
|
|
|
58
|
|
|
// Validates if the BigBlueButton server is working. |
59
|
|
|
$serverversion = bigbluebuttonbn_get_server_version(); |
60
|
|
|
if (is_null($serverversion)) { |
61
|
|
|
if ($bbbsession['administrator']) { |
62
|
|
|
print_error('view_error_unable_join', 'bigbluebuttonbn', |
63
|
|
|
$CFG->wwwroot.'/admin/settings.php?section=modsettingbigbluebuttonbn'); |
64
|
|
|
exit; |
65
|
|
|
} |
66
|
|
|
if ($bbbsession['moderator']) { |
67
|
|
|
print_error('view_error_unable_join_teacher', 'bigbluebuttonbn', |
68
|
|
|
$CFG->wwwroot.'/course/view.php?id='.$bigbluebuttonbn->course); |
69
|
|
|
exit; |
70
|
|
|
} |
71
|
|
|
print_error('view_error_unable_join_student', 'bigbluebuttonbn', |
72
|
|
|
$CFG->wwwroot.'/course/view.php?id='.$bigbluebuttonbn->course); |
73
|
|
|
exit; |
74
|
|
|
} |
75
|
|
|
$bbbsession['serverversion'] = (string) $serverversion; |
76
|
|
|
|
77
|
|
|
// Mark viewed by user (if required). |
78
|
|
|
$completion = new completion_info($course); |
79
|
|
|
$completion->set_module_viewed($cm); |
80
|
|
|
|
81
|
|
|
// Print the page header. |
82
|
|
|
$PAGE->set_context($context); |
83
|
|
|
$PAGE->set_url($CFG->wwwroot.'/mod/bigbluebuttonbn/view.php', array('id' => $cm->id)); |
84
|
|
|
$PAGE->set_title(format_string($bigbluebuttonbn->name)); |
85
|
|
|
$PAGE->set_cacheable(false); |
86
|
|
|
$PAGE->set_heading($course->fullname); |
87
|
|
|
$PAGE->set_pagelayout('incourse'); |
88
|
|
|
|
89
|
|
|
// Validate if the user is in a role allowed to join. |
90
|
|
|
if (!has_capability('moodle/category:manage', $context) && !has_capability('mod/bigbluebuttonbn:join', $context)) { |
91
|
|
|
echo $OUTPUT->header(); |
92
|
|
|
if (isguestuser()) { |
93
|
|
|
echo $OUTPUT->confirm('<p>'.get_string('view_noguests', 'bigbluebuttonbn').'</p>'.get_string('liketologin'), |
94
|
|
|
get_login_url(), $CFG->wwwroot.'/course/view.php?id='.$course->id); |
95
|
|
|
} else { |
96
|
|
|
echo $OUTPUT->confirm('<p>'.get_string('view_nojoin', 'bigbluebuttonbn').'</p>'.get_string('liketologin'), |
97
|
|
|
get_login_url(), $CFG->wwwroot.'/course/view.php?id='.$course->id); |
98
|
|
|
} |
99
|
|
|
echo $OUTPUT->footer(); |
100
|
|
|
exit; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
// Operation URLs. |
104
|
|
|
$bbbsession['bigbluebuttonbnURL'] = $CFG->wwwroot . '/mod/bigbluebuttonbn/view.php?id=' . $bbbsession['cm']->id; |
105
|
|
|
$bbbsession['logoutURL'] = $CFG->wwwroot . '/mod/bigbluebuttonbn/bbb_view.php?action=logout&id='.$id . |
106
|
|
|
'&bn=' . $bbbsession['bigbluebuttonbn']->id; |
107
|
|
|
$bbbsession['recordingReadyURL'] = $CFG->wwwroot . '/mod/bigbluebuttonbn/bbb_broker.php?action=recording_' . |
108
|
|
|
'ready&bigbluebuttonbn=' . $bbbsession['bigbluebuttonbn']->id; |
109
|
|
|
$bbbsession['meetingEventsURL'] = $CFG->wwwroot . '/mod/bigbluebuttonbn/bbb_broker.php?action=meeting' . |
110
|
|
|
'_events&bigbluebuttonbn=' . $bbbsession['bigbluebuttonbn']->id; |
111
|
|
|
$bbbsession['joinURL'] = $CFG->wwwroot . '/mod/bigbluebuttonbn/bbb_view.php?action=join&id=' . $id . |
112
|
|
|
'&bn=' . $bbbsession['bigbluebuttonbn']->id; |
113
|
|
|
|
114
|
|
|
// Output starts. |
115
|
|
|
echo $OUTPUT->header(); |
116
|
|
|
|
117
|
|
|
bigbluebuttonbn_view_groups($bbbsession); |
118
|
|
|
|
119
|
|
|
bigbluebuttonbn_view_render($bbbsession, bigbluebuttonbn_view_get_activity_status($bbbsession)); |
120
|
|
|
|
121
|
|
|
// Output finishes. |
122
|
|
|
echo $OUTPUT->footer(); |
123
|
|
|
|
124
|
|
|
// Shows version as a comment. |
125
|
|
|
echo '<!-- '.$bbbsession['originTag'].' -->'."\n"; |
126
|
|
|
|
127
|
|
|
// Initialize session variable used across views. |
128
|
|
|
$SESSION->bigbluebuttonbn_bbbsession = $bbbsession; |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Setup the bbbsession variable that is used all accross the plugin. |
132
|
|
|
* |
133
|
|
|
* @param object $context |
134
|
|
|
* @param array $bbbsession |
135
|
|
|
* @return void |
136
|
|
|
*/ |
137
|
|
|
function bigbluebuttonbn_view_bbbsession_set($context, &$bbbsession) { |
138
|
|
|
global $CFG, $USER; |
139
|
|
|
// User data. |
140
|
|
|
$bbbsession['username'] = fullname($USER); |
141
|
|
|
$bbbsession['userID'] = $USER->id; |
142
|
|
|
// User roles. |
143
|
|
|
$bbbsession['administrator'] = is_siteadmin($bbbsession['userID']); |
144
|
|
|
$participantlist = bigbluebuttonbn_get_participant_list($bbbsession['bigbluebuttonbn'], $context); |
145
|
|
|
$bbbsession['moderator'] = bigbluebuttonbn_is_moderator( |
146
|
|
|
$context, json_encode($participantlist), $bbbsession['userID']); |
147
|
|
|
$bbbsession['managerecordings'] = ($bbbsession['administrator'] |
148
|
|
|
|| has_capability('mod/bigbluebuttonbn:managerecordings', $context)); |
149
|
|
|
$bbbsession['importrecordings'] = ($bbbsession['managerecordings']); |
150
|
|
|
// Server data. |
151
|
|
|
$bbbsession['modPW'] = $bbbsession['bigbluebuttonbn']->moderatorpass; |
152
|
|
|
$bbbsession['viewerPW'] = $bbbsession['bigbluebuttonbn']->viewerpass; |
153
|
|
|
// Database info related to the activity. |
154
|
|
|
$bbbsession['meetingid'] = $bbbsession['bigbluebuttonbn']->meetingid.'-'.$bbbsession['course']->id.'-'. |
155
|
|
|
$bbbsession['bigbluebuttonbn']->id; |
156
|
|
|
$bbbsession['meetingname'] = $bbbsession['bigbluebuttonbn']->name; |
157
|
|
|
$bbbsession['meetingdescription'] = $bbbsession['bigbluebuttonbn']->intro; |
158
|
|
|
// Extra data for setting up the Meeting. |
159
|
|
|
$bbbsession['userlimit'] = intval((int)\mod_bigbluebuttonbn\locallib\config::get('userlimit_default')); |
160
|
|
|
if ((boolean)\mod_bigbluebuttonbn\locallib\config::get('userlimit_editable')) { |
161
|
|
|
$bbbsession['userlimit'] = intval($bbbsession['bigbluebuttonbn']->userlimit); |
162
|
|
|
} |
163
|
|
|
$bbbsession['voicebridge'] = $bbbsession['bigbluebuttonbn']->voicebridge; |
164
|
|
|
if ($bbbsession['bigbluebuttonbn']->voicebridge > 0) { |
165
|
|
|
$bbbsession['voicebridge'] = 70000 + $bbbsession['bigbluebuttonbn']->voicebridge; |
166
|
|
|
} |
167
|
|
|
$bbbsession['wait'] = $bbbsession['bigbluebuttonbn']->wait; |
168
|
|
|
$bbbsession['record'] = $bbbsession['bigbluebuttonbn']->record; |
169
|
|
|
$bbbsession['welcome'] = $bbbsession['bigbluebuttonbn']->welcome; |
170
|
|
|
if (!isset($bbbsession['welcome']) || $bbbsession['welcome'] == '') { |
171
|
|
|
$bbbsession['welcome'] = get_string('mod_form_field_welcome_default', 'bigbluebuttonbn'); |
172
|
|
|
} |
173
|
|
|
if ($bbbsession['bigbluebuttonbn']->record) { |
174
|
|
|
$bbbsession['welcome'] .= '<br><br>'.get_string('bbbrecordwarning', 'bigbluebuttonbn'); |
175
|
|
|
} |
176
|
|
|
$bbbsession['openingtime'] = $bbbsession['bigbluebuttonbn']->openingtime; |
177
|
|
|
$bbbsession['closingtime'] = $bbbsession['bigbluebuttonbn']->closingtime; |
178
|
|
|
// Additional info related to the course. |
179
|
|
|
$bbbsession['context'] = $context; |
180
|
|
|
// Metadata (origin). |
181
|
|
|
$bbbsession['origin'] = 'Moodle'; |
182
|
|
|
$bbbsession['originVersion'] = $CFG->release; |
183
|
|
|
$parsedurl = parse_url($CFG->wwwroot); |
184
|
|
|
$bbbsession['originServerName'] = $parsedurl['host']; |
185
|
|
|
$bbbsession['originServerUrl'] = $CFG->wwwroot; |
186
|
|
|
$bbbsession['originServerCommonName'] = ''; |
187
|
|
|
$bbbsession['originTag'] = 'moodle-mod_bigbluebuttonbn ('.get_config('mod_bigbluebuttonbn', 'version').')'; |
188
|
|
|
$bbbsession['bnserver'] = bigbluebuttonbn_is_bn_server(); |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* Return the status of an activity [open|not_started|ended]. |
193
|
|
|
* |
194
|
|
|
* @param array $bbbsession |
195
|
|
|
* @return string |
196
|
|
|
*/ |
197
|
|
|
function bigbluebuttonbn_view_get_activity_status(&$bbbsession) { |
198
|
|
|
$now = time(); |
199
|
|
|
if (!empty($bbbsession['bigbluebuttonbn']->openingtime) && $now < $bbbsession['bigbluebuttonbn']->openingtime) { |
200
|
|
|
// The activity has not been opened. |
201
|
|
|
return 'not_started'; |
202
|
|
|
} |
203
|
|
|
if (!empty($bbbsession['bigbluebuttonbn']->closingtime) && $now > $bbbsession['bigbluebuttonbn']->closingtime) { |
204
|
|
|
// The activity has been closed. |
205
|
|
|
$bbbsession['presentation'] = bigbluebuttonbn_get_presentation_array( |
206
|
|
|
$bbbsession['context'], $bbbsession['bigbluebuttonbn']->presentation); |
207
|
|
|
return 'ended'; |
208
|
|
|
} |
209
|
|
|
// The activity is open. |
210
|
|
|
$bbbsession['presentation'] = bigbluebuttonbn_get_presentation_array( |
211
|
|
|
$bbbsession['context'], $bbbsession['bigbluebuttonbn']->presentation, $bbbsession['bigbluebuttonbn']->id); |
212
|
|
|
return 'open'; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* Displays the view for groups. |
217
|
|
|
* |
218
|
|
|
* @param array $bbbsession |
219
|
|
|
* @return void |
220
|
|
|
*/ |
221
|
|
|
function bigbluebuttonbn_view_groups(&$bbbsession) { |
222
|
|
|
global $CFG; |
223
|
|
|
// Find out current group mode. |
224
|
|
|
$groupmode = groups_get_activity_groupmode($bbbsession['cm']); |
225
|
|
|
if ($groupmode == NOGROUPS) { |
226
|
|
|
// No groups mode. |
227
|
|
|
return; |
228
|
|
|
} |
229
|
|
|
// Separate or visible group mode. |
230
|
|
|
$groups = groups_get_activity_allowed_groups($bbbsession['cm']); |
231
|
|
|
if (empty($groups)) { |
232
|
|
|
// No groups in this course. |
233
|
|
|
bigbluebuttonbn_view_message_box($bbbsession, get_string('view_groups_nogroups_warning', 'bigbluebuttonbn'), 'info', true); |
234
|
|
|
return; |
235
|
|
|
} |
236
|
|
|
$bbbsession['group'] = groups_get_activity_group($bbbsession['cm'], true); |
237
|
|
|
$groupname = get_string('allparticipants'); |
238
|
|
|
if ($bbbsession['group'] != 0) { |
239
|
|
|
$groupname = groups_get_group_name($bbbsession['group']); |
240
|
|
|
} |
241
|
|
|
// Assign group default values. |
242
|
|
|
$bbbsession['meetingid'] .= '['.$bbbsession['group'].']'; |
243
|
|
|
$bbbsession['meetingname'] .= ' ('.$groupname.')'; |
244
|
|
|
if (count($groups) == 0) { |
245
|
|
|
// Only the All participants group exists. |
246
|
|
|
bigbluebuttonbn_view_message_box($bbbsession, get_string('view_groups_notenrolled_warning', 'bigbluebuttonbn'), 'info'); |
247
|
|
|
return; |
248
|
|
|
} |
249
|
|
|
$context = context_module::instance($bbbsession['cm']->id); |
250
|
|
|
if (has_capability('moodle/site:accessallgroups', $context)) { |
251
|
|
|
bigbluebuttonbn_view_message_box($bbbsession, get_string('view_groups_selection_warning', 'bigbluebuttonbn')); |
252
|
|
|
} |
253
|
|
|
$urltoroot = $CFG->wwwroot.'/mod/bigbluebuttonbn/view.php?id='.$bbbsession['cm']->id; |
254
|
|
|
groups_print_activity_menu($bbbsession['cm'], $urltoroot); |
255
|
|
|
echo '<br><br>'; |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
/** |
259
|
|
|
* Displays the view for messages. |
260
|
|
|
* |
261
|
|
|
* @param array $bbbsession |
262
|
|
|
* @param string $message |
263
|
|
|
* @param string $type |
264
|
|
|
* @param boolean $onlymoderator |
265
|
|
|
* @return void |
266
|
|
|
*/ |
267
|
|
|
function bigbluebuttonbn_view_message_box(&$bbbsession, $message, $type = 'warning', $onlymoderator = false) { |
268
|
|
|
global $OUTPUT; |
269
|
|
|
if ($onlymoderator && !$bbbsession['moderator'] && !$bbbsession['administrator']) { |
270
|
|
|
return; |
271
|
|
|
} |
272
|
|
|
echo $OUTPUT->box_start('generalbox boxaligncenter'); |
273
|
|
|
echo '<br><div class="alert alert-' . $type . '">' . $message . '</div>'; |
274
|
|
|
echo $OUTPUT->box_end(); |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* Displays the general view. |
279
|
|
|
* |
280
|
|
|
* @param array $bbbsession |
281
|
|
|
* @param string $activity |
282
|
|
|
* @return void |
283
|
|
|
*/ |
284
|
|
|
function bigbluebuttonbn_view_render(&$bbbsession, $activity) { |
285
|
|
|
global $OUTPUT, $PAGE; |
286
|
|
|
$type = null; |
287
|
|
|
if (isset($bbbsession['bigbluebuttonbn']->type)) { |
288
|
|
|
$type = $bbbsession['bigbluebuttonbn']->type; |
289
|
|
|
} |
290
|
|
|
$typeprofiles = bigbluebuttonbn_get_instance_type_profiles(); |
291
|
|
|
$enabledfeatures = bigbluebuttonbn_get_enabled_features($typeprofiles, $type); |
292
|
|
|
$pinginterval = (int)\mod_bigbluebuttonbn\locallib\config::get('waitformoderator_ping_interval') * 1000; |
293
|
|
|
// JavaScript for locales. |
294
|
|
|
$PAGE->requires->strings_for_js(array_keys(bigbluebuttonbn_get_strings_for_js()), 'bigbluebuttonbn'); |
295
|
|
|
// JavaScript variables. |
296
|
|
|
$jsvars = array('activity' => $activity, 'ping_interval' => $pinginterval, |
297
|
|
|
'locale' => bigbluebuttonbn_get_localcode(), 'profile_features' => $typeprofiles[0]['features']); |
298
|
|
|
$output = ''; |
299
|
|
|
// Renders warning messages when configured. |
300
|
|
|
$output .= bigbluebuttonbn_view_warning_default_server($bbbsession); |
301
|
|
|
$output .= bigbluebuttonbn_view_warning_general($bbbsession); |
302
|
|
|
// Renders the rest of the page. |
303
|
|
|
$output .= $OUTPUT->heading($bbbsession['meetingname'], 3); |
304
|
|
|
$output .= $OUTPUT->heading($bbbsession['meetingdescription'], 5); |
305
|
|
|
if ($enabledfeatures['showroom']) { |
306
|
|
|
$output .= bigbluebuttonbn_view_render_room($bbbsession, $activity, $jsvars); |
307
|
|
|
$PAGE->requires->yui_module('moodle-mod_bigbluebuttonbn-rooms', |
308
|
|
|
'M.mod_bigbluebuttonbn.rooms.init', array($jsvars)); |
309
|
|
|
} |
310
|
|
|
if ($enabledfeatures['showrecordings']) { |
311
|
|
|
$output .= html_writer::start_tag('div', array('id' => 'bigbluebuttonbn_view_recordings')); |
312
|
|
|
$output .= bigbluebuttonbn_view_render_recording_section($bbbsession, $type, $enabledfeatures, $jsvars); |
313
|
|
|
$output .= html_writer::end_tag('div'); |
314
|
|
|
$PAGE->requires->yui_module('moodle-mod_bigbluebuttonbn-recordings', |
315
|
|
|
'M.mod_bigbluebuttonbn.recordings.init', array($jsvars)); |
316
|
|
|
} else if ($type == BIGBLUEBUTTONBN_TYPE_RECORDING_ONLY) { |
317
|
|
|
$recordingsdisabled = get_string('view_message_recordings_disabled', 'bigbluebuttonbn'); |
318
|
|
|
$output .= bigbluebuttonbn_render_warning($recordingsdisabled, 'danger'); |
319
|
|
|
} |
320
|
|
|
echo $output.html_writer::empty_tag('br').html_writer::empty_tag('br').html_writer::empty_tag('br'); |
321
|
|
|
$PAGE->requires->yui_module('moodle-mod_bigbluebuttonbn-broker', 'M.mod_bigbluebuttonbn.broker.init', array($jsvars)); |
322
|
|
|
} |
323
|
|
|
|
324
|
|
|
/** |
325
|
|
|
* Renders the view for recordings. |
326
|
|
|
* |
327
|
|
|
* @param array $bbbsession |
328
|
|
|
* @param integer $type |
329
|
|
|
* @param array $enabledfeatures |
330
|
|
|
* @param array $jsvars |
331
|
|
|
* @return string |
332
|
|
|
*/ |
333
|
|
|
function bigbluebuttonbn_view_render_recording_section(&$bbbsession, $type, $enabledfeatures, &$jsvars) { |
334
|
|
|
if ($type == BIGBLUEBUTTONBN_TYPE_ROOM_ONLY) { |
335
|
|
|
return ''; |
336
|
|
|
} |
337
|
|
|
$output = ''; |
338
|
|
|
if ($type == BIGBLUEBUTTONBN_TYPE_ALL && $bbbsession['record']) { |
339
|
|
|
$output .= html_writer::start_tag('div', array('id' => 'bigbluebuttonbn_view_recordings_header')); |
340
|
|
|
$output .= html_writer::tag('h4', get_string('view_section_title_recordings', 'bigbluebuttonbn')); |
341
|
|
|
$output .= html_writer::end_tag('div'); |
342
|
|
|
} |
343
|
|
|
if ($type == BIGBLUEBUTTONBN_TYPE_RECORDING_ONLY || $bbbsession['record']) { |
344
|
|
|
$output .= html_writer::start_tag('div', array('id' => 'bigbluebuttonbn_view_recordings_content')); |
345
|
|
|
$output .= bigbluebuttonbn_view_render_recordings($bbbsession, $enabledfeatures, $jsvars); |
346
|
|
|
$output .= html_writer::end_tag('div'); |
347
|
|
|
$output .= html_writer::start_tag('div', array('id' => 'bigbluebuttonbn_view_recordings_footer')); |
348
|
|
|
$output .= bigbluebuttonbn_view_render_imported($bbbsession, $enabledfeatures); |
349
|
|
|
$output .= html_writer::end_tag('div'); |
350
|
|
|
} |
351
|
|
|
return $output; |
352
|
|
|
} |
353
|
|
|
|
354
|
|
|
/** |
355
|
|
|
* Evaluates if the warning box should be shown. |
356
|
|
|
* |
357
|
|
|
* @param array $bbbsession |
358
|
|
|
* |
359
|
|
|
* @return boolean |
360
|
|
|
*/ |
361
|
|
|
function bigbluebuttonbn_view_warning_shown($bbbsession) { |
362
|
|
|
if (is_siteadmin($bbbsession['userID'])) { |
363
|
|
|
return true; |
364
|
|
|
} |
365
|
|
|
$generalwarningroles = explode(',', \mod_bigbluebuttonbn\locallib\config::get('general_warning_roles')); |
366
|
|
|
$userroles = bigbluebuttonbn_get_user_roles($bbbsession['context'], $bbbsession['userID']); |
367
|
|
|
foreach ($userroles as $userrole) { |
368
|
|
|
if (in_array($userrole->shortname, $generalwarningroles)) { |
369
|
|
|
return true; |
370
|
|
|
} |
371
|
|
|
} |
372
|
|
|
return false; |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
/** |
376
|
|
|
* Renders the view for room. |
377
|
|
|
* |
378
|
|
|
* @param array $bbbsession |
379
|
|
|
* @param string $activity |
380
|
|
|
* @param array $jsvars |
381
|
|
|
* |
382
|
|
|
* @return string |
383
|
|
|
*/ |
384
|
|
|
function bigbluebuttonbn_view_render_room(&$bbbsession, $activity, &$jsvars) { |
385
|
|
|
global $OUTPUT; |
386
|
|
|
// JavaScript variables for room. |
387
|
|
|
$openingtime = ''; |
388
|
|
|
if ($bbbsession['openingtime']) { |
389
|
|
|
$openingtime = get_string('mod_form_field_openingtime', 'bigbluebuttonbn').': '. |
390
|
|
|
userdate($bbbsession['openingtime']); |
391
|
|
|
} |
392
|
|
|
$closingtime = ''; |
393
|
|
|
if ($bbbsession['closingtime']) { |
394
|
|
|
$closingtime = get_string('mod_form_field_closingtime', 'bigbluebuttonbn').': '. |
395
|
|
|
userdate($bbbsession['closingtime']); |
396
|
|
|
} |
397
|
|
|
$jsvars += array( |
398
|
|
|
'meetingid' => $bbbsession['meetingid'], |
399
|
|
|
'bigbluebuttonbnid' => $bbbsession['bigbluebuttonbn']->id, |
400
|
|
|
'userlimit' => $bbbsession['userlimit'], |
401
|
|
|
'opening' => $openingtime, |
402
|
|
|
'closing' => $closingtime, |
403
|
|
|
); |
404
|
|
|
// Main box. |
405
|
|
|
$output = $OUTPUT->box_start('generalbox boxaligncenter', 'bigbluebuttonbn_view_message_box'); |
406
|
|
|
$output .= '<br><span id="status_bar"></span>'; |
407
|
|
|
$output .= '<br><span id="control_panel"></span>'; |
408
|
|
|
$output .= $OUTPUT->box_end(); |
409
|
|
|
// Action button box. |
410
|
|
|
$output .= $OUTPUT->box_start('generalbox boxaligncenter', 'bigbluebuttonbn_view_action_button_box'); |
411
|
|
|
$output .= '<br><br><span id="join_button"></span> <span id="end_button"></span>'."\n"; |
412
|
|
|
$output .= $OUTPUT->box_end(); |
413
|
|
|
if ($activity == 'ended') { |
414
|
|
|
$output .= bigbluebuttonbn_view_ended($bbbsession); |
415
|
|
|
} |
416
|
|
|
return $output; |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
/** |
420
|
|
|
* Renders the view for recordings. |
421
|
|
|
* |
422
|
|
|
* @param array $bbbsession |
423
|
|
|
* @param array $enabledfeatures |
424
|
|
|
* @param array $jsvars |
425
|
|
|
* |
426
|
|
|
* @return string |
427
|
|
|
*/ |
428
|
|
|
function bigbluebuttonbn_view_render_recordings(&$bbbsession, $enabledfeatures, &$jsvars) { |
429
|
|
|
$bigbluebuttonbnid = null; |
430
|
|
|
if ($enabledfeatures['showroom']) { |
431
|
|
|
$bigbluebuttonbnid = $bbbsession['bigbluebuttonbn']->id; |
432
|
|
|
} |
433
|
|
|
// Get recordings. |
434
|
|
|
$recordings = bigbluebuttonbn_get_recordings( |
435
|
|
|
$bbbsession['course']->id, $bigbluebuttonbnid, $enabledfeatures['showroom'], |
436
|
|
|
$bbbsession['bigbluebuttonbn']->recordings_deleted |
437
|
|
|
); |
438
|
|
|
if ($enabledfeatures['importrecordings']) { |
439
|
|
|
// Get recording links. |
440
|
|
|
$recordingsimported = bigbluebuttonbn_get_recordings_imported_array( |
441
|
|
|
$bbbsession['course']->id, $bigbluebuttonbnid, $enabledfeatures['showroom'] |
442
|
|
|
); |
443
|
|
|
/* Perform aritmetic addition instead of merge so the imported recordings corresponding to existent |
444
|
|
|
* recordings are not included. */ |
445
|
|
|
$recordings += $recordingsimported; |
446
|
|
|
} |
447
|
|
|
if (empty($recordings) || array_key_exists('messageKey', $recordings)) { |
448
|
|
|
// There are no recordings to be shown. |
449
|
|
|
return html_writer::div(get_string('view_message_norecordings', 'bigbluebuttonbn'), '', |
450
|
|
|
array('id' => 'bigbluebuttonbn_recordings_table')); |
451
|
|
|
} |
452
|
|
|
// There are recordings for this meeting. |
453
|
|
|
// JavaScript variables for recordings. |
454
|
|
|
$jsvars += array( |
455
|
|
|
'recordings_html' => $bbbsession['bigbluebuttonbn']->recordings_html == '1', |
456
|
|
|
); |
457
|
|
|
// If there are meetings with recordings load the data to the table. |
458
|
|
|
if ($bbbsession['bigbluebuttonbn']->recordings_html) { |
459
|
|
|
// Render a plain html table. |
460
|
|
|
return bigbluebuttonbn_output_recording_table($bbbsession, $recordings)."\n"; |
461
|
|
|
} |
462
|
|
|
// JavaScript variables for recordings with YUI. |
463
|
|
|
$jsvars += array( |
464
|
|
|
'columns' => bigbluebuttonbn_get_recording_columns($bbbsession), |
465
|
|
|
'data' => bigbluebuttonbn_get_recording_data($bbbsession, $recordings), |
466
|
|
|
); |
467
|
|
|
// Render a YUI table. |
468
|
|
|
return html_writer::div('', '', array('id' => 'bigbluebuttonbn_recordings_table')); |
469
|
|
|
} |
470
|
|
|
|
471
|
|
|
/** |
472
|
|
|
* Renders the view for importing recordings. |
473
|
|
|
* |
474
|
|
|
* @param array $bbbsession |
475
|
|
|
* @param array $enabledfeatures |
476
|
|
|
* |
477
|
|
|
* @return string |
478
|
|
|
*/ |
479
|
|
|
function bigbluebuttonbn_view_render_imported($bbbsession, $enabledfeatures) { |
480
|
|
|
global $CFG; |
481
|
|
|
if (!$enabledfeatures['importrecordings'] || !$bbbsession['importrecordings']) { |
482
|
|
|
return ''; |
483
|
|
|
} |
484
|
|
|
$button = html_writer::tag('input', '', |
485
|
|
|
array('type' => 'button', |
486
|
|
|
'value' => get_string('view_recording_button_import', 'bigbluebuttonbn'), |
487
|
|
|
'class' => 'btn btn-secondary', |
488
|
|
|
'onclick' => 'window.location=\''.$CFG->wwwroot.'/mod/bigbluebuttonbn/import_view.php?bn='. |
489
|
|
|
$bbbsession['bigbluebuttonbn']->id.'\'')); |
490
|
|
|
$output = html_writer::empty_tag('br'); |
491
|
|
|
$output .= html_writer::tag('span', $button, array('id' => 'import_recording_links_button')); |
492
|
|
|
$output .= html_writer::tag('span', '', array('id' => 'import_recording_links_table')); |
493
|
|
|
return $output; |
494
|
|
|
} |
495
|
|
|
|
496
|
|
|
/** |
497
|
|
|
* Renders the content for ended meeting. |
498
|
|
|
* |
499
|
|
|
* @param array $bbbsession |
500
|
|
|
* |
501
|
|
|
* @return string |
502
|
|
|
*/ |
503
|
|
|
function bigbluebuttonbn_view_ended(&$bbbsession) { |
504
|
|
|
global $OUTPUT; |
505
|
|
|
if (!is_null($bbbsession['presentation']['url'])) { |
506
|
|
|
$attributes = array('title' => $bbbsession['presentation']['name']); |
507
|
|
|
$icon = new pix_icon($bbbsession['presentation']['icon'], $bbbsession['presentation']['mimetype_description']); |
508
|
|
|
return '<h4>'.get_string('view_section_title_presentation', 'bigbluebuttonbn').'</h4>'. |
509
|
|
|
$OUTPUT->action_icon($bbbsession['presentation']['url'], $icon, null, array(), false). |
510
|
|
|
$OUTPUT->action_link($bbbsession['presentation']['url'], |
511
|
|
|
$bbbsession['presentation']['name'], null, $attributes).'<br><br>'; |
512
|
|
|
} |
513
|
|
|
return ''; |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
// Hot-fix: Only for v2017101004, to be removed in the next release if db upgrade is added. |
517
|
|
|
/** |
518
|
|
|
* Make sure the passwords have been setup. |
519
|
|
|
* |
520
|
|
|
* @param object $bigbluebuttonbn |
521
|
|
|
* |
522
|
|
|
* @return void |
523
|
|
|
*/ |
524
|
|
|
function bigbluebuttonbn_verify_passwords(&$bigbluebuttonbn) { |
525
|
|
|
global $DB; |
526
|
|
|
if (empty($bigbluebuttonbn->moderatorpass) || empty($bigbluebuttonbn->viewerpass)) { |
527
|
|
|
$bigbluebuttonbn->moderatorpass = bigbluebuttonbn_random_password(12); |
528
|
|
|
$bigbluebuttonbn->viewerpass = bigbluebuttonbn_random_password(12, $bigbluebuttonbn->moderatorpass); |
529
|
|
|
// Store passwords in the database. |
530
|
|
|
$DB->update_record('bigbluebuttonbn', $bigbluebuttonbn); |
531
|
|
|
} |
532
|
|
|
} |
533
|
|
|
|
534
|
|
|
/** |
535
|
|
|
* Renders a default server warning message when using test-install. |
536
|
|
|
* |
537
|
|
|
* @param array $bbbsession |
538
|
|
|
* |
539
|
|
|
* @return string |
540
|
|
|
*/ |
541
|
|
|
function bigbluebuttonbn_view_warning_default_server(&$bbbsession) { |
542
|
|
|
if (!is_siteadmin($bbbsession['userID'])) { |
543
|
|
|
return ''; |
544
|
|
|
} |
545
|
|
|
if (BIGBLUEBUTTONBN_DEFAULT_SERVER_URL != \mod_bigbluebuttonbn\locallib\config::get('server_url')) { |
546
|
|
|
return ''; |
547
|
|
|
} |
548
|
|
|
return bigbluebuttonbn_render_warning(get_string('view_warning_default_server', 'bigbluebuttonbn'), 'warning'); |
549
|
|
|
} |
550
|
|
|
|
551
|
|
|
/** |
552
|
|
|
* Renders a general warning message when it is configured. |
553
|
|
|
* |
554
|
|
|
* @param array $bbbsession |
555
|
|
|
* |
556
|
|
|
* @return string |
557
|
|
|
*/ |
558
|
|
|
function bigbluebuttonbn_view_warning_general(&$bbbsession) { |
559
|
|
|
if (!bigbluebuttonbn_view_warning_shown($bbbsession)) { |
560
|
|
|
return ''; |
561
|
|
|
} |
562
|
|
|
return bigbluebuttonbn_render_warning( |
563
|
|
|
(string)\mod_bigbluebuttonbn\locallib\config::get('general_warning_message'), |
564
|
|
|
(string)\mod_bigbluebuttonbn\locallib\config::get('general_warning_box_type'), |
565
|
|
|
(string)\mod_bigbluebuttonbn\locallib\config::get('general_warning_button_href'), |
566
|
|
|
(string)\mod_bigbluebuttonbn\locallib\config::get('general_warning_button_text'), |
567
|
|
|
(string)\mod_bigbluebuttonbn\locallib\config::get('general_warning_button_class') |
568
|
|
|
); |
569
|
|
|
} |
570
|
|
|
|