Proyectos de Subversion Moodle

Rev

Rev 992 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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
 * Prints a particular instance of zoom
19
 *
20
 * You can have a rather longer description of the file as well,
21
 * if you like, and it can span multiple lines.
22
 *
23
 * @package    mod_zoom
24
 * @copyright  2015 UC Regents
25
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26
 */
27
 
28
require(__DIR__ . '/../../config.php');
29
require_once(__DIR__ . '/lib.php');
30
require_once(__DIR__ . '/locallib.php');
31
require_once($CFG->libdir . '/moodlelib.php');
32
 
33
require_login();
34
// Additional access checks in zoom_get_instance_setup().
35
[$course, $cm, $zoom] = zoom_get_instance_setup();
36
 
37
$config = get_config('zoom');
38
 
39
$context = context_module::instance($cm->id);
40
$iszoommanager = has_capability('mod/zoom:addinstance', $context);
41
 
42
$event = \mod_zoom\event\course_module_viewed::create([
43
    'objectid' => $PAGE->cm->instance,
44
    'context' => $PAGE->context,
45
]);
46
$event->add_record_snapshot('course', $PAGE->course);
47
$event->add_record_snapshot($PAGE->cm->modname, $zoom);
48
$event->trigger();
49
 
50
// Print the page header.
51
 
52
$PAGE->set_url('/mod/zoom/view.php', ['id' => $cm->id]);
53
$PAGE->set_title(format_string($zoom->name));
54
$PAGE->set_heading(format_string($course->fullname));
55
$PAGE->requires->js_call_amd("mod_zoom/toggle_text", 'init');
56
 
57
// Get Zoom user ID of current Moodle user.
58
$zoomuserid = zoom_get_user_id(false);
59
 
60
// Check if this user is the (real) host.
61
$userisrealhost = ($zoomuserid === $zoom->host_id);
62
 
63
// Get the alternative hosts of the meeting.
64
$alternativehosts = zoom_get_alternative_host_array_from_string($zoom->alternative_hosts);
65
 
66
// Check if this user is the host or an alternative host.
67
$userishost = ($userisrealhost || in_array(zoom_get_api_identifier($USER), $alternativehosts, true));
68
 
69
// Get host user from Zoom.
70
$showrecreate = false;
71
if ($zoom->exists_on_zoom == ZOOM_MEETING_EXPIRED) {
72
    $showrecreate = true;
73
} else {
74
    try {
75
        zoom_webservice()->get_meeting_webinar_info($zoom->meeting_id, $zoom->webinar);
76
    } catch (\mod_zoom\webservice_exception $error) {
77
        $showrecreate = zoom_is_meeting_gone_error($error);
78
 
79
        if ($showrecreate) {
80
            // Mark meeting as expired.
81
            $updatedata = new stdClass();
82
            $updatedata->id = $zoom->id;
83
            $updatedata->exists_on_zoom = ZOOM_MEETING_EXPIRED;
84
            $DB->update_record('zoom', $updatedata);
85
 
86
            $zoom->exists_on_zoom = ZOOM_MEETING_EXPIRED;
87
        }
88
    } catch (moodle_exception $error) {
89
        // Ignore other exceptions.
90
        debugging($error->getMessage());
91
    }
92
}
93
 
94
$isrecurringnotime = ($zoom->recurring && $zoom->recurrence_type == ZOOM_RECURRINGTYPE_NOTIME);
95
 
