Completed
Push — master ( 5b2228...956655 )
by Jesus
02:03
created

lib.php ➔ bigbluebuttonbn_update_media_file()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 13
nc 4
nop 1
dl 0
loc 21
rs 9.3142
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
 * Library calls for Moodle and BigBlueButton.
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
defined('MOODLE_INTERNAL') || die;
27
28
global $CFG;
29
30
require_once($CFG->dirroot.'/calendar/lib.php');
31
require_once($CFG->dirroot.'/message/lib.php');
32
require_once($CFG->dirroot.'/mod/lti/OAuth.php');
33
require_once($CFG->libdir.'/accesslib.php');
34
require_once($CFG->libdir.'/completionlib.php');
35
require_once($CFG->libdir.'/datalib.php');
36
require_once($CFG->libdir.'/coursecatlib.php');
37
require_once($CFG->libdir.'/enrollib.php');
38
require_once($CFG->libdir.'/filelib.php');
39
require_once($CFG->libdir.'/formslib.php');
40
41
if (file_exists(dirname(__FILE__).'/vendor/firebase/php-jwt/src/JWT.php')) {
42
    require_once(dirname(__FILE__).'/vendor/firebase/php-jwt/src/JWT.php');
43
}
44
45
if (!isset($CFG->bigbluebuttonbn)) {
46
    $CFG->bigbluebuttonbn = array();
47
}
48
49
if (file_exists(dirname(__FILE__).'/config.php')) {
50
    require_once(dirname(__FILE__).'/config.php');
51
    // Old BigBlueButtonBN cfg schema. For backward compatibility.
52
    global $BIGBLUEBUTTONBN_CFG;
53
54
    if (isset($BIGBLUEBUTTONBN_CFG)) {
55
        foreach ((array) $BIGBLUEBUTTONBN_CFG as $key => $value) {
56
            $cfgkey = str_replace("bigbluebuttonbn_", "", $key);
57
            $CFG->bigbluebuttonbn[$cfgkey] = $value;
58
        }
59
    }
60
}
61
62
/*
63
 * DURATIONCOMPENSATION: Feature removed by configuration
64
 */
65
$CFG->bigbluebuttonbn['scheduled_duration_enabled'] = 0;
66
/*
67
 * Remove this block when restored
68
 */
69
70
const BIGBLUEBUTTONBN_DEFAULT_SERVER_URL = 'http://test-install.blindsidenetworks.com/bigbluebutton/';
71
const BIGBLUEBUTTONBN_DEFAULT_SHARED_SECRET = '8cd8ef52e8e101574e400365b55e11a6';
72
73
const BIGBLUEBUTTONBN_LOG_EVENT_CREATE = 'Create';
74
const BIGBLUEBUTTONBN_LOG_EVENT_JOIN = 'Join';
75
const BIGBLUEBUTTONBN_LOG_EVENT_LOGOUT = 'Logout';
76
const BIGBLUEBUTTONBN_LOG_EVENT_IMPORT = 'Import';
77
const BIGBLUEBUTTONBN_LOG_EVENT_DELETE = 'Delete';
78
79
function bigbluebuttonbn_supports($feature) {
80
81
    if (!$feature) {
82
        return null;
83
    }
84
85
    $features = array(
86
        (string) FEATURE_IDNUMBER => true,
87
        (string) FEATURE_GROUPS => true,
88
        (string) FEATURE_GROUPINGS => true,
89
        (string) FEATURE_GROUPMEMBERSONLY => true,
90
        (string) FEATURE_MOD_INTRO => true,
91
        (string) FEATURE_BACKUP_MOODLE2 => true,
92
        (string) FEATURE_COMPLETION_TRACKS_VIEWS => true,
93
        (string) FEATURE_GRADE_HAS_GRADE => false,
94
        (string) FEATURE_GRADE_OUTCOMES => false,
95
        (string) FEATURE_SHOW_DESCRIPTION => true,
96
    );
97
98
    if (isset($features[(string) $feature])) {
99
        return $features[$feature];
100
    }
101
102
    return null;
103
}
104
105
/**
106
 * Given an object containing all the necessary data,
107
 * (defined by the form in mod_form.php) this function
108
 * will create a new instance and return the id number
109
 * of the new instance.
110
 *
111
 * @param object $data  An object from the form in mod_form.php
112
 * @return int The id of the newly inserted bigbluebuttonbn record
113
 */
