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 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
|
|
|
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('bn', 0, PARAM_INT); |
32
|
|
|
$group = optional_param('group', 0, PARAM_INT); |
33
|
|
|
|
34
|
|
|
$viewinstance = bigbluebuttonbn_view_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
|
|
|
$context = context_module::instance($cm->id); |
43
|
|
|
|
44
|
|
|
require_login($course, true, $cm); |
45
|
|
|
|
46
|
|
|
bigbluebuttonbn_event_log(\mod_bigbluebuttonbn\event\events::$events['view'], $bigbluebuttonbn); |
47
|
|
|
|
48
|
|
|
// Additional info related to the course. |
49
|
|
|
$bbbsession['course'] = $course; |
50
|
|
|
$bbbsession['coursename'] = $course->fullname; |
51
|
|
|
$bbbsession['cm'] = $cm; |
52
|
|
|
$bbbsession['bigbluebuttonbn'] = $bigbluebuttonbn; |
53
|
|
|
bigbluebuttonbn_view_bbbsession_set($context, $bbbsession); |
54
|
|
|
|
55
|
|
|
// Validates if the BigBlueButton server is working. |
56
|
|
|
$serverversion = bigbluebuttonbn_get_server_version(); |
57
|
|
View Code Duplication |
if (is_null($serverversion)) { |
|
|
|
|
58
|
|
|
if ($bbbsession['administrator']) { |
59
|
|
|
print_error('view_error_unable_join', 'bigbluebuttonbn', |
60
|
|
|
$CFG->wwwroot.'/admin/settings.php?section=modsettingbigbluebuttonbn'); |
61
|
|
|
exit; |
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
|
|
|
print_error('view_error_unable_join_student', 'bigbluebuttonbn', |
69
|
|
|
$CFG->wwwroot.'/course/view.php?id='.$bigbluebuttonbn->course); |
70
|
|
|
exit; |
71
|
|
|
} |
72
|
|
|
$bbbsession['serverversion'] = (string) $serverversion; |
73
|
|
|
|
74
|
|
|
// Mark viewed by user (if required). |
75
|
|
|
$completion = new completion_info($course); |
76
|
|
|
$completion->set_module_viewed($cm); |
77
|
|
|
|
78
|
|
|
// Print the page header. |
79
|
|
|
$PAGE->set_context($context); |
80
|
|
|
$PAGE->set_url($CFG->wwwroot.'/mod/bigbluebuttonbn/view.php', array('id' => $cm->id)); |
81
|
|
|
$PAGE->set_title(format_string($bigbluebuttonbn->name)); |
82
|
|
|
$PAGE->set_cacheable(false); |
83
|
|
|
$PAGE->set_heading($course->fullname); |
84
|
|
|
$PAGE->set_pagelayout('incourse'); |
85
|
|
|
|
86
|
|
|
// Validate if the user is in a role allowed to join. |
87
|
|
|
if (!has_capability('moodle/category:manage', $context) && !has_capability('mod/bigbluebuttonbn:join', $context)) { |
88
|
|
|
echo $OUTPUT->header(); |
89
|
|
|
if (isguestuser()) { |
90
|
|
|
echo $OUTPUT->confirm('<p>'.get_string('view_noguests', 'bigbluebuttonbn').'</p>'.get_string('liketologin'), |
91
|
|
|
get_login_url(), $CFG->wwwroot.'/course/view.php?id='.$course->id); |
92
|
|
|
} else { |
93
|
|
|
echo $OUTPUT->confirm('<p>'.get_string('view_nojoin', 'bigbluebuttonbn').'</p>'.get_string('liketologin'), |
94
|
|
|
get_login_url(), $CFG->wwwroot.'/course/view.php?id='.$course->id); |
95
|
|
|
} |
96
|
|
|
echo $OUTPUT->footer(); |
97
|
|
|
exit; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
// Operation URLs. |
101
|
|
|
$bbbsession['bigbluebuttonbnURL'] = $CFG->wwwroot . '/mod/bigbluebuttonbn/view.php?id=' . $bbbsession['cm']->id; |
102
|
|
|
$bbbsession['logoutURL'] = $CFG->wwwroot . '/mod/bigbluebuttonbn/bbb_view.php?action=logout&id='.$id . |
103
|
|
|
'&bn=' . $bbbsession['bigbluebuttonbn']->id; |
104
|
|
|
$bbbsession['recordingReadyURL'] = $CFG->wwwroot . '/mod/bigbluebuttonbn/bbb_broker.php?action=recording_' . |
105
|
|
|
'ready&bigbluebuttonbn=' . $bbbsession['bigbluebuttonbn']->id; |
106
|
|
|
$bbbsession['meetingEventsURL'] = $CFG->wwwroot . '/mod/bigbluebuttonbn/bbb_broker.php?action=meeting' . |
107
|
|
|
'_events&bigbluebuttonbn=' . $bbbsession['bigbluebuttonbn']->id; |
108
|
|
|
$bbbsession['joinURL'] = $CFG->wwwroot . '/mod/bigbluebuttonbn/bbb_view.php?action=join&id=' . $id . |
109
|
|
|
'&bn=' . $bbbsession['bigbluebuttonbn']->id; |
110
|
|
|
|
111
|
|
|
// Check status and set extra values. |
112
|
|
|
$activitystatus = bigbluebuttonbn_view_get_activity_status($bbbsession); |
113
|
|
View Code Duplication |
if ($activitystatus == 'ended') { |
|
|
|
|
114
|
|
|
$bbbsession['presentation'] = bigbluebuttonbn_get_presentation_array( |
115
|
|
|
$bbbsession['context'], $bbbsession['bigbluebuttonbn']->presentation); |
116
|
|
|
} else if ($activitystatus == 'open') { |
117
|
|
|
$bbbsession['presentation'] = bigbluebuttonbn_get_presentation_array( |
118
|
|
|
$bbbsession['context'], $bbbsession['bigbluebuttonbn']->presentation, $bbbsession['bigbluebuttonbn']->id); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
// Initialize session variable used across views. |
122
|
|
|
$SESSION->bigbluebuttonbn_bbbsession = $bbbsession; |
123
|
|
|
|
124
|
|
|
// Output starts. |
125
|
|
|
echo $OUTPUT->header(); |
126
|
|
|
|
127
|
|
|
bigbluebuttonbn_view_groups($bbbsession); |
128
|
|
|
|
129
|
|
|
bigbluebuttonbn_view_render($bbbsession, $activitystatus); |
130
|
|
|
|
131
|
|
|
// Output finishes. |
132
|
|
|
echo $OUTPUT->footer(); |
133
|
|
|
|
134
|
|
|
// Shows version as a comment. |
135
|
|
|
echo '<!-- '.$bbbsession['originTag'].' -->'."\n"; |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Displays the view for groups. |
139
|
|
|
* |
140
|
|
|
* @param array $bbbsession |
141
|
|
|
* @return void |
142
|
|
|
*/ |
143
|
|
|
function bigbluebuttonbn_view_groups(&$bbbsession) { |
144
|
|
|
global $CFG; |
145
|
|
|
// Find out current group mode. |
146
|
|
|
$groupmode = groups_get_activity_groupmode($bbbsession['cm']); |
147
|
|
|
if ($groupmode == NOGROUPS) { |
148
|
|
|
// No groups mode. |
149
|
|
|
return; |
150
|
|
|
} |
151
|
|
|
// Separate or visible group mode. |
152
|
|
|
$groups = groups_get_activity_allowed_groups($bbbsession['cm']); |
153
|
|
|
if (empty($groups)) { |
154
|
|
|
// No groups in this course. |
155
|
|
|
bigbluebuttonbn_view_message_box($bbbsession, get_string('view_groups_nogroups_warning', 'bigbluebuttonbn'), 'info', true); |
156
|
|
|
return; |
157
|
|
|
} |
158
|
|
|
$bbbsession['group'] = groups_get_activity_group($bbbsession['cm'], true); |
159
|
|
|
$groupname = get_string('allparticipants'); |
160
|
|
|
if ($bbbsession['group'] != 0) { |
161
|
|
|
$groupname = groups_get_group_name($bbbsession['group']); |
162
|
|
|
} |
163
|
|
|
// Assign group default values. |
164
|
|
|
$bbbsession['meetingid'] .= '['.$bbbsession['group'].']'; |
165
|
|
|
$bbbsession['meetingname'] .= ' ('.$groupname.')'; |
166
|
|
|
if (count($groups) == 0) { |
167
|
|
|
// Only the All participants group exists. |
168
|
|
|
bigbluebuttonbn_view_message_box($bbbsession, get_string('view_groups_notenrolled_warning', 'bigbluebuttonbn'), 'info'); |
169
|
|
|
return; |
170
|
|
|
} |
171
|
|
|
$context = context_module::instance($bbbsession['cm']->id); |
172
|
|
|
if (has_capability('moodle/site:accessallgroups', $context)) { |
173
|
|
|
bigbluebuttonbn_view_message_box($bbbsession, get_string('view_groups_selection_warning', 'bigbluebuttonbn')); |
174
|
|
|
} |
175
|
|
|
$urltoroot = $CFG->wwwroot.'/mod/bigbluebuttonbn/view.php?id='.$bbbsession['cm']->id; |
176
|
|
|
groups_print_activity_menu($bbbsession['cm'], $urltoroot); |
177
|
|
|
echo '<br><br>'; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* Displays the view for messages. |
182
|
|
|
* |
183
|
|
|
* @param array $bbbsession |
184
|
|
|
* @param string $message |
185
|
|
|
* @param string $type |
186
|
|
|
* @param boolean $onlymoderator |
187
|
|
|
* @return void |
188
|
|
|
*/ |
189
|
|
|
function bigbluebuttonbn_view_message_box(&$bbbsession, $message, $type = 'warning', $onlymoderator = false) { |
190
|
|
|
global $OUTPUT; |
191
|
|
|
if ($onlymoderator && !$bbbsession['moderator'] && !$bbbsession['administrator']) { |
192
|
|
|
return; |
193
|
|
|
} |
194
|
|
|
echo $OUTPUT->box_start('generalbox boxaligncenter'); |
195
|
|
|
echo '<br><div class="alert alert-' . $type . '">' . $message . '</div>'; |
196
|
|
|
echo $OUTPUT->box_end(); |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* Displays the general view. |
201
|
|
|
* |
202
|
|
|
* @param array $bbbsession |
203
|
|
|
* @param string $activity |
204
|
|
|
* @return void |
205
|
|
|
*/ |
206
|
|
|
function bigbluebuttonbn_view_render(&$bbbsession, $activity) { |
207
|
|
|
global $OUTPUT, $PAGE; |
208
|
|
|
$type = null; |
209
|
|
|
if (isset($bbbsession['bigbluebuttonbn']->type)) { |
210
|
|
|
$type = $bbbsession['bigbluebuttonbn']->type; |
211
|
|
|
} |
212
|
|
|
$typeprofiles = bigbluebuttonbn_get_instance_type_profiles(); |
213
|
|
|
$enabledfeatures = bigbluebuttonbn_get_enabled_features($typeprofiles, $type); |
214
|
|
|
$pinginterval = (int)\mod_bigbluebuttonbn\locallib\config::get('waitformoderator_ping_interval') * 1000; |
215
|
|
|
// JavaScript for locales. |
216
|
|
|
$PAGE->requires->strings_for_js(array_keys(bigbluebuttonbn_get_strings_for_js()), 'bigbluebuttonbn'); |
217
|
|
|
// JavaScript variables. |
218
|
|
|
$jsvars = array('activity' => $activity, 'ping_interval' => $pinginterval, |
219
|
|
|
'locale' => bigbluebuttonbn_get_localcode(), 'profile_features' => $typeprofiles[0]['features']); |
220
|
|
|
$output = ''; |
221
|
|
|
// Renders warning messages when configured. |
222
|
|
|
$output .= bigbluebuttonbn_view_warning_default_server($bbbsession); |
223
|
|
|
$output .= bigbluebuttonbn_view_warning_general($bbbsession); |
224
|
|
|
|
225
|
|
|
// Renders the rest of the page. |
226
|
|
|
$output .= $OUTPUT->heading($bbbsession['meetingname'], 3); |
227
|
|
|
// Renders the completed description. |
228
|
|
|
$desc = file_rewrite_pluginfile_urls($bbbsession['meetingdescription'], 'pluginfile.php', |
229
|
|
|
$bbbsession['context']->id, 'mod_bigbluebuttonbn', 'intro', null); |
230
|
|
|
$output .= $OUTPUT->heading($desc, 5); |
231
|
|
|
|
232
|
|
|
if ($enabledfeatures['showroom']) { |
233
|
|
|
$output .= bigbluebuttonbn_view_render_room($bbbsession, $activity, $jsvars); |
234
|
|
|
$PAGE->requires->yui_module('moodle-mod_bigbluebuttonbn-rooms', |
235
|
|
|
'M.mod_bigbluebuttonbn.rooms.init', array($jsvars)); |
236
|
|
|
} |
237
|
|
|
if ($enabledfeatures['showrecordings']) { |
238
|
|
|
$output .= html_writer::start_tag('div', array('id' => 'bigbluebuttonbn_view_recordings')); |
239
|
|
|
$output .= bigbluebuttonbn_view_render_recording_section($bbbsession, $type, $enabledfeatures, $jsvars); |
240
|
|
|
$output .= html_writer::end_tag('div'); |
241
|
|
|
$PAGE->requires->yui_module('moodle-mod_bigbluebuttonbn-recordings', |
242
|
|
|
'M.mod_bigbluebuttonbn.recordings.init', array($jsvars)); |
243
|
|
|
} else if ($type == BIGBLUEBUTTONBN_TYPE_RECORDING_ONLY) { |
244
|
|
|
$recordingsdisabled = get_string('view_message_recordings_disabled', 'bigbluebuttonbn'); |
245
|
|
|
$output .= bigbluebuttonbn_render_warning($recordingsdisabled, 'danger'); |
246
|
|
|
} |
247
|
|
|
echo $output.html_writer::empty_tag('br').html_writer::empty_tag('br').html_writer::empty_tag('br'); |
248
|
|
|
$PAGE->requires->yui_module('moodle-mod_bigbluebuttonbn-broker', 'M.mod_bigbluebuttonbn.broker.init', array($jsvars)); |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* Renders the view for recordings. |
253
|
|
|
* |
254
|
|
|
* @param array $bbbsession |
255
|
|
|
* @param integer $type |
256
|
|
|
* @param array $enabledfeatures |
257
|
|
|
* @param array $jsvars |
258
|
|
|
* @return string |
259
|
|
|
*/ |
260
|
|
|
function bigbluebuttonbn_view_render_recording_section(&$bbbsession, $type, $enabledfeatures, &$jsvars) { |
261
|
|
|
if ($type == BIGBLUEBUTTONBN_TYPE_ROOM_ONLY) { |
262
|
|
|
return ''; |
263
|
|
|
} |
264
|
|
|
$output = ''; |
265
|
|
|
if ($type == BIGBLUEBUTTONBN_TYPE_ALL && $bbbsession['record']) { |
266
|
|
|
$output .= html_writer::start_tag('div', array('id' => 'bigbluebuttonbn_view_recordings_header')); |
267
|
|
|
$output .= html_writer::tag('h4', get_string('view_section_title_recordings', 'bigbluebuttonbn')); |
268
|
|
|
$output .= html_writer::end_tag('div'); |
269
|
|
|
} |
270
|
|
|
if ($type == BIGBLUEBUTTONBN_TYPE_RECORDING_ONLY || $bbbsession['record']) { |
271
|
|
|
$output .= html_writer::start_tag('div', array('id' => 'bigbluebuttonbn_view_recordings_content')); |
272
|
|
|
$output .= bigbluebuttonbn_view_render_recordings($bbbsession, $enabledfeatures, $jsvars); |
273
|
|
|
$output .= html_writer::end_tag('div'); |
274
|
|
|
$output .= html_writer::start_tag('div', array('id' => 'bigbluebuttonbn_view_recordings_footer')); |
275
|
|
|
$output .= bigbluebuttonbn_view_render_imported($bbbsession, $enabledfeatures); |
276
|
|
|
$output .= html_writer::end_tag('div'); |
277
|
|
|
} |
278
|
|
|
return $output; |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
/** |
282
|
|
|
* Evaluates if the warning box should be shown. |
283
|
|
|
* |
284
|
|
|
* @param array $bbbsession |
285
|
|
|
* |
286
|
|
|
* @return boolean |
287
|
|
|
*/ |
288
|
|
|
function bigbluebuttonbn_view_warning_shown($bbbsession) { |
289
|
|
|
if (is_siteadmin($bbbsession['userID'])) { |
290
|
|
|
return true; |
291
|
|
|
} |
292
|
|
|
$generalwarningroles = explode(',', \mod_bigbluebuttonbn\locallib\config::get('general_warning_roles')); |
293
|
|
|
$userroles = bigbluebuttonbn_get_user_roles($bbbsession['context'], $bbbsession['userID']); |
294
|
|
|
foreach ($userroles as $userrole) { |
295
|
|
|
if (in_array($userrole->shortname, $generalwarningroles)) { |
296
|
|
|
return true; |
297
|
|
|
} |
298
|
|
|
} |
299
|
|
|
return false; |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
/** |
303
|
|
|
* Renders the view for room. |
304
|
|
|
* |
305
|
|
|
* @param array $bbbsession |
306
|
|
|
* @param string $activity |
307
|
|
|
* @param array $jsvars |
308
|
|
|
* |
309
|
|
|
* @return string |
310
|
|
|
*/ |
311
|
|
|
function bigbluebuttonbn_view_render_room(&$bbbsession, $activity, &$jsvars) { |
312
|
|
|
global $OUTPUT; |
313
|
|
|
// JavaScript variables for room. |
314
|
|
|
$openingtime = ''; |
315
|
|
|
if ($bbbsession['openingtime']) { |
316
|
|
|
$openingtime = get_string('mod_form_field_openingtime', 'bigbluebuttonbn').': '. |
317
|
|
|
userdate($bbbsession['openingtime']); |
318
|
|
|
} |
319
|
|
|
$closingtime = ''; |
320
|
|
|
if ($bbbsession['closingtime']) { |
321
|
|
|
$closingtime = get_string('mod_form_field_closingtime', 'bigbluebuttonbn').': '. |
322
|
|
|
userdate($bbbsession['closingtime']); |
323
|
|
|
} |
324
|
|
|
$jsvars += array( |
325
|
|
|
'meetingid' => $bbbsession['meetingid'], |
326
|
|
|
'bigbluebuttonbnid' => $bbbsession['bigbluebuttonbn']->id, |
327
|
|
|
'userlimit' => $bbbsession['userlimit'], |
328
|
|
|
'opening' => $openingtime, |
329
|
|
|
'closing' => $closingtime, |
330
|
|
|
); |
331
|
|
|
// Main box. |
332
|
|
|
$output = $OUTPUT->box_start('generalbox boxaligncenter', 'bigbluebuttonbn_view_message_box'); |
333
|
|
|
$output .= '<br><span id="status_bar"></span>'; |
334
|
|
|
$output .= '<br><span id="control_panel"></span>'; |
335
|
|
|
$output .= $OUTPUT->box_end(); |
336
|
|
|
// Action button box. |
337
|
|
|
$output .= $OUTPUT->box_start('generalbox boxaligncenter', 'bigbluebuttonbn_view_action_button_box'); |
338
|
|
|
$output .= '<br><br><span id="join_button"></span> <span id="end_button"></span>'."\n"; |
339
|
|
|
$output .= $OUTPUT->box_end(); |
340
|
|
|
if ($activity == 'ended') { |
341
|
|
|
$output .= bigbluebuttonbn_view_ended($bbbsession); |
342
|
|
|
} |
343
|
|
|
return $output; |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
/** |
347
|
|
|
* Renders the view for recordings. |
348
|
|
|
* |
349
|
|
|
* @param array $bbbsession |
350
|
|
|
* @param array $enabledfeatures |
351
|
|
|
* @param array $jsvars |
352
|
|
|
* |
353
|
|
|
* @return string |
354
|
|
|
*/ |
355
|
|
|
function bigbluebuttonbn_view_render_recordings(&$bbbsession, $enabledfeatures, &$jsvars) { |
356
|
|
|
$bigbluebuttonbnid = null; |
357
|
|
|
if ($enabledfeatures['showroom']) { |
358
|
|
|
$bigbluebuttonbnid = $bbbsession['bigbluebuttonbn']->id; |
359
|
|
|
} |
360
|
|
|
// Get recordings. |
361
|
|
|
$recordings = bigbluebuttonbn_get_recordings( |
362
|
|
|
$bbbsession['course']->id, $bigbluebuttonbnid, $enabledfeatures['showroom'], |
363
|
|
|
$bbbsession['bigbluebuttonbn']->recordings_deleted |
364
|
|
|
); |
365
|
|
|
if ($enabledfeatures['importrecordings']) { |
366
|
|
|
// Get recording links. |
367
|
|
|
$recordingsimported = bigbluebuttonbn_get_recordings_imported_array( |
368
|
|
|
$bbbsession['course']->id, $bigbluebuttonbnid, $enabledfeatures['showroom'] |
369
|
|
|
); |
370
|
|
|
/* Perform aritmetic addition instead of merge so the imported recordings corresponding to existent |
371
|
|
|
* recordings are not included. */ |
372
|
|
|
if ($bbbsession['bigbluebuttonbn']->recordings_imported) { |
373
|
|
|
$recordings = $recordingsimported; |
374
|
|
|
} else { |
375
|
|
|
$recordings += $recordingsimported; |
376
|
|
|
} |
377
|
|
|
} |
378
|
|
|
if (empty($recordings) || array_key_exists('messageKey', $recordings)) { |
379
|
|
|
// There are no recordings to be shown. |
380
|
|
|
return html_writer::div(get_string('view_message_norecordings', 'bigbluebuttonbn'), '', |
381
|
|
|
array('id' => 'bigbluebuttonbn_recordings_table')); |
382
|
|
|
} |
383
|
|
|
// There are recordings for this meeting. |
384
|
|
|
// JavaScript variables for recordings. |
385
|
|
|
$jsvars += array( |
386
|
|
|
'recordings_html' => $bbbsession['bigbluebuttonbn']->recordings_html == '1', |
387
|
|
|
); |
388
|
|
|
// If there are meetings with recordings load the data to the table. |
389
|
|
|
if ($bbbsession['bigbluebuttonbn']->recordings_html) { |
390
|
|
|
// Render a plain html table. |
391
|
|
|
return bigbluebuttonbn_output_recording_table($bbbsession, $recordings)."\n"; |
392
|
|
|
} |
393
|
|
|
// JavaScript variables for recordings with YUI. |
394
|
|
|
$jsvars += array( |
395
|
|
|
'columns' => bigbluebuttonbn_get_recording_columns($bbbsession), |
396
|
|
|
'data' => bigbluebuttonbn_get_recording_data($bbbsession, $recordings), |
397
|
|
|
); |
398
|
|
|
// Render a YUI table. |
399
|
|
|
return html_writer::div('', '', array('id' => 'bigbluebuttonbn_recordings_table')); |
400
|
|
|
} |
401
|
|
|
|
402
|
|
|
/** |
403
|
|
|
* Renders the view for importing recordings. |
404
|
|
|
* |
405
|
|
|
* @param array $bbbsession |
406
|
|
|
* @param array $enabledfeatures |
407
|
|
|
* |
408
|
|
|
* @return string |
409
|
|
|
*/ |
410
|
|
|
function bigbluebuttonbn_view_render_imported($bbbsession, $enabledfeatures) { |
411
|
|
|
global $CFG; |
412
|
|
|
if (!$enabledfeatures['importrecordings'] || !$bbbsession['importrecordings']) { |
413
|
|
|
return ''; |
414
|
|
|
} |
415
|
|
|
$button = html_writer::tag('input', '', |
416
|
|
|
array('type' => 'button', |
417
|
|
|
'value' => get_string('view_recording_button_import', 'bigbluebuttonbn'), |
418
|
|
|
'class' => 'btn btn-secondary', |
419
|
|
|
'onclick' => 'window.location=\''.$CFG->wwwroot.'/mod/bigbluebuttonbn/import_view.php?bn='. |
420
|
|
|
$bbbsession['bigbluebuttonbn']->id.'\'')); |
421
|
|
|
$output = html_writer::empty_tag('br'); |
422
|
|
|
$output .= html_writer::tag('span', $button, array('id' => 'import_recording_links_button')); |
423
|
|
|
$output .= html_writer::tag('span', '', array('id' => 'import_recording_links_table')); |
424
|
|
|
return $output; |
425
|
|
|
} |
426
|
|
|
|
427
|
|
|
/** |
428
|
|
|
* Renders the content for ended meeting. |
429
|
|
|
* |
430
|
|
|
* @param array $bbbsession |
431
|
|
|
* |
432
|
|
|
* @return string |
433
|
|
|
*/ |
434
|
|
|
function bigbluebuttonbn_view_ended(&$bbbsession) { |
435
|
|
|
global $OUTPUT; |
436
|
|
|
if (!is_null($bbbsession['presentation']['url'])) { |
437
|
|
|
$attributes = array('title' => $bbbsession['presentation']['name']); |
438
|
|
|
$icon = new pix_icon($bbbsession['presentation']['icon'], $bbbsession['presentation']['mimetype_description']); |
439
|
|
|
return '<h4>'.get_string('view_section_title_presentation', 'bigbluebuttonbn').'</h4>'. |
440
|
|
|
$OUTPUT->action_icon($bbbsession['presentation']['url'], $icon, null, array(), false). |
441
|
|
|
$OUTPUT->action_link($bbbsession['presentation']['url'], |
442
|
|
|
$bbbsession['presentation']['name'], null, $attributes).'<br><br>'; |
443
|
|
|
} |
444
|
|
|
return ''; |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
/** |
448
|
|
|
* Renders a default server warning message when using test-install. |
449
|
|
|
* |
450
|
|
|
* @param array $bbbsession |
451
|
|
|
* |
452
|
|
|
* @return string |
453
|
|
|
*/ |
454
|
|
|
function bigbluebuttonbn_view_warning_default_server(&$bbbsession) { |
455
|
|
|
if (!is_siteadmin($bbbsession['userID'])) { |
456
|
|
|
return ''; |
457
|
|
|
} |
458
|
|
|
if (BIGBLUEBUTTONBN_DEFAULT_SERVER_URL != \mod_bigbluebuttonbn\locallib\config::get('server_url')) { |
459
|
|
|
return ''; |
460
|
|
|
} |
461
|
|
|
return bigbluebuttonbn_render_warning(get_string('view_warning_default_server', 'bigbluebuttonbn'), 'warning'); |
462
|
|
|
} |
463
|
|
|
|
464
|
|
|
/** |
465
|
|
|
* Renders a general warning message when it is configured. |
466
|
|
|
* |
467
|
|
|
* @param array $bbbsession |
468
|
|
|
* |
469
|
|
|
* @return string |
470
|
|
|
*/ |
471
|
|
|
function bigbluebuttonbn_view_warning_general(&$bbbsession) { |
472
|
|
|
if (!bigbluebuttonbn_view_warning_shown($bbbsession)) { |
473
|
|
|
return ''; |
474
|
|
|
} |
475
|
|
|
return bigbluebuttonbn_render_warning( |
476
|
|
|
(string)\mod_bigbluebuttonbn\locallib\config::get('general_warning_message'), |
477
|
|
|
(string)\mod_bigbluebuttonbn\locallib\config::get('general_warning_box_type'), |
478
|
|
|
(string)\mod_bigbluebuttonbn\locallib\config::get('general_warning_button_href'), |
479
|
|
|
(string)\mod_bigbluebuttonbn\locallib\config::get('general_warning_button_text'), |
480
|
|
|
(string)\mod_bigbluebuttonbn\locallib\config::get('general_warning_button_class') |
481
|
|
|
); |
482
|
|
|
} |
483
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.