96
$stryes = get_string('yes');
97
$strno = get_string('no');
98
$strstart = get_string('start_meeting', 'mod_zoom');
99
$strjoin = get_string('join_meeting', 'mod_zoom');
100
$strregister = get_string('register', 'mod_zoom');
101
$strtime = get_string('meeting_time', 'mod_zoom');
102
$strduration = get_string('duration', 'mod_zoom');
103
$strpassprotect = get_string('passwordprotected', 'mod_zoom');
104
$strpassword = get_string('password', 'mod_zoom');
105
$strjoinlink = get_string('joinlink', 'mod_zoom');
106
$strencryption = get_string('option_encryption_type', 'mod_zoom');
107
$strencryptionenhanced = get_string('option_encryption_type_enhancedencryption', 'mod_zoom');
108
$strencryptionendtoend = get_string('option_encryption_type_endtoendencryption', 'mod_zoom');
109
$strjoinbeforehost = get_string('joinbeforehost', 'mod_zoom');
110
$strstartvideohost = get_string('starthostjoins', 'mod_zoom');
111
$strstartvideopart = get_string('startpartjoins', 'mod_zoom');
112
$straudioopt = get_string('option_audio', 'mod_zoom');
113
$strstatus = get_string('status', 'mod_zoom');
114
$strall = get_string('allmeetings', 'mod_zoom');
115
$strwwaitingroom = get_string('waitingroom', 'mod_zoom');
116
$strmuteuponentry = get_string('option_mute_upon_entry', 'mod_zoom');
117
$strauthenticatedusers = get_string('option_authenticated_users', 'mod_zoom');
118
$strhost = get_string('host', 'mod_zoom');
119
$strmeetinginvite = get_string('meeting_invite', 'mod_zoom');
120
$strmeetinginviteshow = get_string('meeting_invite_show', 'mod_zoom');
121
 
122
// Output starts here.
123
echo $OUTPUT->header();
124
 
125
if ($CFG->branch < '400') {
126
    echo $OUTPUT->heading(format_string($zoom->name), 2);
127
}
128
 
129
// Show notification if the meeting does not exist on Zoom.
130
if ($showrecreate) {
131
    // Only show recreate/delete links in the message for users that can edit.
132
    if ($iszoommanager) {
133
        $message = get_string('zoomerr_meetingnotfound', 'mod_zoom', zoom_meetingnotfound_param($cm->id));
134
        $style = \core\output\notification::NOTIFY_ERROR;
135
    } else {
136
        $message = get_string('zoomerr_meetingnotfound_info', 'mod_zoom');
137
        $style = \core\output\notification::NOTIFY_WARNING;
138
    }
139
 
140
    echo $OUTPUT->notification($message, $style);
141
}
142
 
143
// Show intro.
144
if ($zoom->intro && $CFG->branch < '400') {
145
    echo $OUTPUT->box(format_module_intro('zoom', $zoom, $cm->id), 'generalbox mod_introbox', 'intro');
146
}
147
 
148
// Supplementary feature: Meeting capacity warning.
149
// Only show if the admin did not disable this feature completely.
150
if (!$showrecreate && $config->showcapacitywarning == true) {
151
    // Only show if the user viewing this is the host.
152
    if ($userishost) {
153
        // Get meeting capacity.
154
        $meetingcapacity = zoom_get_meeting_capacity($zoom->host_id, $zoom->webinar);
155
 
156
        // Get number of course participants who are eligible to join the meeting.
157
        $eligiblemeetingparticipants = zoom_get_eligible_meeting_participants($context);
158
 
159
        // If the number of eligible course participants exceeds the meeting capacity, output a warning.
160
        if ($eligiblemeetingparticipants > $meetingcapacity) {
161
            // Compose warning string.
162
            $participantspageurl = new moodle_url('/user/index.php', ['id' => $course->id]);
163
            $meetingcapacityplaceholders = [
164
                'meetingcapacity' => $meetingcapacity,
165
                'eligiblemeetingparticipants' => $eligiblemeetingparticipants,
166
                'zoomprofileurl' => $config->zoomurl . '/profile',
167
                'courseparticipantsurl' => $participantspageurl->out(),
168
                'hostname' => zoom_get_user_display_name($zoom->host_id),
169
            ];
170
            $meetingcapacitywarning = get_string('meetingcapacitywarningheading', 'mod_zoom');
171
            $meetingcapacitywarning .= html_writer::empty_tag('br');
172
            if ($userisrealhost == true) {
173
                $meetingcapacitywarning .= get_string(
174
                    'meetingcapacitywarningbodyrealhost',
175
                    'mod_zoom',
176
                    $meetingcapacityplaceholders
177
                );
178
            } else {
179
                $meetingcapacitywarning .= get_string(
180
                    'meetingcapacitywarningbodyalthost',
181
                    'mod_zoom',
182
                    $meetingcapacityplaceholders
183
                );
184
            }
185
 
186
            $meetingcapacitywarning .= html_writer::empty_tag('br');
187
            if ($userisrealhost == true) {
188
                $meetingcapacitywarning .= get_string('meetingcapacitywarningcontactrealhost', 'mod_zoom');
189
            } else {
190
                $meetingcapacitywarning .= get_string('meetingcapacitywarningcontactalthost', 'mod_zoom');
191
            }
192
 
193
            // Ideally, this would use $OUTPUT->notification(), but this renderer adds a close icon to the notification which
194
            // does not make sense here. So we build the notification manually.
195
            echo html_writer::tag('div', $meetingcapacitywarning, ['class' => 'alert alert-warning']);
196
        }
197
    }
198
}
199
 