114
function bigbluebuttonbn_add_instance($data) {
115
    global $DB;
116
    // Excecute preprocess.
117
    bigbluebuttonbn_process_pre_save($data);
118
    try {
119
        $transaction = $DB->start_delegated_transaction();
120
        // Pre-set initial values.
121
        $data->presentation = bigbluebuttonbn_get_media_file($data);
122
        // Insert a record.
123
        $data->id = $DB->insert_record('bigbluebuttonbn', $data);
124
        // Encode meetingid.
125
        $meetingid = bigbluebuttonbn_encode_meetingid($data->id);
126
        // Set the meetingid column in the bigbluebuttonbn table.
127
        $DB->set_field('bigbluebuttonbn', 'meetingid', $meetingid, array('id' => $data->id));
128
        // Add or Update attachment.
129
        bigbluebuttonbn_update_media_file($data);
130
        // Assuming the inserts work, we get to the following line.
131
        $transaction->allow_commit();
132
        // Complete the process.
133
        bigbluebuttonbn_process_post_save($data);
134
        return $data->id;
135
    } catch(Exception $e) {
136
        $transaction->rollback($e);
137
    }
138
    return null;
139
}
140
141
/**
142
 * Given an object containing all the necessary data,
143
 * (defined by the form in mod_form.php) this function
144
 * will update an existing instance with new data.
145
 *
146
 * @param object $data  An object from the form in mod_form.php
147
 * @return bool Success/Fail
148
 */
149
function bigbluebuttonbn_update_instance($data) {
150
    global $DB;
151
    bigbluebuttonbn_process_pre_save($data);
152
    try {
153
        $transaction = $DB->start_delegated_transaction();
154
        // Pre-set initial values.
155
        $data->id = $data->instance;
156
        $data->presentation = bigbluebuttonbn_get_media_file($data);
157
        // Update a record.
158
        $DB->update_record('bigbluebuttonbn', $data);
159
        // Assuming the inserts work, we get to the following line.
160
        $transaction->allow_commit();
161
        // Complete the process.
162
        bigbluebuttonbn_process_post_save($data);
163
    } catch(Exception $e) {
164
        $transaction->rollback($e);
165
        return false;
166
    }
167
    return true;
168
}
169
170
/**
171
 * Given an ID of an instance of this module,
172
 * this function will permanently delete the instance
173
 * and any data that depends on it.
174
 *
175
 * @param int $id Id of the module instance
176
 *
177
 * @return bool Success/Failure
178
 */
179
function bigbluebuttonbn_delete_instance($id) {
180
    global $DB;
181
    $bigbluebuttonbn = $DB->get_record('bigbluebuttonbn', array('id' => $id));
182
    if (!$bigbluebuttonbn) {
183
        return false;
184
    }
185
    // TODO: End the meeting if it is running.
186
187
    // Perform delete.
188
    if (!$DB->delete_records('bigbluebuttonbn', array('id' => $bigbluebuttonbn->id))) {
189
        return false;
190
    }
191
    if (!$DB->delete_records('event', array('modulename' => 'bigbluebuttonbn', 'instance' => $bigbluebuttonbn->id))) {
192
        return false;
193
    }
194
    // Log action performed.
195
    return bigbluebuttonbn_delete_instance_log($bigbluebuttonbn);
196
}
197
198
function bigbluebuttonbn_delete_instance_log($bigbluebuttonbn) {
199
    global $DB, $USER;
200
    $log = new stdClass();
201
    $log->meetingid = $bigbluebuttonbn->meetingid;
202
    $log->courseid = $bigbluebuttonbn->course;
203
    $log->bigbluebuttonbnid = $bigbluebuttonbn->id;
204
    $log->userid = $USER->id;
205
    $log->timecreated = time();
206
    $log->log = BIGBLUEBUTTONBN_LOG_EVENT_DELETE;
207
    $sql = "SELECT * FROM {bigbluebuttonbn_logs} WHERE bigbluebuttonbnid = ? AND log = ? AND " . $DB->sql_compare_text('meta') . " = ?";
208
    $logs = $DB->get_records_sql($sql, array($bigbluebuttonbn->id, BIGBLUEBUTTONBN_LOG_EVENT_CREATE, "{\"record\":true}"));
209
    $log->meta = "{\"has_recordings\":false}";
210
    if (!empty($logs)) {
211
        $log->meta = "{\"has_recordings\":true}";
212
    }
213
    if (!$DB->insert_record('bigbluebuttonbn_logs', $log)) {
214
        return false;
215
    }
216
    return true;
217
}
218
/**
219
 * Return a small object with summary information about what a
220
 * user has done with a given particular instance of this module
221
 * Used for user activity reports.
222
 * $return->time = the time they did it
223
 * $return->info = a short text description.
224
 *
225
 * @return bool
226
 */
