-
Notifications
You must be signed in to change notification settings - Fork 108
/
recreate.php
62 lines (53 loc) · 2.27 KB
/
recreate.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
<?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/>.
/**
* Recreate a meeting that exists on Moodle but cannot be found on Zoom.
*
* @package mod_zoom
* @copyright 2017 UC Regents
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require(__DIR__ . '/../../config.php');
require_once(__DIR__ . '/lib.php');
require_once(__DIR__ . '/locallib.php');
require_login();
// Additional access checks in zoom_get_instance_setup().
[$course, $cm, $zoom] = zoom_get_instance_setup();
require_sesskey();
$context = context_module::instance($cm->id);
// This capability is for managing Zoom instances in general.
require_capability('mod/zoom:addinstance', $context);
$PAGE->set_url('/mod/zoom/recreate.php', ['id' => $cm->id]);
// Create a new meeting with Zoom API to replace the missing one.
// We will use the logged-in user's Zoom account to recreate,
// in case the meeting's former owner no longer exists on Zoom.
$zoom->host_id = zoom_get_user_id();
$trackingfields = $DB->get_records('zoom_meeting_tracking_fields', ['meeting_id' => $zoom->id]);
foreach ($trackingfields as $trackingfield) {
$field = $trackingfield->tracking_field;
$zoom->$field = $trackingfield->value;
}
// Set the current zoom table entry to use the new meeting (meeting_id/etc).
$response = zoom_webservice()->create_meeting($zoom, $cm->id);
$zoom = populate_zoom_from_response($zoom, $response);
$zoom->exists_on_zoom = ZOOM_MEETING_EXISTS;
$zoom->timemodified = time();
$DB->update_record('zoom', $zoom);
// Return to Zoom page.
redirect(
new moodle_url('/mod/zoom/view.php', ['id' => $cm->id]),
get_string('recreatesuccessful', 'mod_zoom')
);