Completed
Push — master ( d8c9ad...1b8539 )
by Jesus
03:11
created

view.php ➔ bigbluebuttonbn_view_warning_general()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 2
nop 1
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
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
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
// Output starts.
112
echo $OUTPUT->header();
113
114
bigbluebuttonbn_view_groups($bbbsession);
115
116
bigbluebuttonbn_view_render($bbbsession, bigbluebuttonbn_view_get_activity_status($bbbsession));
117
118
// Output finishes.
119
echo $OUTPUT->footer();
120
121
// Shows version as a comment.
122
echo '<!-- '.$bbbsession['originTag'].' -->'."\n";
123
124
// Initialize session variable used across views.
125
$SESSION->bigbluebuttonbn_bbbsession = $bbbsession;
126
127
/**
128
 * Setup the bbbsession variable that is used all accross the plugin.
129
 *
130
 * @param object $context
131
 * @param array $bbbsession
132
 * @return void
133
 */
134
function bigbluebuttonbn_view_bbbsession_set($context, &$bbbsession) {
135
    global $CFG, $USER;
136
    // User data.
137
    $bbbsession['username'] = fullname($USER);
138
    $bbbsession['userID'] = $USER->id;
139
    // User roles.
140
    $bbbsession['administrator'] = is_siteadmin($bbbsession['userID']);
141
    $participantlist = bigbluebuttonbn_get_participant_list($bbbsession['bigbluebuttonbn'], $context);
142
    $bbbsession['moderator'] = bigbluebuttonbn_is_moderator(
143
        $context, json_encode($participantlist), $bbbsession['userID']);
144
    $bbbsession['managerecordings'] = ($bbbsession['administrator']
145
        || has_capability('mod/bigbluebuttonbn:managerecordings', $context));
146
    $bbbsession['importrecordings'] = ($bbbsession['managerecordings']);
147
    // Server data.
148
    $bbbsession['modPW'] = $bbbsession['bigbluebuttonbn']->moderatorpass;
149
    $bbbsession['viewerPW'] = $bbbsession['bigbluebuttonbn']->viewerpass;
150
    // Database info related to the activity.
151
    $bbbsession['meetingid'] = $bbbsession['bigbluebuttonbn']->meetingid.'-'.$bbbsession['course']->id.'-'.
152
        $bbbsession['bigbluebuttonbn']->id;
153
    $bbbsession['meetingname'] = $bbbsession['bigbluebuttonbn']->name;
154
    $bbbsession['meetingdescription'] = $bbbsession['bigbluebuttonbn']->intro;
155
    // Extra data for setting up the Meeting.
156
    $bbbsession['userlimit'] = intval((int)\mod_bigbluebuttonbn\locallib\config::get('userlimit_default'));
157
    if ((boolean)\mod_bigbluebuttonbn\locallib\config::get('userlimit_editable')) {
158
        $bbbsession['userlimit'] = intval($bbbsession['bigbluebuttonbn']->userlimit);
159
    }
160
    $bbbsession['voicebridge'] = $bbbsession['bigbluebuttonbn']->voicebridge;
161
    if ($bbbsession['bigbluebuttonbn']->voicebridge > 0) {
162
        $bbbsession['voicebridge'] = 70000 + $bbbsession['bigbluebuttonbn']->voicebridge;
163
    }
164
    $bbbsession['wait'] = $bbbsession['bigbluebuttonbn']->wait;
165
    $bbbsession['record'] = $bbbsession['bigbluebuttonbn']->record;
166
    $bbbsession['welcome'] = $bbbsession['bigbluebuttonbn']->welcome;
167
    if (!isset($bbbsession['welcome']) || $bbbsession['welcome'] == '') {
168
        $bbbsession['welcome'] = get_string('mod_form_field_welcome_default', 'bigbluebuttonbn');
169
    }
170
    if ($bbbsession['bigbluebuttonbn']->record) {
171
        $bbbsession['welcome'] .= '<br><br>'.get_string('bbbrecordwarning', 'bigbluebuttonbn');
172
    }
173
    $bbbsession['openingtime'] = $bbbsession['bigbluebuttonbn']->openingtime;
174
    $bbbsession['closingtime'] = $bbbsession['bigbluebuttonbn']->closingtime;
175
    // Additional info related to the course.
176
    $bbbsession['context'] = $context;
177
    // Metadata (origin).
178
    $bbbsession['origin'] = 'Moodle';
179
    $bbbsession['originVersion'] = $CFG->release;
180
    $parsedurl = parse_url($CFG->wwwroot);
181
    $bbbsession['originServerName'] = $parsedurl['host'];
182
    $bbbsession['originServerUrl'] = $CFG->wwwroot;
183
    $bbbsession['originServerCommonName'] = '';
184
    $bbbsession['originTag'] = 'moodle-mod_bigbluebuttonbn ('.get_config('mod_bigbluebuttonbn', 'version').')';
185
    $bbbsession['bnserver'] = bigbluebuttonbn_is_bn_server();
186
}
187
188
/**
189
 * Return the status of an activity [open|not_started|ended].
190
 *
191
 * @param array $bbbsession
192
 * @return string
193
 */
