1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of the Zoom plugin for 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 |
* Load zoom meeting recording and add a record of the view.
|
|
|
19 |
*
|
|
|
20 |
* @package mod_zoom
|
|
|
21 |
* @copyright 2020 Nick Stefanski <nmstefanski@gmail.com>
|
|
|
22 |
* @author 2021 Jwalit Shah <jwalitshah@catalyst-au.net>
|
|
|
23 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
24 |
*/
|
|
|
25 |
|
|
|
26 |
require(__DIR__ . '/../../config.php');
|
|
|
27 |
require_once($CFG->libdir . '/moodlelib.php');
|
|
|
28 |
require_once(__DIR__ . '/locallib.php');
|
|
|
29 |
|
|
|
30 |
$recordingid = required_param('recordingid', PARAM_INT);
|
|
|
31 |
|
|
|
32 |
if (!get_config('zoom', 'viewrecordings')) {
|
|
|
33 |
throw new moodle_exception('recordingnotvisible', 'mod_zoom', get_string('recordingnotvisible', 'zoom'));
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
[$course, $cm, $zoom] = zoom_get_instance_setup();
|
|
|
37 |
require_login($course, true, $cm);
|
|
|
38 |
|
|
|
39 |
$context = context_module::instance($cm->id);
|
|
|
40 |
$PAGE->set_context($context);
|
|
|
41 |
|
|
|
42 |
require_capability('mod/zoom:view', $context);
|
|
|
43 |
|
|
|
44 |
// Only show recording that is visble and valid.
|
|
|
45 |
$params = [
|
|
|
46 |
'id' => $recordingid,
|
|
|
47 |
'showrecording' => 1,
|
|
|
48 |
'zoomid' => $zoom->id,
|
|
|
49 |
];
|
|
|
50 |
$rec = $DB->get_record('zoom_meeting_recordings', $params);
|
|
|
51 |
if (empty($rec)) {
|
|
|
52 |
throw new moodle_exception('recordingnotfound', 'mod_zoom', '', get_string('recordingnotfound', 'zoom'));
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
$params = ['recordingsid' => $rec->id, 'userid' => $USER->id];
|
|
|
56 |
$now = time();
|
|
|
57 |
|
|
|
58 |
// Keep track of whether someone has viewed the recording or not.
|
|
|
59 |
$view = $DB->get_record('zoom_meeting_recordings_view', $params);
|
|
|
60 |
if (!empty($view)) {
|
|
|
61 |
if (empty($view->viewed)) {
|
|
|
62 |
$view->viewed = 1;
|
|
|
63 |
$view->timemodified = $now;
|
|
|
64 |
$DB->update_record('zoom_meeting_recordings_view', $view);
|
|
|
65 |
}
|
|
|
66 |
} else {
|
|
|
67 |
$view = new stdClass();
|
|
|
68 |
$view->recordingsid = $rec->id;
|
|
|
69 |
$view->userid = $USER->id;
|
|
|
70 |
$view->viewed = 1;
|
|
|
71 |
$view->timemodified = $now;
|
|
|
72 |
$view->id = $DB->insert_record('zoom_meeting_recordings_view', $view);
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
$nexturl = new moodle_url($rec->externalurl);
|
|
|
76 |
|
|
|
77 |
redirect($nexturl);
|