forked from tigusigalpa/moodle-mod_zoom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview.php
executable file
·202 lines (169 loc) · 7.25 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
<?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));
/*
* Other things you may want to set - remove if not needed.
* $PAGE->set_cacheable(false);
* $PAGE->set_focuscontrol('some-html-id');
* $PAGE->add_body_class('zoom-'.$somevar);
*/
$zoomuserid = zoom_get_user_id(false);
$userishost = ($zoomuserid == $zoom->host_id);
$service = new mod_zoom_webservice();
$showrecreate = !$service->get_meeting_info($zoom) && zoom_is_meeting_gone_error($service->lasterror);
$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');
// 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'));
$aurl = new moodle_url($zoom->start_url);
} 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()));
} 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);
// Only show sessions link to users with edit capability.
if ($iszoommanager) {
$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);
}
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));
}
if (!$zoom->webinar) {
$haspassword = (isset($zoom->password) && $zoom->password !== '');
$strhaspass = ($haspassword) ? $stryes : $strno;
$table->data[] = array($strpassprotect, $strhaspass);
if ($zoomuserid === $zoom->host_id && $haspassword) {
$table->data[] = array($strpassword, $zoom->password);
}
}
if ($userishost) {
$table->data[] = array($strjoinlink, html_writer::link($zoom->join_url, $zoom->join_url));
}
if (!$zoom->webinar) {
$strjbh = ($zoom->option_jbh) ? $stryes : $strno;
$table->data[] = array($strjoinbeforehost, $strjbh);
$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, $zoom->option_audio);
if (!$zoom->recurring) {
if ($zoom->status == ZOOM_MEETING_EXPIRED) {
$status = get_string('meeting_expired', '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();