forked from ncstate-delta/moodle-mod_zoom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview.php
executable file
·236 lines (199 loc) · 9.11 KB
/
view.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<?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/>.
/**
* Prints a particular instance of zoom
*
* You can have a rather longer description of the file as well,
* if you like, and it can span multiple lines.
*
* @package mod_zoom
* @copyright 2015 UC Regents
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Login check require_login() is called in zoom_get_instance_setup();.
// @codingStandardsIgnoreLine
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once(dirname(__FILE__).'/lib.php');
require_once(dirname(__FILE__).'/locallib.php');
require_once(dirname(__FILE__).'/../../lib/moodlelib.php');
$config = get_config('mod_zoom');
list($course, $cm, $zoom) = zoom_get_instance_setup();
$context = context_module::instance($cm->id);
$iszoommanager = has_capability('mod/zoom:addinstance', $context);
$event = \mod_zoom\event\course_module_viewed::create(array(
'objectid' => $PAGE->cm->instance,
'context' => $PAGE->context,
));
$event->add_record_snapshot('course', $PAGE->course);
$event->add_record_snapshot($PAGE->cm->modname, $zoom);
$event->trigger();
// Print the page header.
$PAGE->set_url('/mod/zoom/view.php', array('id' => $cm->id));
$PAGE->set_title(format_string($zoom->name));
$PAGE->set_heading(format_string($course->fullname));
$zoomuserid = zoom_get_user_id(false);
$alternativehosts = array();
if (!is_null($zoom->alternative_hosts)) {
$alternativehosts = explode(',', str_replace(';', ',', $zoom->alternative_hosts));
}
$userishost = ($zoomuserid === $zoom->host_id || in_array($USER->email, $alternativehosts));
$service = new mod_zoom_webservice();
$hostuser = false;
try {
$service->get_meeting_webinar_info($zoom->meeting_id, $zoom->webinar);
$showrecreate = false;
$hostuser = $service->get_user($zoom->host_id);
} catch (moodle_exception $error) {
$showrecreate = zoom_is_meeting_gone_error($error);
}
$stryes = get_string('yes');
$strno = get_string('no');
$strstart = get_string('start_meeting', 'mod_zoom');
$strjoin = get_string('join_meeting', 'mod_zoom');
$strunavailable = get_string('unavailable', 'mod_zoom');
$strtime = get_string('meeting_time', 'mod_zoom');
$strduration = get_string('duration', 'mod_zoom');
$strpassprotect = get_string('passwordprotected', 'mod_zoom');
$strpassword = get_string('password', 'mod_zoom');
$strjoinlink = get_string('join_link', 'mod_zoom');
$strjoinbeforehost = get_string('joinbeforehost', 'mod_zoom');
$strstartvideohost = get_string('starthostjoins', 'mod_zoom');
$strstartvideopart = get_string('startpartjoins', 'mod_zoom');
$straudioopt = get_string('option_audio', 'mod_zoom');
$strstatus = get_string('status', 'mod_zoom');
$strall = get_string('allmeetings', 'mod_zoom');
$strwwaitingroom = get_string('waitingroom', 'mod_zoom');
$strmuteuponentry = get_string('option_mute_upon_entry', 'mod_zoom');
$strauthenticatedusers = get_string('option_authenticated_users', 'mod_zoom');
$strhost = get_string('host', 'mod_zoom');
// Output starts here.
echo $OUTPUT->header();
if ($showrecreate) {
// Only show recreate/delete links in the message for users that can edit.
if ($iszoommanager) {
$message = get_string('zoomerr_meetingnotfound', 'mod_zoom', zoom_meetingnotfound_param($cm->id));
$style = 'notifywarning';
} else {
$message = get_string('zoomerr_meetingnotfound_info', 'mod_zoom');
$style = 'notifymessage';
}
echo $OUTPUT->notification($message, $style);
}
echo $OUTPUT->heading(format_string($zoom->name), 2);
if ($zoom->intro) {
echo $OUTPUT->box(format_module_intro('zoom', $zoom, $cm->id), 'generalbox mod_introbox', 'intro');
}
$table = new html_table();
$table->attributes['class'] = 'generaltable mod_view';
$table->align = array('center', 'left');
$numcolumns = 2;
list($inprogress, $available, $finished) = zoom_get_state($zoom);
if ($available) {
if ($userishost) {
$buttonhtml = html_writer::tag('button', $strstart, array('type' => 'submit', 'class' => 'btn btn-success'));
} else {
$buttonhtml = html_writer::tag('button', $strjoin, array('type' => 'submit', 'class' => 'btn btn-primary'));
}
$aurl = new moodle_url('/mod/zoom/loadmeeting.php', array('id' => $cm->id));
$buttonhtml .= html_writer::input_hidden_params($aurl);
$link = html_writer::tag('form', $buttonhtml, array('action' => $aurl->out_omit_querystring(), 'target' => '_blank'));
} else {
$link = html_writer::tag('span', $strunavailable, array('style' => 'font-size:20px'));
}
$title = new html_table_cell($link);
$title->header = true;
$title->colspan = $numcolumns;
$table->data[] = array($title);
if ($iszoommanager) {
// Only show sessions link to users with edit capability.
$sessionsurl = new moodle_url('/mod/zoom/report.php', array('id' => $cm->id));
$sessionslink = html_writer::link($sessionsurl, get_string('sessions', 'mod_zoom'));
$sessions = new html_table_cell($sessionslink);
$sessions->colspan = $numcolumns;
$table->data[] = array($sessions);
// Display alternate hosts if they exist.
if (!empty($zoom->alternative_hosts)) {
$table->data[] = array(get_string('alternative_hosts', 'mod_zoom'), $zoom->alternative_hosts);
}
}
// Generate add-to-calendar button if meeting was found and isn't recurring.
if (!($showrecreate || $zoom->recurring)) {
$icallink = new moodle_url('/mod/zoom/exportical.php', array('id' => $cm->id));
$calendaricon = $OUTPUT->pix_icon('i/calendar', get_string('calendariconalt', 'mod_zoom'), 'mod_zoom');
$calendarbutton = html_writer::div($calendaricon . ' ' . get_string('downloadical', 'mod_zoom'), 'btn btn-primary');
$buttonhtml = html_writer::link((string) $icallink, $calendarbutton, array('target' => '_blank'));
$table->data[] = array(get_string('addtocalendar', 'mod_zoom'), $buttonhtml);
}
if ($zoom->recurring) {
$recurringmessage = new html_table_cell(get_string('recurringmeetinglong', 'mod_zoom'));
$recurringmessage->colspan = $numcolumns;
$table->data[] = array($recurringmessage);
} else {
$table->data[] = array($strtime, userdate($zoom->start_time));
$table->data[] = array($strduration, format_time($zoom->duration));
}
$haspassword = (isset($zoom->password) && $zoom->password !== '');
$strhaspass = ($haspassword) ? $stryes : $strno;
$table->data[] = array($strpassprotect, $strhaspass);
if ($userishost && $haspassword) {
$table->data[] = array($strpassword, $zoom->password);
}
if ($userishost) {
$table->data[] = array($strjoinlink, html_writer::link($zoom->join_url, $zoom->join_url, array('target' => '_blank')));
}
if ($hostuser) {
$hostmoodleuser = new stdClass();
$hostmoodleuser->firstname = $hostuser->first_name;
$hostmoodleuser->lastname = $hostuser->last_name;
$hostmoodleuser->alternatename = '';
$hostmoodleuser->firstnamephonetic = '';
$hostmoodleuser->lastnamephonetic = '';
$hostmoodleuser->middlename = '';
$table->data[] = array($strhost, fullname($hostmoodleuser));
}
if (!$zoom->webinar) {
$strjbh = ($zoom->option_jbh) ? $stryes : $strno;
$table->data[] = array($strjoinbeforehost, $strjbh);
$strwr = ($zoom->option_waiting_room) ? $stryes : $strno;
$table->data[] = array($strwwaitingroom, $strwr);
$strvideohost = ($zoom->option_host_video) ? $stryes : $strno;
$table->data[] = array($strstartvideohost, $strvideohost);
$strparticipantsvideo = ($zoom->option_participants_video) ? $stryes : $strno;
$table->data[] = array($strstartvideopart, $strparticipantsvideo);
}
$table->data[] = array($straudioopt, get_string('audio_' . $zoom->option_audio, 'mod_zoom'));
$table->data[] = array($strmuteuponentry, ($zoom->option_mute_upon_entry) ? $stryes : $strno);
$table->data[] = array($strauthenticatedusers, ($zoom->option_authenticated_users) ? $stryes : $strno);
if (!$zoom->recurring) {
if (!$zoom->exists_on_zoom) {
$status = get_string('meeting_nonexistent_on_zoom', 'mod_zoom');
} else if ($finished) {
$status = get_string('meeting_finished', 'mod_zoom');
} else if ($inprogress) {
$status = get_string('meeting_started', 'mod_zoom');
} else {
$status = get_string('meeting_not_started', 'mod_zoom');
}
$table->data[] = array($strstatus, $status);
}
$urlall = new moodle_url('/mod/zoom/index.php', array('id' => $course->id));
$linkall = html_writer::link($urlall, $strall);
$linktoall = new html_table_cell($linkall);
$linktoall->colspan = $numcolumns;
$table->data[] = array($linktoall);
echo html_writer::table($table);
// Finish the page.
echo $OUTPUT->footer();