200
// Get meeting state from Zoom.
201
[$inprogress, $available, $finished] = zoom_get_state($zoom);
202
 
203
// Show join meeting button or unavailability note.
204
if (!$showrecreate) {
205
    // If registration is required, check the registration.
206
    if (!$userishost && $zoom->registration != ZOOM_REGISTRATION_OFF) {
207
        $userisregistered = zoom_is_user_registered_for_meeting($USER->email, $zoom->meeting_id, $zoom->webinar);
208
 
209
        // Unregistered users are allowed to register.
210
        if (!$userisregistered) {
211
            $available = true;
212
        }
213
    }
214
 
215
    if ($available) {
216
        // Show join meeting button.
217
        if ($userishost) {
218
            $buttonhtml = html_writer::tag('button', $strstart, ['type' => 'submit', 'class' => 'btn btn-success']);
219
        } else {
220
            $btntext = $strjoin;
221
            // If user is not already registered, use register text.
222
            if ($zoom->registration != ZOOM_REGISTRATION_OFF && !$userisregistered) {
223
                $btntext = $strregister;
224
            }
225
 
226
            $buttonhtml = html_writer::tag('button', $btntext, ['type' => 'submit', 'class' => 'btn btn-primary']);
227
        }
228
 
229
        $aurl = new moodle_url('/mod/zoom/loadmeeting.php', ['id' => $cm->id]);
230
        $buttonhtml .= html_writer::input_hidden_params($aurl);
231
        $link = html_writer::tag('form', $buttonhtml, ['action' => $aurl->out_omit_querystring(), 'target' => '_blank']);
232
    } else {
233
        // Get unavailability note.
234
        $unavailabilitynote = zoom_get_unavailability_note($zoom, $finished);
235
 
236
        // Show unavailability note.
237
        // Ideally, this would use $OUTPUT->notification(), but this renderer adds a close icon to the notification which does not
238
        // make sense here. So we build the notification manually.
239
        $link = html_writer::tag('div', $unavailabilitynote, ['class' => 'alert alert-primary']);
240
    }
241
 
242
    echo $OUTPUT->box_start('generalbox text-center');
243
    echo $link;
244
    echo $OUTPUT->box_end();
245
}
246
 