227
function bigbluebuttonbn_user_outline($course, $user, $mod, $bigbluebuttonbn) {
0 ignored issues
show
Unused Code introduced by
The parameter $mod is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
228
    global $DB;
229
    $completed = $DB->count_records('bigbluebuttonbn_logs', array('courseid' => $course->id,
230
                                                              'bigbluebuttonbnid' => $bigbluebuttonbn->id,
231
                                                              'userid' => $user->id,
232
                                                              'log' => 'Join', ), '*');
233
    if ($completed > 0) {
234
        return fullname($user).' '.get_string('view_message_has_joined', 'bigbluebuttonbn').' '.
235
            get_string('view_message_session_for', 'bigbluebuttonbn').' '.(string) $completed.' '.
236
            get_string('view_message_times', 'bigbluebuttonbn');
237
    }
238
    return '';
239
}
240
241
/**
242
 * Print a detailed representation of what a user has done with
243
 * a given particular instance of this module, for user activity reports.
244
 *
245
 * @return bool
246
 */
247
function bigbluebuttonbn_user_complete($course, $user, $mod, $bigbluebuttonbn) {
0 ignored issues
show
Unused Code introduced by
The parameter $mod is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
248
    global $DB;
249
    $completed = $DB->count_recorda('bigbluebuttonbn_logs', array('courseid' => $course->id,
250
                                                              'bigbluebuttonbnid' => $bigbluebuttonbn->id,
251
                                                              'userid' => $user->id,
252
                                                              'log' => 'Join', ), '*', IGNORE_MULTIPLE);
253
    return $completed > 0;
254
}
255
256
/**
257
 * Returns all other caps used in module.
258
 *
259
 * @return string[]
260
 */
261
function bigbluebuttonbn_get_extra_capabilities() {
262
    return array('moodle/site:accessallgroups');
263
}
264
265
/**
266
 * List of view style log actions.
267
 *
268
 * @return string[]
269
 */
270
function bigbluebuttonbn_get_view_actions() {
271
    return array('view', 'view all');
272
}
273
274
/**
275
 * List of update style log actions.
276
 *
277
 * @return string[]
278
 */
279
function bigbluebuttonbn_get_post_actions() {
280
    return array('update', 'add', 'create', 'join', 'end', 'left', 'publish', 'unpublish', 'delete');
281
}
282
283
/**
284
 * @param array $courses
285
 * @param array $htmlarray Passed by reference
286
 */
287
function bigbluebuttonbn_print_overview($courses, &$htmlarray) {
288
    if (empty($courses) || !is_array($courses)) {
289
        return array();
290
    }
291
    $bns = get_all_instances_in_courses('bigbluebuttonbn', $courses);
292
    foreach ($bns as $bn) {
293
        $now = time();
294
        if ($bn->openingtime and (!$bn->closingtime or $bn->closingtime > $now)) {
295
            // A bigbluebuttonbn is scheduled.
296
            if (empty($htmlarray[$bn->course]['bigbluebuttonbn'])) {
297
                $htmlarray[$bn->course]['bigbluebuttonbn'] = '';
298
            }
299
            $htmlarray[$bn->course]['bigbluebuttonbn'] = bigbluebuttonbn_print_overview_element($bn, $now);
300
        }
301
    }
302
}
303
304
/**
305
 * @global object
306
 *
307
 * @param array $bigbluebuttonbn
308
 * @param int $now
309
 */