194
function bigbluebuttonbn_view_get_activity_status(&$bbbsession) {
195
    $now = time();
196
    if (!empty($bbbsession['bigbluebuttonbn']->openingtime) && $now < $bbbsession['bigbluebuttonbn']->openingtime) {
197
        // The activity has not been opened.
198
        return 'not_started';
199
    }
200
    if (!empty($bbbsession['bigbluebuttonbn']->closingtime) && $now > $bbbsession['bigbluebuttonbn']->closingtime) {
201
        // The activity has been closed.
202
        $bbbsession['presentation'] = bigbluebuttonbn_get_presentation_array(
203
            $bbbsession['context'], $bbbsession['bigbluebuttonbn']->presentation);
204
        return 'ended';
205
    }
206
    // The activity is open.
207
    $bbbsession['presentation'] = bigbluebuttonbn_get_presentation_array(
208
        $bbbsession['context'], $bbbsession['bigbluebuttonbn']->presentation, $bbbsession['bigbluebuttonbn']->id);
209
    return 'open';
210
}
211
212
/**
213
 * Displays the view for groups.
214
 *
215
 * @param array $bbbsession
216
 * @return void
217
 */
218
function bigbluebuttonbn_view_groups(&$bbbsession) {
219
    global $CFG;
220
    // Find out current group mode.
221
    $groupmode = groups_get_activity_groupmode($bbbsession['cm']);
222
    if ($groupmode == NOGROUPS) {
223
        // No groups mode.
224
        return;
225
    }
226
    // Separate or visible group mode.
227
    $groups = groups_get_activity_allowed_groups($bbbsession['cm']);
228
    if (empty($groups)) {
229
        // No groups in this course.
230
        bigbluebuttonbn_view_message_box($bbbsession, get_string('view_groups_nogroups_warning', 'bigbluebuttonbn'), 'info', true);
231
        return;
232
    }
233
    $bbbsession['group'] = groups_get_activity_group($bbbsession['cm'], true);
234
    $groupname = get_string('allparticipants');
235
    if ($bbbsession['group'] != 0) {
236
        $groupname = groups_get_group_name($bbbsession['group']);
237
    }
238
    // Assign group default values.
239
    $bbbsession['meetingid'] .= '['.$bbbsession['group'].']';
240
    $bbbsession['meetingname'] .= ' ('.$groupname.')';
241
    if (count($groups) == 0) {
242
        // Only the All participants group exists.
243
        bigbluebuttonbn_view_message_box($bbbsession, get_string('view_groups_notenrolled_warning', 'bigbluebuttonbn'), 'info');
244
        return;
245
    }
246
    $context = context_module::instance($bbbsession['cm']->id);
247
    if (has_capability('moodle/site:accessallgroups', $context)) {
248
        bigbluebuttonbn_view_message_box($bbbsession, get_string('view_groups_selection_warning', 'bigbluebuttonbn'));
249
    }
250
    $urltoroot = $CFG->wwwroot.'/mod/bigbluebuttonbn/view.php?id='.$bbbsession['cm']->id;
251
    groups_print_activity_menu($bbbsession['cm'], $urltoroot);
252
    echo '<br><br>';
253
}
254
255
/**
256
 * Displays the view for messages.
257
 *
258
 * @param array $bbbsession
259
 * @param string $message
260
 * @param string $type
261
 * @param boolean $onlymoderator
262
 * @return void
263
 */
264
function bigbluebuttonbn_view_message_box(&$bbbsession, $message, $type = 'warning', $onlymoderator = false) {
265
    global $OUTPUT;
266
    if ($onlymoderator && !$bbbsession['moderator'] && !$bbbsession['administrator']) {
267
        return;
268
    }
269
    echo $OUTPUT->box_start('generalbox boxaligncenter');
270
    echo '<br><div class="alert alert-' . $type . '">' . $message . '</div>';
271
    echo $OUTPUT->box_end();
272
}
273
274
/**
275
 * Displays the general view.
276
 *
277
 * @param array $bbbsession
278
 * @param string $activity
279
 * @return void
280
 */
