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