310
function bigbluebuttonbn_print_overview_element($bigbluebuttonbn, $now) {
311
    global $CFG;
312
    $start = 'started_at';
313
    if ($bigbluebuttonbn->openingtime > $now) {
314
        $start = 'starts_at';
315
    }
316
    $classes = '';
317
    if ($bigbluebuttonbn->visible) {
318
        $classes = 'class="dimmed" ';
319
    }
320
    $str  = '<div class="bigbluebuttonbn overview">'."\n";
321
    $str .= '  <div class="name">'.get_string('modulename', 'bigbluebuttonbn').':&nbsp;'."\n";
322
    $str .= '    <a '.$classes.'href="'.$CFG->wwwroot.'/mod/bigbluebuttonbn/view.php?id='.$bigbluebuttonbn->coursemodule.
323
      '">'.$bigbluebuttonbn->name.'</a>'."\n";
324
    $str .= '  </div>'."\n";
325
    $str .= '  <div class="info">'.get_string($start, 'bigbluebuttonbn').': '.userdate($bigbluebuttonbn->openingtime).
326
        '</div>'."\n";
327
    $str .= '  <div class="info">'.get_string('ends_at', 'bigbluebuttonbn').': '.userdate($bigbluebuttonbn->closingtime)
328
      .'</div>'."\n";
329
    $str .= '</div>'."\n";
330
    return $str;
331
}
332
333
/**
334
 * Given a course_module object, this function returns any
335
 * "extra" information that may be needed when printing
336
 * this activity in a course listing.
337
 * See get_array_of_activities() in course/lib.php.
338
 *
339
 * @global object
340
 *
341
 * @param object $coursemodule
342
 *
343
 * @return null|cached_cm_info
344
 */
345
function bigbluebuttonbn_get_coursemodule_info($coursemodule) {
346
    global $DB;
347
    $bigbluebuttonbn = $DB->get_record('bigbluebuttonbn', array('id' => $coursemodule->instance),
348
        'id, name, intro, introformat');
349
    if (!$bigbluebuttonbn) {
350
        return null;
351
    }
352
    $info = new cached_cm_info();
353
    $info->name = $bigbluebuttonbn->name;
354
    if ($coursemodule->showdescription) {
355
        // Convert intro to html. Do not filter cached version, filters run at display time.
356
        $info->content = format_module_intro('bigbluebuttonbn', $bigbluebuttonbn, $coursemodule->id, false);
357
    }
358
    return $info;
359
}
360
361
/**
362
 * Runs any processes that must run before a bigbluebuttonbn insert/update.
363
 *
364
 * @global object
365
 *
366
 * @param object $bigbluebuttonbn BigBlueButtonBN form data
367
 **/
368
function bigbluebuttonbn_process_pre_save(&$bigbluebuttonbn) {
369
    $bigbluebuttonbn->timemodified = time();
370
    if (!isset($bigbluebuttonbn->timecreated) || !$bigbluebuttonbn->timecreated) {
371
        $bigbluebuttonbn->timecreated = time();
372
        // Assign password only if it is a new activity.
373
        $bigbluebuttonbn->moderatorpass = bigbluebuttonbn_random_password(12);
374
        $bigbluebuttonbn->viewerpass = bigbluebuttonbn_random_password(12);
375
        $bigbluebuttonbn->timemodified = 0;
376
    }
377
    if (!isset($bigbluebuttonbn->wait)) {
378
        $bigbluebuttonbn->wait = 0;
379
    }
380
    if (!isset($bigbluebuttonbn->record)) {
381
        $bigbluebuttonbn->record = 0;
382
    }
383
    if (!isset($bigbluebuttonbn->recordings_html)) {
384
        $bigbluebuttonbn->recordings_html = 0;
385
    }
386
    if (!isset($bigbluebuttonbn->recordings_deleted)) {
387
        $bigbluebuttonbn->recordings_deleted = 0;
388
    }
389
    if (!isset($bigbluebuttonbn->recordings_imported)) {
390
        $bigbluebuttonbn->recordings_imported = 0;
391
    }
392
    $bigbluebuttonbn->participants = htmlspecialchars_decode($bigbluebuttonbn->participants);
393
}
394
395
/**
396
 * Runs any processes that must be run after a bigbluebuttonbn insert/update.
397
 *
398
 * @global object
399
 *
400
 * @param object $bigbluebuttonbn BigBlueButtonBN form data
401
 **/