247
if ($zoom->show_schedule) {
248
    // Output "Schedule" heading.
249
    echo $OUTPUT->heading(get_string('schedule', 'mod_zoom'), 3);
250
 
251
    // Start "Schedule" table.
252
    $table = new html_table();
253
    $table->attributes['class'] = 'generaltable mod_view';
254
    $table->align = ['center', 'left'];
255
    $table->size = ['35%', '65%'];
256
    $numcolumns = 2;
257
 
258
    // Show start/end date or recurring meeting information.
259
    if ($isrecurringnotime) {
260
        $table->data[] = [get_string('recurringmeeting', 'mod_zoom'), get_string('recurringmeetingexplanation', 'mod_zoom')];
261
    } else if ($zoom->recurring && $zoom->recurrence_type != ZOOM_RECURRINGTYPE_NOTIME) {
262
        $table->data[] = [get_string('recurringmeeting', 'mod_zoom'), get_string('recurringmeetingthisis', 'mod_zoom')];
263
        $nextoccurrence = zoom_get_next_occurrence($zoom);
264
        if ($nextoccurrence > 0) {
265
            $table->data[] = [get_string('nextoccurrence', 'mod_zoom'), userdate($nextoccurrence)];
266
        } else {
267
            $table->data[] = [get_string('nextoccurrence', 'mod_zoom'), get_string('nooccurrenceleft', 'mod_zoom')];
268
        }
269
 
270
        $table->data[] = [$strduration, format_time($zoom->duration)];
271
    } else {
272
        $table->data[] = [$strtime, userdate($zoom->start_time)];
273
        $table->data[] = [$strduration, format_time($zoom->duration)];
274
    }
275
 
276
    // Show recordings section if option enabled to view recordings.
277
    if (!empty($config->viewrecordings)) {
278
        $recordinghtml = null;
279
        $recordingaddurl = new moodle_url('/mod/zoom/recordings.php', ['id' => $cm->id]);
280
        $recordingaddbutton = html_writer::div(get_string('recordingview', 'mod_zoom'), 'btn btn-primary');
281
        $recordingaddbuttonhtml = html_writer::link($recordingaddurl, $recordingaddbutton, ['target' => '_blank']);
282
        $recordingaddhtml = html_writer::div($recordingaddbuttonhtml);
283
        $recordinghtml .= $recordingaddhtml;
284
 
285
        $table->data[] = [get_string('recordings', 'mod_zoom'), $recordinghtml];
286
    }
287
 
288
    // Display add-to-calendar button if meeting was found and isn't recurring and if the admin did not disable the feature.
289
    if ($config->showdownloadical != ZOOM_DOWNLOADICAL_DISABLE && !$showrecreate && !$isrecurringnotime) {
290
        $icallink = new moodle_url('/mod/zoom/exportical.php', ['id' => $cm->id]);
291
        $calendaricon = $OUTPUT->pix_icon('i/calendar', get_string('calendariconalt', 'mod_zoom'));
292
        $calendarbutton = html_writer::div($calendaricon . ' ' . get_string('downloadical', 'mod_zoom'), 'btn btn-primary');
293
        $buttonhtml = html_writer::link((string) $icallink, $calendarbutton, ['target' => '_blank']);
294
        $table->data[] = [get_string('addtocalendar', 'mod_zoom'), $buttonhtml];
295
    }
296
 
297
    // Show meeting status.
298
    if ($zoom->exists_on_zoom == ZOOM_MEETING_EXPIRED) {
299
        $status = get_string('meeting_nonexistent_on_zoom', 'mod_zoom');
300
    } else if (!$isrecurringnotime) {
301
        if ($finished) {
302
            $status = get_string('meeting_finished', 'mod_zoom');
303
        } else if ($inprogress) {
304
            $status = get_string('meeting_started', 'mod_zoom');
305
        } else {
306
            $status = get_string('meeting_not_started', 'mod_zoom');
307
        }
308
 
309
        $table->data[] = [$strstatus, $status];
310
    }
311
 
312
    // Show host.
313
    $hostdisplayname = zoom_get_user_display_name($zoom->host_id);
314
    if (isset($hostdisplayname)) {
315
        $table->data[] = [$strhost, $hostdisplayname];
316
    }
317
 
318
    // Display alternate hosts if they exist and if the admin did not disable the feature.
319
    if ($iszoommanager) {
320
        if ($config->showalternativehosts != ZOOM_ALTERNATIVEHOSTS_DISABLE && !empty($zoom->alternative_hosts)) {
321
            // If the admin did show the alternative hosts user picker, we try to show the real names of the users here.
322
            if ($config->showalternativehosts == ZOOM_ALTERNATIVEHOSTS_PICKER) {
323
                // Unfortunately, the host is not only able to add alternative hosts in Moodle with the user picker.
324
                // He is also able to add any alternative host with an email address in Zoom directly.
325
                // Thus, we get a) the array of existing Moodle user objects and b) the array of non-Moodle user mail addresses
326
                // based on the given set of alternative host email addresses.
327
                $alternativehostusers = zoom_get_users_from_alternativehosts($alternativehosts);
328
                $alternativehostnonusers = zoom_get_nonusers_from_alternativehosts($alternativehosts);
329
 
330
                // Create a comma-separated string of the existing Moodle users' fullnames.
331
                $alternativehostusersstring = implode(', ', array_map('fullname', $alternativehostusers));
332
 
333
                // Create a comma-separated string of the non-Moodle users' mail addresses.
334
                foreach ($alternativehostnonusers as &$ah) {
335
                    $ah .= ' (' . get_string('externaluser', 'mod_zoom') . ')';
336
                }
337
 
338
                $alternativehostnonusersstring = implode(', ', $alternativehostnonusers);
339
 
340
                // Concatenate both strings.
341
                // If we have existing Moodle users and non-Moodle users.
342
                if ($alternativehostusersstring != '' && $alternativehostnonusersstring != '') {
343
                    $alternativehoststring = $alternativehostusersstring . ', ' . $alternativehostnonusersstring;
344
 
345
                    // If we just have existing Moodle users.
346
                } else if ($alternativehostusersstring != '') {
347
                    $alternativehoststring = $alternativehostusersstring;
348
 
349
                    // It seems as if we just have non-Moodle users.
350
                } else {
351
                    $alternativehoststring = $alternativehostnonusersstring;
352
                }
353
 
354
                // Output the concatenated string of alternative hosts.
355
                $table->data[] = [get_string('alternative_hosts', 'mod_zoom'), $alternativehoststring];
356
 
357
                // Otherwise we stick with the plain list of email addresses as we got it from Zoom directly.
358
            } else {
359
                $table->data[] = [get_string('alternative_hosts', 'mod_zoom'), $zoom->alternative_hosts];
360
            }
361
        }
362
    }
363
 
364
    // Show sessions link to users with edit capability.
365
    if ($iszoommanager) {
366
        $sessionsurl = new moodle_url('/mod/zoom/report.php', ['id' => $cm->id]);
367
        $sessionslink = html_writer::link($sessionsurl, get_string('sessionsreport', 'mod_zoom'));
368
        $table->data[] = [get_string('sessions', 'mod_zoom'), $sessionslink];
369
    }
370
 
371
    // Output table.
372
    echo html_writer::table($table);
373
}
374
 
