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 |
* Mobile support for zoom.
|
|
|
19 |
*
|
|
|
20 |
* @package mod_zoom
|
|
|
21 |
* @copyright 2018 Nick Stefanski <nmstefanski@gmail.com>
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
namespace mod_zoom\output;
|
|
|
26 |
|
|
|
27 |
use context_module;
|
|
|
28 |
use mod_zoom\external;
|
|
|
29 |
|
|
|
30 |
/**
|
|
|
31 |
* Mobile output class for zoom
|
|
|
32 |
*/
|
|
|
33 |
class mobile {
|
|
|
34 |
/**
|
|
|
35 |
* Returns the zoom course view for the mobile app,
|
|
|
36 |
* including meeting details and launch button (if applicable).
|
|
|
37 |
* @param array $args Arguments from tool_mobile_get_content WS
|
|
|
38 |
*
|
|
|
39 |
* @return array HTML, javascript and otherdata
|
|
|
40 |
*/
|
|
|
41 |
public static function mobile_course_view($args) {
|
|
|
42 |
global $OUTPUT, $DB;
|
|
|
43 |
|
|
|
44 |
$args = (object) $args;
|
|
|
45 |
$versionname = $args->appversioncode >= 3950 ? 'latest' : 'ionic3';
|
|
|
46 |
$cm = get_coursemodule_from_id('zoom', $args->cmid);
|
|
|
47 |
|
|
|
48 |
// Capabilities check.
|
|
|
49 |
require_login($args->courseid, false, $cm, true, true);
|
|
|
50 |
|
|
|
51 |
$context = context_module::instance($cm->id);
|
|
|
52 |
|
|
|
53 |
require_capability('mod/zoom:view', $context);
|
|
|
54 |
// Right now we're just implementing basic viewing, otherwise we may
|
|
|
55 |
// need to check other capabilities.
|
|
|
56 |
$zoom = $DB->get_record('zoom', ['id' => $cm->instance]);
|
|
|
57 |
|
|
|
58 |
// WS to get zoom state.
|
|
|
59 |
try {
|
|
|
60 |
$zoomstate = external::get_state($cm->id);
|
|
|
61 |
} catch (\Exception $e) {
|
|
|
62 |
$zoomstate = [];
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
// Format date and time.
|
|
|
66 |
$starttime = userdate($zoom->start_time);
|
|
|
67 |
$duration = format_time($zoom->duration);
|
|
|
68 |
|
|
|
69 |
// Get audio option string.
|
|
|
70 |
$optionaudio = get_string('audio_' . $zoom->option_audio, 'mod_zoom');
|
|
|
71 |
|
|
|
72 |
$data = [
|
|
|
73 |
'zoom' => $zoom,
|
|
|
74 |
'available' => $zoomstate['available'],
|
|
|
75 |
'status' => $zoomstate['status'],
|
|
|
76 |
'start_time' => $starttime,
|
|
|
77 |
'duration' => $duration,
|
|
|
78 |
'option_audio' => $optionaudio,
|
|
|
79 |
'cmid' => $cm->id,
|
|
|
80 |
'courseid' => $args->courseid,
|
|
|
81 |
];
|
|
|
82 |
|
|
|
83 |
return [
|
|
|
84 |
'templates' => [
|
|
|
85 |
[
|
|
|
86 |
'id' => 'main',
|
|
|
87 |
'html' => $OUTPUT->render_from_template("mod_zoom/mobile_view_page_$versionname", $data),
|
|
|
88 |
],
|
|
|
89 |
],
|
|
|
90 |
'javascript' => "this.loadMeeting = function(result) { window.open(result.joinurl, '_system'); };",
|
|
|
91 |
// This JS will redirect to a joinurl passed by the mod_zoom_grade_item_update WS.
|
|
|
92 |
'otherdata' => '',
|
|
|
93 |
'files' => '',
|
|
|
94 |
];
|
|
|
95 |
}
|
|
|
96 |
}
|