forked from ncstate-delta/moodle-mod_zoom
-
Notifications
You must be signed in to change notification settings - Fork 1
/
recordings.php
137 lines (123 loc) · 5.61 KB
/
recordings.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?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/>.
/**
* Adding, updating, and deleting zoom meeting recordings.
*
* @package mod_zoom
* @copyright 2020 UC Regents
* @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(__DIR__ . '/lib.php');
require_once(__DIR__ . '/locallib.php');
list($course, $cm, $zoom) = zoom_get_instance_setup();
require_login($course, true, $cm);
if (!get_config('zoom', 'viewrecordings')) {
throw new moodle_exception('recordingnotvisible', 'mod_zoom', get_string('recordingnotvisible', 'zoom'));
}
$context = context_module::instance($cm->id);
// Set up the page.
$params = array('id' => $cm->id);
$url = new moodle_url('/mod/zoom/recordings.php', $params);
$PAGE->set_url($url);
$strname = $zoom->name;
$PAGE->set_title("$course->shortname: $strname");
$PAGE->set_heading($course->fullname);
$PAGE->set_pagelayout('incourse');
echo $OUTPUT->header();
echo $OUTPUT->heading($strname);
$iszoommanager = has_capability('mod/zoom:addinstance', $context);
// Set up html table.
$table = new html_table();
$table->attributes['class'] = 'generaltable mod_view';
if ($iszoommanager) {
$table->align = ['left', 'left', 'left', 'left'];
$table->head = [
get_string('recordingdate', 'mod_zoom'),
get_string('recordinglink', 'mod_zoom'),
get_string('recordingpasscode', 'mod_zoom'),
get_string('recordingshowtoggle', 'mod_zoom')
];
} else {
$table->align = ['left', 'left', 'left'];
$table->head = [
get_string('recordingdate', 'mod_zoom'),
get_string('recordinglink', 'mod_zoom'),
get_string('recordingpasscode', 'mod_zoom')
];
}
$service = new mod_zoom_webservice();
// Find all entries for this meeting in the database.
$recordings = zoom_get_meeting_recordings_grouped($zoom->id);
if (empty($recordings)) {
$cell = new html_table_cell();
$cell->colspan = count($table->head);
$cell->text = get_string('norecordings', 'mod_zoom');
$cell->style = 'text-align: center';
$row = new html_table_row([$cell]);
$table->data = [$row];
} else {
foreach ($recordings as $timestart => $grouping) {
// Output the related recordings into the same row.
$recordingdate = '';
$recordinghtml = '';
$recordingpasscode = '';
$recordingshowhtml = '';
foreach ($grouping as $recording) {
// If zoom admin -> show all recordings.
// Or if visible to students.
if ($iszoommanager || intval($recording->showrecording) === 1) {
if (empty($recordingdate)) {
$recordingdate = date('F j, Y, g:i:s a \P\T', $recording->recordingstart);
}
if (empty($recordingpasscode)) {
$recordingpasscode = $recording->passcode;
}
if ($iszoommanager && empty($recordingshowhtml)) {
$isrecordinghidden = intval($recording->showrecording) === 0;
$urlparams = [
'id' => $cm->id,
'meetinguuid' => $recording->meetinguuid,
'recordingstart' => $recording->recordingstart,
'showrecording' => ($isrecordinghidden) ? 1 : 0,
'sesskey' => sesskey(),
];
// If the user is a zoom admin, show the button to toggle whether students can see the recording or not.
$recordingshowurl = new moodle_url('/mod/zoom/showrecording.php', $urlparams);
$recordingshowtext = get_string('recordinghide', 'mod_zoom');
if ($isrecordinghidden) {
$recordingshowtext = get_string('recordingshow', 'mod_zoom');
}
$btnclass = 'btn btn-';
$btnclass .= $isrecordinghidden ? 'dark' : 'primary';
$recordingshowbutton = html_writer::div($recordingshowtext, $btnclass);
$recordingshowbuttonhtml = html_writer::link($recordingshowurl, $recordingshowbutton);
$recordingshowhtml = html_writer::div($recordingshowbuttonhtml);
}
$params = ['id' => $cm->id, 'recordingid' => $recording->id];
$recordingurl = new moodle_url('/mod/zoom/loadrecording.php', $params);
$recordinglink = html_writer::link($recordingurl, $recording->name);
$recordinglinkhtml = html_writer::span($recordinglink, 'recording-link', ['style' => 'margin-right:1rem']);
$recordinghtml .= html_writer::div($recordinglinkhtml, 'recording', ['style' => 'margin-bottom:.5rem']);
}
}
// Output only one row per grouping.
$table->data[] = [$recordingdate, $recordinghtml, $recordingpasscode, $recordingshowhtml];
}
}
echo html_writer::table($table);
echo $OUTPUT->footer();