402
function bigbluebuttonbn_process_post_save(&$bigbluebuttonbn) {
403
    if (isset($bigbluebuttonbn->notification) && $bigbluebuttonbn->notification) {
404
        bigbluebuttonbn_process_post_save_notification($bigbluebuttonbn);
405
    }
406
    bigbluebuttonbn_process_post_save_event($bigbluebuttonbn);
407
}
408
409
/**
410
 * Generates a message on insert/update which is sent to all users enrolled.
411
 *
412
 * @global object
413
 *
414
 * @param object $bigbluebuttonbn BigBlueButtonBN form data
415
 **/
416
function bigbluebuttonbn_process_post_save_notification(&$bigbluebuttonbn) {
417
    $action = get_string('mod_form_field_notification_msg_modified', 'bigbluebuttonbn');
418
    if (isset($bigbluebuttonbn->add) && !empty($bigbluebuttonbn->add)) {
419
        $action = get_string('mod_form_field_notification_msg_created', 'bigbluebuttonbn');
420
    }
421
    $context = context_course::instance($bigbluebuttonbn->course);
422
    \mod_bigbluebuttonbn\locallib\notifier::notification_process($context, $bigbluebuttonbn, $action);
423
}
424
425
/**
426
 * Generates an event after a bigbluebuttonbn insert/update.
427
 *
428
 * @global object
429
 *
430
 * @param object $bigbluebuttonbn BigBlueButtonBN form data
431
 **/
432
function bigbluebuttonbn_process_post_save_event(&$bigbluebuttonbn) {
433
    global $DB;
434
    // Delete evento to the calendar when/if openingtime is NOT set.
435
    if (!isset($bigbluebuttonbn->openingtime) || !$bigbluebuttonbn->openingtime) {
436
        $DB->delete_records('event', array('modulename' => 'bigbluebuttonbn', 'instance' => $bigbluebuttonbn->id));
437
        return;
438
    }
439
    // Add evento to the calendar as openingtime is set.
440
    $event = new stdClass();
441
    $event->name = $bigbluebuttonbn->name;
442
    $event->courseid = $bigbluebuttonbn->course;
443
    $event->groupid = 0;
444
    $event->userid = 0;
445
    $event->modulename = 'bigbluebuttonbn';
446
    $event->instance = $bigbluebuttonbn->id;
447
    $event->timestart = $bigbluebuttonbn->openingtime;
448
    $event->durationtime = 0;
449
    if ($bigbluebuttonbn->closingtime) {
450
        $event->durationtime = $bigbluebuttonbn->closingtime - $bigbluebuttonbn->openingtime;
451
    }
452
    $event->id = $DB->get_field('event', 'id', array('modulename' => 'bigbluebuttonbn',
453
        'instance' => $bigbluebuttonbn->id));
454
    if ($event->id) {
455
        $calendarevent = calendar_event::load($event->id);
456
        $calendarevent->update($event);
457
        return;
458
    }
459
    calendar_event::create($event);
460
}
461
462
/**
463
 * Get a full path to the file attached as a preuploaded presentation
464
 * or if there is none, set the presentation field will be set to blank.
465
 *
466
 * @param object $bigbluebuttonbn BigBlueButtonBN form data
467
 */