375
if ($zoom->show_security) {
376
    // Output "Security" heading.
377
    echo $OUTPUT->heading(get_string('security', 'mod_zoom'), 3);
378
 
379
    // Start "Security" table.
380
    $table = new html_table();
381
    $table->attributes['class'] = 'generaltable mod_view';
382
    $table->align = ['center', 'left'];
383
    $table->size = ['35%', '65%'];
384
    $numcolumns = 2;
385
 
386
    // Get passcode information.
387
    $haspassword = (isset($zoom->password) && $zoom->password !== '');
388
    $strhaspass = ($haspassword) ? $stryes : $strno;
389
    $canviewjoinurl = ($userishost || has_capability('mod/zoom:viewjoinurl', $context));
390
 
391
    // Show passcode status.
392
    $table->data[] = [$strpassprotect, $strhaspass];
393
 
394
    // Show passcode.
395
    if ($haspassword && ($canviewjoinurl || get_config('zoom', 'displaypassword'))) {
396
        $table->data[] = [$strpassword, $zoom->password];
397
    }
398
 
399
    // Show join link.
400
    if ($canviewjoinurl) {
401
        $table->data[] = [$strjoinlink, html_writer::link($zoom->join_url, $zoom->join_url, ['target' => '_blank'])];
402
    }
403
 
404
    // Show encryption type.
405
    if (!$zoom->webinar) {
406
        if ($config->showencryptiontype != ZOOM_ENCRYPTION_DISABLE) {
407
            $strenc = ($zoom->option_encryption_type === ZOOM_ENCRYPTION_TYPE_E2EE)
408
                ? $strencryptionendtoend
409
                : $strencryptionenhanced;
410
            $table->data[] = [$strencryption, $strenc];
411
        }
412
    }
413
 
414
    // Show waiting room.
415
    if (!$zoom->webinar) {
416
        $strwr = ($zoom->option_waiting_room) ? $stryes : $strno;
417
        $table->data[] = [$strwwaitingroom, $strwr];
418
    }
419
 
420
    // Show join before host.
421
    if (!$zoom->webinar) {
422
        $strjbh = ($zoom->option_jbh) ? $stryes : $strno;
423
        $table->data[] = [$strjoinbeforehost, $strjbh];
424
    }
425
 
426
    // Show authentication.
427
    $table->data[] = [$strauthenticatedusers, ($zoom->option_authenticated_users) ? $stryes : $strno];
428
 
429
    // Output table.
430
    echo html_writer::table($table);
431
}
432
 
