|
1
|
|
|
<?php |
|
2
|
|
|
// This file is part of 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 output class for bigbluebuttonbn |
|
19
|
|
|
* |
|
20
|
|
|
* @package mod_bigbluebuttonbn |
|
21
|
|
|
* @copyright 2018 onwards, Blindside Networks Inc |
|
22
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|
23
|
|
|
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com) |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
namespace mod_bigbluebuttonbn\output; |
|
27
|
|
|
|
|
28
|
|
|
defined('MOODLE_INTERNAL') || die(); |
|
29
|
|
|
|
|
30
|
|
|
use context_module; |
|
31
|
|
|
use mod_bigbluebuttonbn_external; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Mobile output class for bigbluebuttonbn |
|
35
|
|
|
* |
|
36
|
|
|
* @package mod_bigbluebuttonbn |
|
37
|
|
|
* @copyright 2018 onwards, Blindside Networks Inc |
|
38
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|
39
|
|
|
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com) |
|
40
|
|
|
*/ |
|
41
|
|
|
class mobile { |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Returns the bigbluebuttonbn course view for the mobile app. |
|
45
|
|
|
* @param array $args Arguments from tool_mobile_get_content WS |
|
46
|
|
|
* |
|
47
|
|
|
* @return array HTML, javascript and otherdata |
|
48
|
|
|
*/ |
|
49
|
|
|
public static function mobile_course_view($args) { |
|
50
|
|
|
global $OUTPUT, $USER, $DB; |
|
51
|
|
|
|
|
52
|
|
|
$args = (object) $args; |
|
53
|
|
|
$cm = get_coursemodule_from_id('bigbluebuttonbn', $args->cmid); |
|
54
|
|
|
|
|
55
|
|
|
// Capabilities check. |
|
56
|
|
|
require_login($args->courseid , false , $cm, true, true); |
|
57
|
|
|
|
|
58
|
|
|
$context = context_module::instance($cm->id); |
|
59
|
|
|
|
|
60
|
|
|
require_capability ('mod/bigbluebuttonbn:view', $context); |
|
61
|
|
|
if ($args->userid != $USER->id) { |
|
62
|
|
|
require_capability('mod/bigbluebuttonbn:manage', $context); |
|
63
|
|
|
} |
|
64
|
|
|
$bigbluebuttonbn = $DB->get_record('bigbluebuttonbn', array('id' => $cm->instance)); |
|
65
|
|
|
|
|
66
|
|
|
$showget = true; |
|
67
|
|
|
if ($bigbluebuttonbn->requiredtime && !has_capability('mod/bigbluebuttonbn:manage', $context)) { |
|
68
|
|
|
if (bigbluebuttonbn_get_course_time($bigbluebuttonbn->course) < ($bigbluebuttonbn->requiredtime * 60)) { |
|
69
|
|
|
$showget = false; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
$bigbluebuttonbn->name = format_string($bigbluebuttonbn->name); |
|
74
|
|
|
list($bigbluebuttonbn->intro, $bigbluebuttonbn->introformat) = |
|
75
|
|
|
external_format_text($bigbluebuttonbn->intro, $bigbluebuttonbn->introformat, $context->id, |
|
76
|
|
|
'mod_bigbluebuttonbn', 'intro'); |
|
77
|
|
|
$data = array( |
|
78
|
|
|
'bigbluebuttonbn' => $bigbluebuttonbn, |
|
79
|
|
|
'showget' => $showget && count($issues) > 0, |
|
|
|
|
|
|
80
|
|
|
'issues' => $issues, |
|
81
|
|
|
'issue' => $issues[0], |
|
82
|
|
|
'numissues' => count($issues), |
|
83
|
|
|
'cmid' => $cm->id, |
|
84
|
|
|
'courseid' => $args->courseid |
|
85
|
|
|
); |
|
86
|
|
|
|
|
87
|
|
|
return array( |
|
88
|
|
|
'templates' => array( |
|
89
|
|
|
array( |
|
90
|
|
|
'id' => 'main', |
|
91
|
|
|
'html' => $OUTPUT->render_from_template('mod_bigbluebuttonbn/mobile_view_page', $data), |
|
92
|
|
|
), |
|
93
|
|
|
), |
|
94
|
|
|
'javascript' => '', |
|
95
|
|
|
'otherdata' => '', |
|
96
|
|
|
'files' => $issues |
|
97
|
|
|
); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Returns the bigbluebuttonbn issues view for the mobile app. |
|
102
|
|
|
* @param array $args Arguments from tool_mobile_get_content WS |
|
103
|
|
|
* |
|
104
|
|
|
* @return array HTML, javascript and otherdata |
|
105
|
|
|
*/ |
|
106
|
|
|
public static function mobile_issues_view($args) { |
|
107
|
|
|
global $OUTPUT, $USER, $DB; |
|
108
|
|
|
|
|
109
|
|
|
$args = (object) $args; |
|
110
|
|
|
$cm = get_coursemodule_from_id('bigbluebuttonbn', $args->cmid); |
|
111
|
|
|
|
|
112
|
|
|
// Capabilities check. |
|
113
|
|
|
require_login($args->courseid , false , $cm, true, true); |
|
114
|
|
|
|
|
115
|
|
|
$context = context_module::instance($cm->id); |
|
116
|
|
|
|
|
117
|
|
|
require_capability ('mod/bigbluebuttonbn:view', $context); |
|
118
|
|
|
if ($args->userid != $USER->id) { |
|
119
|
|
|
require_capability('mod/bigbluebuttonbn:manage', $context); |
|
120
|
|
|
} |
|
121
|
|
|
$bigbluebuttonbn = $DB->get_record('bigbluebuttonbn', array('id' => $cm->instance)); |
|
|
|
|
|
|
122
|
|
|
|
|
123
|
|
|
// Get bigbluebuttonbns from external (taking care of exceptions). |
|
124
|
|
|
try { |
|
125
|
|
|
$issued = mod_bigbluebuttonbn_external::issue_bigbluebuttonbn($cm->instance); |
|
|
|
|
|
|
126
|
|
|
$bigbluebuttonbns = mod_bigbluebuttonbn_external::get_issued_bigbluebuttonbns($cm->instance); |
|
127
|
|
|
$issues = array_values($bigbluebuttonbns['issues']); // Make it mustache compatible. |
|
128
|
|
|
} catch (Exception $e) { |
|
|
|
|
|
|
129
|
|
|
$issues = array(); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
$data = array( |
|
133
|
|
|
'issues' => $issues |
|
134
|
|
|
); |
|
135
|
|
|
|
|
136
|
|
|
return array( |
|
137
|
|
|
'templates' => array( |
|
138
|
|
|
array( |
|
139
|
|
|
'id' => 'main', |
|
140
|
|
|
'html' => $OUTPUT->render_from_template('mod_bigbluebuttonbn/mobile_view_issues', $data), |
|
141
|
|
|
), |
|
142
|
|
|
), |
|
143
|
|
|
'javascript' => '', |
|
144
|
|
|
'otherdata' => '' |
|
145
|
|
|
); |
|
146
|
|
|
} |
|
147
|
|
|
} |
|
148
|
|
|
|
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.