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 |
* List all zoom meetings.
|
|
|
19 |
*
|
|
|
20 |
* @package mod_zoom
|
|
|
21 |
* @copyright 2015 UC Regents
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
require(__DIR__ . '/../../config.php');
|
|
|
26 |
require_once(__DIR__ . '/lib.php');
|
|
|
27 |
require_once(__DIR__ . '/locallib.php');
|
|
|
28 |
require_once($CFG->libdir . '/moodlelib.php');
|
|
|
29 |
|
|
|
30 |
$id = required_param('id', PARAM_INT); // Course.
|
|
|
31 |
|
|
|
32 |
$course = $DB->get_record('course', ['id' => $id], '*', MUST_EXIST);
|
|
|
33 |
|
|
|
34 |
require_course_login($course);
|
|
|
35 |
|
|
|
36 |
$context = context_course::instance($course->id);
|
|
|
37 |
require_capability('mod/zoom:view', $context);
|
|
|
38 |
$iszoommanager = has_capability('mod/zoom:addinstance', $context);
|
|
|
39 |
|
|
|
40 |
$params = [
|
|
|
41 |
'context' => $context,
|
|
|
42 |
];
|
|
|
43 |
$event = \mod_zoom\event\course_module_instance_list_viewed::create($params);
|
|
|
44 |
$event->add_record_snapshot('course', $course);
|
|
|
45 |
$event->trigger();
|
|
|
46 |
|
|
|
47 |
$strname = get_string('modulenameplural', 'mod_zoom');
|
|
|
48 |
$strnew = get_string('newmeetings', 'mod_zoom');
|
|
|
49 |
$strold = get_string('oldmeetings', 'mod_zoom');
|
|
|
50 |
|
|
|
51 |
$strtitle = get_string('title', 'mod_zoom');
|
|
|
52 |
$strwebinar = get_string('webinar', 'mod_zoom');
|
|
|
53 |
$strtime = get_string('meeting_time', 'mod_zoom');
|
|
|
54 |
$strduration = get_string('duration', 'mod_zoom');
|
|
|
55 |
$stractions = get_string('actions', 'mod_zoom');
|
|
|
56 |
$strsessions = get_string('sessions', 'mod_zoom');
|
|
|
57 |
|
|
|
58 |
$strmeetingstarted = get_string('meeting_started', 'mod_zoom');
|
|
|
59 |
$strjoin = get_string('join', 'mod_zoom');
|
|
|
60 |
|
|
|
61 |
$PAGE->set_url('/mod/zoom/index.php', ['id' => $id]);
|
|
|
62 |
$PAGE->navbar->add($strname);
|
|
|
63 |
$PAGE->set_title("$course->shortname: $strname");
|
|
|
64 |
$PAGE->set_heading($course->fullname);
|
|
|
65 |
$PAGE->set_pagelayout('incourse');
|
|
|
66 |
|
|
|
67 |
echo $OUTPUT->header();
|
|
|
68 |
|
|
|
69 |
if ($CFG->branch < '400') {
|
|
|
70 |
echo $OUTPUT->heading($strname);
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
if (! $zooms = get_all_instances_in_course('zoom', $course)) {
|
|
|
74 |
notice(get_string('nozooms', 'mod_zoom'), new moodle_url('/course/view.php', ['id' => $course->id]));
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
$usesections = course_format_uses_sections($course->format);
|
|
|
78 |
|
|
|
79 |
$zoomuserid = zoom_get_user_id(false);
|
|
|
80 |
|
|
|
81 |
$newtable = new html_table();
|
|
|
82 |
$newtable->attributes['class'] = 'generaltable mod_index';
|
|
|
83 |
$newhead = [$strtitle, $strtime, $strduration, $stractions];
|
|
|
84 |
$newalign = ['left', 'left', 'left', 'left'];
|
|
|
85 |
|
|
|
86 |
$oldtable = new html_table();
|
|
|
87 |
$oldhead = [$strtitle, $strtime];
|
|
|
88 |
$oldalign = ['left', 'left'];
|
|
|
89 |
|
|
|
90 |
// Show section column if there are sections.
|
|
|
91 |
if ($usesections) {
|
|
|
92 |
$strsectionname = get_string('sectionname', 'format_' . $course->format);
|
|
|
93 |
array_unshift($newhead, $strsectionname);
|
|
|
94 |
array_unshift($newalign, 'center');
|
|
|
95 |
array_unshift($oldhead, $strsectionname);
|
|
|
96 |
array_unshift($oldalign, 'center');
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
// Show sessions column only if user can edit Zoom meetings.
|
|
|
100 |
if ($iszoommanager) {
|
|
|
101 |
$newhead[] = $strsessions;
|
|
|
102 |
$newalign[] = 'left';
|
|
|
103 |
$oldhead[] = $strsessions;
|
|
|
104 |
$oldalign[] = 'left';
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
$newtable->head = $newhead;
|
|
|
108 |
$newtable->align = $newalign;
|
|
|
109 |
$oldtable->head = $oldhead;
|
|
|
110 |
$oldtable->align = $oldalign;
|
|
|
111 |
|
|
|
112 |
$now = time();
|
|
|
113 |
$modinfo = get_fast_modinfo($course);
|
|
|
114 |
$cms = $modinfo->instances['zoom'];
|
|
|
115 |
foreach ($zooms as $z) {
|
|
|
116 |
$row = [];
|
|
|
117 |
[$inprogress, $available, $finished] = zoom_get_state($z);
|
|
|
118 |
|
|
|
119 |
$cm = $cms[$z->id];
|
|
|
120 |
if ($usesections && isset($cm->sectionnum)) {
|
|
|
121 |
$row[0] = get_section_name($course, $cm->sectionnum);
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
$url = new moodle_url('view.php', ['id' => $cm->id]);
|
|
|
125 |
$row[1] = html_writer::link($url, $cm->get_formatted_name());
|
|
|
126 |
if ($z->webinar) {
|
|
|
127 |
$row[1] .= " ($strwebinar)";
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
// Get start time column information.
|
|
|
131 |
if ($z->recurring && $z->recurrence_type == ZOOM_RECURRINGTYPE_NOTIME) {
|
|
|
132 |
$displaytime = get_string('recurringmeeting', 'mod_zoom');
|
|
|
133 |
$displaytime .= html_writer::empty_tag('br');
|
|
|
134 |
$displaytime .= get_string('recurringmeetingexplanation', 'mod_zoom');
|
|
|
135 |
} else if ($z->recurring && $z->recurrence_type != ZOOM_RECURRINGTYPE_NOTIME) {
|
|
|
136 |
$displaytime = get_string('recurringmeeting', 'mod_zoom');
|
|
|
137 |
$displaytime .= html_writer::empty_tag('br');
|
|
|
138 |
if (($nextoccurrence = zoom_get_next_occurrence($z)) > 0) {
|
|
|
139 |
$displaytime .= get_string('nextoccurrence', 'mod_zoom') . ': ' . userdate($nextoccurrence);
|
|
|
140 |
} else {
|
|
|
141 |
$displaytime .= get_string('nooccurrenceleft', 'mod_zoom');
|
|
|
142 |
}
|
|
|
143 |
} else {
|
|
|
144 |
$displaytime = userdate($z->start_time);
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
$report = new moodle_url('report.php', ['id' => $cm->id]);
|
|
|
148 |
$sessions = html_writer::link($report, $strsessions);
|
|
|
149 |
|
|
|
150 |
if ($finished) {
|
|
|
151 |
$row[2] = $displaytime;
|
|
|
152 |
if ($iszoommanager) {
|
|
|
153 |
$row[3] = $sessions;
|
|
|
154 |
}
|
|
|
155 |
|
|
|
156 |
$oldtable->data[] = $row;
|
|
|
157 |
} else {
|
|
|
158 |
if ($inprogress) {
|
|
|
159 |
$label = html_writer::tag('span', $strmeetingstarted, ['class' => 'label label-info zoom-info']);
|
|
|
160 |
$row[2] = html_writer::tag('div', $label);
|
|
|
161 |
} else {
|
|
|
162 |
$row[2] = $displaytime;
|
|
|
163 |
}
|
|
|
164 |
|
|
|
165 |
$row[3] = ($z->recurring && $z->recurrence_type == ZOOM_RECURRINGTYPE_NOTIME) ? '--' : format_time($z->duration);
|
|
|
166 |
|
|
|
167 |
if ($available) {
|
|
|
168 |
$buttonhtml = html_writer::tag('button', $strjoin, ['type' => 'submit', 'class' => 'btn btn-primary']);
|
|
|
169 |
$aurl = new moodle_url('/mod/zoom/loadmeeting.php', ['id' => $cm->id]);
|
|
|
170 |
$buttonhtml .= html_writer::input_hidden_params($aurl);
|
|
|
171 |
$row[4] = html_writer::tag('form', $buttonhtml, ['action' => $aurl->out_omit_querystring(), 'target' => '_blank']);
|
|
|
172 |
} else {
|
|
|
173 |
$row[4] = '--';
|
|
|
174 |
}
|
|
|
175 |
|
|
|
176 |
if ($iszoommanager) {
|
|
|
177 |
$row[] = $sessions;
|
|
|
178 |
}
|
|
|
179 |
|
|
|
180 |
$newtable->data[] = $row;
|
|
|
181 |
}
|
|
|
182 |
}
|
|
|
183 |
|
|
|
184 |
echo $OUTPUT->heading($strnew, 4);
|
|
|
185 |
echo html_writer::table($newtable);
|
|
|
186 |
echo $OUTPUT->heading($strold, 4, null, 'mod-zoom-old-meetings-header');
|
|
|
187 |
// Show refresh meeting sessions link only if user can run the 'refresh session reports' console command.
|
|
|
188 |
if (has_capability('mod/zoom:refreshsessions', $context)) {
|
|
|
189 |
$linkarguments = [
|
|
|
190 |
'courseid' => $id,
|
|
|
191 |
'start' => date('Y-m-d', strtotime('-3 days')),
|
|
|
192 |
'end' => date('Y-m-d'),
|
|
|
193 |
];
|
|
|
194 |
$url = new moodle_url($CFG->wwwroot . '/mod/zoom/console/get_meeting_report.php', $linkarguments);
|
|
|
195 |
echo html_writer::link($url, get_string('refreshreports', 'mod_zoom'), ['target' => '_blank', 'class' => 'pl-4']);
|
|
|
196 |
}
|
|
|
197 |
|
|
|
198 |
echo html_writer::table($oldtable);
|
|
|
199 |
|
|
|
200 |
echo $OUTPUT->footer();
|