forked from ncstate-delta/moodle-mod_zoom
-
Notifications
You must be signed in to change notification settings - Fork 1
/
loadrecording.php
77 lines (65 loc) · 2.55 KB
/
loadrecording.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
// This file is part of the Zoom plugin for Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Load zoom meeting recording and add a record of the view.
*
* @package mod_zoom
* @copyright 2020 Nick Stefanski <nmstefanski@gmail.com>
* @author 2021 Jwalit Shah <jwalitshah@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(__DIR__ . '/../../config.php');
require_once($CFG->libdir . '/moodlelib.php');
require_once(__DIR__ . '/locallib.php');
$recordingid = required_param('recordingid', PARAM_INT);
if (!get_config('zoom', 'viewrecordings')) {
throw new moodle_exception('recordingnotvisible', 'mod_zoom', get_string('recordingnotvisible', 'zoom'));
}
list($course, $cm, $zoom) = zoom_get_instance_setup();
require_login($course, true, $cm);
$context = context_module::instance($cm->id);
$PAGE->set_context($context);
require_capability('mod/zoom:view', $context);
// Only show recording that is visble and valid.
$params = [
'id' => $recordingid,
'showrecording' => 1,
'zoomid' => $zoom->id,
];
$rec = $DB->get_record('zoom_meeting_recordings', $params);
if (empty($rec)) {
throw new moodle_exception('recordingnotfound', 'mod_zoom', '', get_string('recordingnotfound', 'zoom'));
}
$params = array('recordingsid' => $rec->id, 'userid' => $USER->id);
$now = time();
// Keep track of whether someone has viewed the recording or not.
$view = $DB->get_record('zoom_meeting_recordings_view', $params);
if (!empty($view)) {
if (empty($view->viewed)) {
$view->viewed = 1;
$view->timemodified = $now;
$DB->update_record('zoom_meeting_recordings_view', $view);
}
} else {
$view = new stdClass();
$view->recordingsid = $rec->id;
$view->userid = $USER->id;
$view->viewed = 1;
$view->timemodified = $now;
$view->id = $DB->insert_record('zoom_meeting_recordings_view', $view);
}
$nexturl = new moodle_url($rec->externalurl);
redirect($nexturl);