281
function bigbluebuttonbn_view_render(&$bbbsession, $activity) {
282
    global $OUTPUT, $PAGE;
283
    $type = null;
284
    if (isset($bbbsession['bigbluebuttonbn']->type)) {
285
        $type = $bbbsession['bigbluebuttonbn']->type;
286
    }
287
    $typeprofiles = bigbluebuttonbn_get_instance_type_profiles();
288
    $enabledfeatures = bigbluebuttonbn_get_enabled_features($typeprofiles, $type);
289
    $pinginterval = (int)\mod_bigbluebuttonbn\locallib\config::get('waitformoderator_ping_interval') * 1000;
290
    // JavaScript for locales.
291
    $PAGE->requires->strings_for_js(array_keys(bigbluebuttonbn_get_strings_for_js()), 'bigbluebuttonbn');
292
    // JavaScript variables.
293
    $jsvars = array('activity' => $activity, 'ping_interval' => $pinginterval,
294
        'locale' => bigbluebuttonbn_get_localcode(), 'profile_features' => $typeprofiles[0]['features']);
295
    $output  = '';
296
    // Renders warning messages when configured.
297
    $output .= bigbluebuttonbn_view_warning_default_server($bbbsession);
298
    $output .= bigbluebuttonbn_view_warning_general($bbbsession);
299
    // Renders the rest of the page.
300
    $output .= $OUTPUT->heading($bbbsession['meetingname'], 3);
301
    $output .= $OUTPUT->heading($bbbsession['meetingdescription'], 5);
302
    if ($enabledfeatures['showroom']) {
303
        $output .= bigbluebuttonbn_view_render_room($bbbsession, $activity, $jsvars);
304
        $PAGE->requires->yui_module('moodle-mod_bigbluebuttonbn-rooms',
305
            'M.mod_bigbluebuttonbn.rooms.init', array($jsvars));
306
    }
307
    if ($enabledfeatures['showrecordings']) {
308
        $output .= html_writer::start_tag('div', array('id' => 'bigbluebuttonbn_view_recordings'));
309
        $output .= bigbluebuttonbn_view_render_recording_section($bbbsession, $type, $enabledfeatures, $jsvars);
310
        $output .= html_writer::end_tag('div');
311
        $PAGE->requires->yui_module('moodle-mod_bigbluebuttonbn-recordings',
312
                'M.mod_bigbluebuttonbn.recordings.init', array($jsvars));
313
    } else if ($type == BIGBLUEBUTTONBN_TYPE_RECORDING_ONLY) {
314
        $recordingsdisabled = get_string('view_message_recordings_disabled', 'bigbluebuttonbn');
315
        $output .= bigbluebuttonbn_render_warning($recordingsdisabled, 'danger');
316
    }
317
    echo $output.html_writer::empty_tag('br').html_writer::empty_tag('br').html_writer::empty_tag('br');
318
    $PAGE->requires->yui_module('moodle-mod_bigbluebuttonbn-broker', 'M.mod_bigbluebuttonbn.broker.init', array($jsvars));
319
}
320
321
/**
322
 * Renders the view for recordings.
323
 *
324
 * @param array $bbbsession
325
 * @param integer $type
326
 * @param array $enabledfeatures
327
 * @param array $jsvars
328
 * @return string
329
 */
330
function bigbluebuttonbn_view_render_recording_section(&$bbbsession, $type, $enabledfeatures, &$jsvars) {
331
    if ($type == BIGBLUEBUTTONBN_TYPE_ROOM_ONLY) {
332
        return '';
333
    }
334
    $output = '';
335
    if ($type == BIGBLUEBUTTONBN_TYPE_ALL && $bbbsession['record']) {
336
        $output .= html_writer::start_tag('div', array('id' => 'bigbluebuttonbn_view_recordings_header'));
337
        $output .= html_writer::tag('h4', get_string('view_section_title_recordings', 'bigbluebuttonbn'));
338
        $output .= html_writer::end_tag('div');
339
    }
340
    if ($type == BIGBLUEBUTTONBN_TYPE_RECORDING_ONLY || $bbbsession['record']) {
341
        $output .= html_writer::start_tag('div', array('id' => 'bigbluebuttonbn_view_recordings_content'));
342
        $output .= bigbluebuttonbn_view_render_recordings($bbbsession, $enabledfeatures, $jsvars);
343
        $output .= html_writer::end_tag('div');
344
        $output .= html_writer::start_tag('div', array('id' => 'bigbluebuttonbn_view_recordings_footer'));
345
        $output .= bigbluebuttonbn_view_render_imported($bbbsession, $enabledfeatures);
346
        $output .= html_writer::end_tag('div');
347
    }
348
    return $output;
349
}
350
351
/**
352
 * Evaluates if the warning box should be shown.
353
 *
354
 * @param array $bbbsession
355
 *
356
 * @return boolean
357
 */