433
if ($zoom->show_media) {
434
    // Output "Media" heading.
435
    echo $OUTPUT->heading(get_string('media', 'mod_zoom'), 3);
436
 
437
    // Start "Media" table.
438
    $table = new html_table();
439
    $table->attributes['class'] = 'generaltable mod_view';
440
    $table->align = ['center', 'left'];
441
    $table->size = ['35%', '65%'];
442
    $numcolumns = 2;
443
 
444
    // Show host video.
445
    if (!$zoom->webinar) {
446
        $strvideohost = ($zoom->option_host_video) ? $stryes : $strno;
447
        $table->data[] = [$strstartvideohost, $strvideohost];
448
    }
449
 
450
    // Show participants video.
451
    if (!$zoom->webinar) {
452
        $strparticipantsvideo = ($zoom->option_participants_video) ? $stryes : $strno;
453
        $table->data[] = [$strstartvideopart, $strparticipantsvideo];
454
    }
455
 
456
    // Show audio options.
457
    $table->data[] = [$straudioopt, get_string('audio_' . $zoom->option_audio, 'mod_zoom')];
458
 
459
    // Show audio default configuration.
460
    $table->data[] = [$strmuteuponentry, ($zoom->option_mute_upon_entry) ? $stryes : $strno];
461
 
462
    // Show dial-in information.
463
    if (
464
        !$showrecreate
465
        && ($zoom->option_audio === ZOOM_AUDIO_BOTH || $zoom->option_audio === ZOOM_AUDIO_TELEPHONY)
466
        && ($userishost || has_capability('mod/zoom:viewdialin', $context))
467
    ) {
468
        // Get meeting invitation from Zoom.
469
        $meetinginvite = zoom_webservice()->get_meeting_invitation($zoom)->get_display_string($cm->id);
470
        // Show meeting invitation if there is any.
471
        if (!empty($meetinginvite)) {
472
            $meetinginvitetext = str_replace("\r\n", '<br/>', $meetinginvite);
473
            $showbutton = html_writer::tag(
474
                'button',
475
                $strmeetinginviteshow,
476
                ['id' => 'show-more-button', 'class' => 'btn btn-link pt-0 pl-0']
477
            );
478
            $meetinginvitebody = html_writer::div(
479
                $meetinginvitetext,
480
                '',
481
                ['id' => 'show-more-body', 'style' => 'display: none;']
482
            );
483
            $table->data[] = [$strmeetinginvite, html_writer::div($showbutton . $meetinginvitebody, '')];
484
        }
485
    }
486
 
487
    // Output table.
488
    echo html_writer::table($table);
489
}
490
 
986 ariadna 491
// Supplementary feature: All meetings link.
492
// Only show if the admin did not disable this feature completely.
493
if ($config->showallmeetings != ZOOM_ALLMEETINGS_DISABLE) {
494
    $urlall = new moodle_url('/mod/zoom/index.php', ['id' => $course->id]);
495
    $linkall = html_writer::link($urlall, $strall);
496
    echo $OUTPUT->box_start('generalbox mt-4 pt-4 border-top text-center');
497
    echo $linkall;
498
    echo $OUTPUT->box_end();
499
}
985 ariadna 500
 
501
$modules = get_fast_modinfo($course->id)->get_cms();
502
 
503
foreach ($modules as $module) {
504
    $modname = $module->get_formatted_name();
505
 
993 ariadna 506
    if ($cm->id == $module->id) {
985 ariadna 507
        $modcontent = $module->get_formatted_content();
990 ariadna 508
        echo $modcontent;
985 ariadna 509
    }
510
}
511
 
512
 
1 efrain 513
// Finish the page.
514
echo $OUTPUT->footer();