468
function bigbluebuttonbn_get_media_file(&$bigbluebuttonbn) {
469
    global $DB;
470
    $draftitemid = isset($bigbluebuttonbn->presentation) ? $bigbluebuttonbn->presentation : null;
471
    $context = context_module::instance($bigbluebuttonbn->coursemodule);
472
    // Set the filestorage object.
473
    $fs = get_file_storage();
474
    // Save the file if it exists that is currently in the draft area.
475
    file_save_draft_area_files($draftitemid, $context->id, 'mod_bigbluebuttonbn', 'presentation', 0);
476
    // Get the file if it exists.
477
    $files = $fs->get_area_files($context->id, 'mod_bigbluebuttonbn', 'presentation', 0,
478
        'itemid, filepath, filename', false);
479
    // Check that there is a file to process.
480
    $filesrc = '';
481
    if (count($files) == 1) {
482
        // Get the first (and only) file.
483
        $file = reset($files);
484
        $filesrc = '/'.$file->get_filename();
485
    }
486
    return $filesrc;
487
}
488
489
/**
490
 * Serves the bigbluebuttonbn attachments. Implements needed access control ;-).
491
 *
492
 * @category files
493
 *
494
 * @param stdClass $course        course object
495
 * @param stdClass $cm            course module object
496
 * @param stdClass $context       context object
497
 * @param string   $filearea      file area
498
 * @param array    $args          extra arguments
499
 * @param bool     $forcedownload whether or not force download
500
 * @param array    $options       additional options affecting the file serving
501
 *
502
 * @return false|null false if file not found, does not return if found - justsend the file
503
 */
504
function bigbluebuttonbn_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
505
    if (!bigbluebuttonbn_pluginfile_valid($context, $filearea)) {
506
        return false;
507
    }
508
    $file = bigbluebuttonbn_pluginfile_file($course, $cm, $context, $filearea, $args);
509
    if (!$file) {
510
        return false;
511
    }
512
    // Finally send the file.
513
    send_stored_file($file, 0, 0, $forcedownload, $options); // download MUST be forced - security!
514
}
515
516
function bigbluebuttonbn_pluginfile_valid($context, $filearea) {
517
    if ($context->contextlevel != CONTEXT_MODULE) {
518
        return false;
519
    }
520
    if ($filearea !== 'presentation') {
521
        return false;
522
    }
523
    if (!array_key_exists($filearea, bigbluebuttonbn_get_file_areas())) {
524
        return false;
525
    }
526
    return true;
527
}
528
529
function bigbluebuttonbn_pluginfile_file($course, $cm, $context, $filearea, $args) {
530
    $filename = bigbluebuttonbn_pluginfile_filename($course, $cm, $context, $args);
531
    if (!$filename) {
532
        return false;
533
    }
534
    $fullpath = "/$context->id/mod_bigbluebuttonbn/$filearea/0/".$filename;
535
    $fs = get_file_storage();
536
    $file = $fs->get_file_by_hash(sha1($fullpath));
537
    if (!$file || $file->is_directory()) {
538
        return false;
539
    }
540
    return $file;
541
}
542
543
function bigbluebuttonbn_pluginfile_filename($course, $cm, $context, $args) {
544
    global $DB;
545
    if (count($args) > 1) {
546
        if (!$bigbluebuttonbn = $DB->get_record('bigbluebuttonbn', array('id' => $cm->instance))) {
547
            return;
548
        }
549
        $cache = cache::make_from_params(cache_store::MODE_APPLICATION, 'mod_bigbluebuttonbn', 'presentation_cache');
550
        $noncekey = sha1($bigbluebuttonbn->id);
551
        $presentationnonce = $cache->get($noncekey);
552
        $noncevalue = $presentationnonce['value'];
553
        $noncecounter = $presentationnonce['counter'];
554
        if ($args['0'] != $noncevalue) {
555
            return;
556
        }
557
        // The nonce value is actually used twice because BigBlueButton reads the file two times.
558
        $noncecounter += 1;
559
        $cache->set($noncekey, array('value' => $noncevalue, 'counter' => $noncecounter));
560
        if ($noncecounter == 2) {
561
            $cache->delete($noncekey);
562
        }
563
        return $args['1'];
564
    }
565
    require_course_login($course, true, $cm);
566
    if (!has_capability('mod/bigbluebuttonbn:join', $context)) {
567
        return;
568
    }
569
    return implode('/', $args);
570
}
571
572
/**
573
 * Returns an array of file areas.
574
 *
575
 * @category files
576
 *
577
 * @return array a list of available file areas
578
 */
579
function bigbluebuttonbn_get_file_areas() {
580
    $areas = array();
581
    $areas['presentation'] = get_string('mod_form_block_presentation', 'bigbluebuttonbn');
582
    return $areas;
583
}
584