358
function bigbluebuttonbn_view_warning_shown($bbbsession) {
359
    if (is_siteadmin($bbbsession['userID'])) {
360
        return true;
361
    }
362
    $generalwarningroles = explode(',', \mod_bigbluebuttonbn\locallib\config::get('general_warning_roles'));
363
    $userroles = bigbluebuttonbn_get_user_roles($bbbsession['context'], $bbbsession['userID']);
364
    foreach ($userroles as $userrole) {
365
        if (in_array($userrole->shortname, $generalwarningroles)) {
366
            return true;
367
        }
368
    }
369
    return false;
370
}
371
372
/**
373
 * Renders the view for room.
374
 *
375
 * @param array $bbbsession
376
 * @param string $activity
377
 * @param array $jsvars
378
 *
379
 * @return string
380
 */
381
function bigbluebuttonbn_view_render_room(&$bbbsession, $activity, &$jsvars) {
382
    global $OUTPUT;
383
    // JavaScript variables for room.
384
    $openingtime = '';
385
    if ($bbbsession['openingtime']) {
386
        $openingtime = get_string('mod_form_field_openingtime', 'bigbluebuttonbn').': '.
387
            userdate($bbbsession['openingtime']);
388
    }
389
    $closingtime = '';
390
    if ($bbbsession['closingtime']) {
391
        $closingtime = get_string('mod_form_field_closingtime', 'bigbluebuttonbn').': '.
392
            userdate($bbbsession['closingtime']);
393
    }
394
    $jsvars += array(
395
        'meetingid' => $bbbsession['meetingid'],
396
        'bigbluebuttonbnid' => $bbbsession['bigbluebuttonbn']->id,
397
        'userlimit' => $bbbsession['userlimit'],
398
        'opening' => $openingtime,
399
        'closing' => $closingtime,
400
    );
401
    // Main box.
402
    $output  = $OUTPUT->box_start('generalbox boxaligncenter', 'bigbluebuttonbn_view_message_box');
403
    $output .= '<br><span id="status_bar"></span>';
404
    $output .= '<br><span id="control_panel"></span>';
405
    $output .= $OUTPUT->box_end();
406
    // Action button box.
407
    $output .= $OUTPUT->box_start('generalbox boxaligncenter', 'bigbluebuttonbn_view_action_button_box');
408
    $output .= '<br><br><span id="join_button"></span>&nbsp;<span id="end_button"></span>'."\n";
409
    $output .= $OUTPUT->box_end();
410
    if ($activity == 'ended') {
411
        $output .= bigbluebuttonbn_view_ended($bbbsession);
412
    }
413
    return $output;
414
}
415
416
/**
417
 * Renders the view for recordings.
418
 *
419
 * @param array $bbbsession
420
 * @param array $enabledfeatures
421
 * @param array $jsvars
422
 *
423
 * @return string
424
 */
425
function bigbluebuttonbn_view_render_recordings(&$bbbsession, $enabledfeatures, &$jsvars) {
426
    $bigbluebuttonbnid = null;
427
    if ($enabledfeatures['showroom']) {
428
        $bigbluebuttonbnid = $bbbsession['bigbluebuttonbn']->id;
429
    }
430
    // Get recordings.
431
    $recordings = bigbluebuttonbn_get_recordings(
432
        $bbbsession['course']->id, $bigbluebuttonbnid, $enabledfeatures['showroom'],
433
        $bbbsession['bigbluebuttonbn']->recordings_deleted
434
      );
435
    if ($enabledfeatures['importrecordings']) {
436
        // Get recording links.
437
        $recordingsimported = bigbluebuttonbn_get_recordings_imported_array(
438
            $bbbsession['course']->id, $bigbluebuttonbnid, $enabledfeatures['showroom']
439
          );
440
        /* Perform aritmetic addition instead of merge so the imported recordings corresponding to existent
441
         * recordings are not included. */
442
        $recordings += $recordingsimported;
443
    }
444
    if (empty($recordings) || array_key_exists('messageKey', $recordings)) {
445
        // There are no recordings to be shown.
446
        return html_writer::div(get_string('view_message_norecordings', 'bigbluebuttonbn'), '',
447
            array('id' => 'bigbluebuttonbn_recordings_table'));
448
    }
449
    // There are recordings for this meeting.
450
    // JavaScript variables for recordings.
451
    $jsvars += array(
452
            'recordings_html' => $bbbsession['bigbluebuttonbn']->recordings_html == '1',
453
          );
454
    // If there are meetings with recordings load the data to the table.
455
    if ($bbbsession['bigbluebuttonbn']->recordings_html) {
456
        // Render a plain html table.
457
        return bigbluebuttonbn_output_recording_table($bbbsession, $recordings)."\n";
458
    }
459
    // JavaScript variables for recordings with YUI.
460
    $jsvars += array(
461
            'columns' => bigbluebuttonbn_get_recording_columns($bbbsession),
462
            'data' => bigbluebuttonbn_get_recording_data($bbbsession, $recordings),
463
          );
464
    // Render a YUI table.
465
    return html_writer::div('', '', array('id' => 'bigbluebuttonbn_recordings_table'));
466
}
467
468
/**
469
 * Renders the view for importing recordings.
470
 *
471
 * @param array $bbbsession
472
 * @param array $enabledfeatures
473
 *
474
 * @return string
475
 */
