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 |
* Recreate a meeting that exists on Moodle but cannot be found on Zoom.
|
|
|
19 |
*
|
|
|
20 |
* @package mod_zoom
|
|
|
21 |
* @copyright 2017 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 |
|
|
|
29 |
require_login();
|
|
|
30 |
// Additional access checks in zoom_get_instance_setup().
|
|
|
31 |
[$course, $cm, $zoom] = zoom_get_instance_setup();
|
|
|
32 |
|
|
|
33 |
require_sesskey();
|
|
|
34 |
$context = context_module::instance($cm->id);
|
|
|
35 |
// This capability is for managing Zoom instances in general.
|
|
|
36 |
require_capability('mod/zoom:addinstance', $context);
|
|
|
37 |
|
|
|
38 |
$PAGE->set_url('/mod/zoom/recreate.php', ['id' => $cm->id]);
|
|
|
39 |
|
|
|
40 |
// Create a new meeting with Zoom API to replace the missing one.
|
|
|
41 |
// We will use the logged-in user's Zoom account to recreate,
|
|
|
42 |
// in case the meeting's former owner no longer exists on Zoom.
|
|
|
43 |
$zoom->host_id = zoom_get_user_id();
|
|
|
44 |
|
|
|
45 |
$trackingfields = $DB->get_records('zoom_meeting_tracking_fields', ['meeting_id' => $zoom->id]);
|
|
|
46 |
foreach ($trackingfields as $trackingfield) {
|
|
|
47 |
$field = $trackingfield->tracking_field;
|
|
|
48 |
$zoom->$field = $trackingfield->value;
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
// Set the current zoom table entry to use the new meeting (meeting_id/etc).
|
|
|
52 |
$response = zoom_webservice()->create_meeting($zoom);
|
|
|
53 |
$zoom = populate_zoom_from_response($zoom, $response);
|
|
|
54 |
$zoom->exists_on_zoom = ZOOM_MEETING_EXISTS;
|
|
|
55 |
$zoom->timemodified = time();
|
|
|
56 |
$DB->update_record('zoom', $zoom);
|
|
|
57 |
|
|
|
58 |
// Return to Zoom page.
|
|
|
59 |
redirect(
|
|
|
60 |
new moodle_url('/mod/zoom/view.php', ['id' => $cm->id]),
|
|
|
61 |
get_string('recreatesuccessful', 'mod_zoom')
|
|
|
62 |
);
|