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 |
$meetinguuid = required_param('meetinguuid', PARAM_TEXT);
|
|
|
31 |
$recordingstart = required_param('recordingstart', PARAM_INT);
|
|
|
32 |
$showrecording = required_param('showrecording', PARAM_INT);
|
|
|
33 |
|
|
|
34 |
if (!get_config('zoom', 'viewrecordings')) {
|
|
|
35 |
throw new moodle_exception('recordingnotvisible', 'mod_zoom', get_string('recordingnotvisible', 'zoom'));
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
[$course, $cm, $zoom] = zoom_get_instance_setup();
|
|
|
39 |
require_login($course, true, $cm);
|
|
|
40 |
|
|
|
41 |
$context = context_module::instance($cm->id);
|
|
|
42 |
$PAGE->set_context($context);
|
|
|
43 |
require_capability('mod/zoom:addinstance', $context);
|
|
|
44 |
|
|
|
45 |
$urlparams = ['id' => $cm->id];
|
|
|
46 |
$url = new moodle_url('/mod/zoom/recordings.php', $urlparams);
|
|
|
47 |
if (!confirm_sesskey()) {
|
|
|
48 |
redirect($url, get_string('sesskeyinvalid', 'mod_zoom'));
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
// Find the video recording and audio only recording pair that matches the criteria.
|
|
|
52 |
$recordings = $DB->get_records('zoom_meeting_recordings', ['meetinguuid' => $meetinguuid, 'recordingstart' => $recordingstart]);
|
|
|
53 |
if (empty($recordings)) {
|
|
|
54 |
throw new moodle_exception('recordingnotfound', 'mod_zoom', '', get_string('recordingnotfound', 'zoom'));
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
$now = time();
|
|
|
58 |
|
|
|
59 |
// Toggle the showrecording value.
|
|
|
60 |
if ($showrecording === 1 || $showrecording === 0) {
|
|
|
61 |
foreach ($recordings as $rec) {
|
|
|
62 |
$rec->showrecording = $showrecording;
|
|
|
63 |
$rec->timemodified = $now;
|
|
|
64 |
$DB->update_record('zoom_meeting_recordings', $rec);
|
|
|
65 |
}
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
redirect($url);
|