476
function bigbluebuttonbn_view_render_imported($bbbsession, $enabledfeatures) {
477
    global $CFG;
478
    if (!$enabledfeatures['importrecordings'] || !$bbbsession['importrecordings']) {
479
        return '';
480
    }
481
    $button = html_writer::tag('input', '',
482
        array('type' => 'button',
483
              'value' => get_string('view_recording_button_import', 'bigbluebuttonbn'),
484
              'class' => 'btn btn-secondary',
485
              'onclick' => 'window.location=\''.$CFG->wwwroot.'/mod/bigbluebuttonbn/import_view.php?bn='.
486
                  $bbbsession['bigbluebuttonbn']->id.'\''));
487
    $output  = html_writer::empty_tag('br');
488
    $output .= html_writer::tag('span', $button, array('id' => 'import_recording_links_button'));
489
    $output .= html_writer::tag('span', '', array('id' => 'import_recording_links_table'));
490
    return $output;
491
}
492
493
/**
494
 * Renders the content for ended meeting.
495
 *
496
 * @param array $bbbsession
497
 *
498
 * @return string
499
 */
500
function bigbluebuttonbn_view_ended(&$bbbsession) {
501
    global $OUTPUT;
502
    if (!is_null($bbbsession['presentation']['url'])) {
503
        $attributes = array('title' => $bbbsession['presentation']['name']);
504
        $icon = new pix_icon($bbbsession['presentation']['icon'], $bbbsession['presentation']['mimetype_description']);
505
        return '<h4>'.get_string('view_section_title_presentation', 'bigbluebuttonbn').'</h4>'.
506
                $OUTPUT->action_icon($bbbsession['presentation']['url'], $icon, null, array(), false).
507
                $OUTPUT->action_link($bbbsession['presentation']['url'],
508
                $bbbsession['presentation']['name'], null, $attributes).'<br><br>';
509
    }
510
    return '';
511
}
512
513
/**
514
 * Renders a default server warning message when using test-install.
515
 *
516
 * @param array $bbbsession
517
 *
518
 * @return string
519
 */
520
function bigbluebuttonbn_view_warning_default_server(&$bbbsession) {
521
    if (!is_siteadmin($bbbsession['userID'])) {
522
        return '';
523
    }
524
    if (BIGBLUEBUTTONBN_DEFAULT_SERVER_URL != \mod_bigbluebuttonbn\locallib\config::get('server_url')) {
525
        return '';
526
    }
527
    return bigbluebuttonbn_render_warning(get_string('view_warning_default_server', 'bigbluebuttonbn'), 'warning');
528
}
529
530
/**
531
 * Renders a general warning message when it is configured.
532
 *
533
 * @param array $bbbsession
534
 *
535
 * @return string
536
 */
537
function bigbluebuttonbn_view_warning_general(&$bbbsession) {
538
    if (!bigbluebuttonbn_view_warning_shown($bbbsession)) {
539
        return '';
540
    }
541
    return bigbluebuttonbn_render_warning(
542
        (string)\mod_bigbluebuttonbn\locallib\config::get('general_warning_message'),
543
        (string)\mod_bigbluebuttonbn\locallib\config::get('general_warning_box_type'),
544
        (string)\mod_bigbluebuttonbn\locallib\config::get('general_warning_button_href'),
545
        (string)\mod_bigbluebuttonbn\locallib\config::get('general_warning_button_text'),
546
        (string)\mod_bigbluebuttonbn\locallib\config::get('general_warning_button_class')
547
      );
548
}
549