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
|
|
|
* Intermediator for handling ajax requests resulting on BigBlueButton actions. |
19
|
|
|
* |
20
|
|
|
* @package mod_bigbluebuttonbn |
21
|
|
|
* @copyright 2010 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
|
|
|
define('READ_ONLY_SESSION', true); |
27
|
|
|
define('AJAX_SCRIPT', true); |
28
|
|
|
|
29
|
|
|
require(__DIR__.'/../../config.php'); |
30
|
|
|
require_once(__DIR__.'/locallib.php'); |
31
|
|
|
require_once(__DIR__.'/brokerlib.php'); |
32
|
|
|
|
33
|
|
|
global $PAGE, $USER, $CFG, $SESSION, $DB; |
34
|
|
|
|
35
|
|
|
$params['action'] = optional_param('action', '', PARAM_TEXT); |
36
|
|
|
$params['callback'] = optional_param('callback', '', PARAM_TEXT); |
37
|
|
|
$params['id'] = optional_param('id', '', PARAM_TEXT); |
38
|
|
|
$params['idx'] = optional_param('idx', '', PARAM_TEXT); |
39
|
|
|
$params['bigbluebuttonbn'] = optional_param('bigbluebuttonbn', 0, PARAM_INT); |
40
|
|
|
$params['signed_parameters'] = optional_param('signed_parameters', '', PARAM_TEXT); |
41
|
|
|
$params['updatecache'] = optional_param('updatecache', 'false', PARAM_TEXT); |
42
|
|
|
$params['meta'] = optional_param('meta', '', PARAM_TEXT); |
43
|
|
|
|
44
|
|
|
require_login(null, true); |
45
|
|
|
require_sesskey(); |
46
|
|
|
|
47
|
|
|
if (empty($params['action'])) { |
48
|
|
|
header('HTTP/1.0 400 Bad Request. Parameter ['.$params['action'].'] was not included'); |
49
|
|
|
return; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
$error = bigbluebuttonbn_broker_validate_parameters($params); |
53
|
|
|
if (!empty($error)) { |
54
|
|
|
header('HTTP/1.0 400 Bad Request. '.$error); |
55
|
|
|
return; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
if ($params['bigbluebuttonbn']) { |
59
|
|
|
$bbbbrokerinstance = bigbluebuttonbn_view_instance_bigbluebuttonbn($params['bigbluebuttonbn']); |
60
|
|
|
$cm = $bbbbrokerinstance['cm']; |
61
|
|
|
$bigbluebuttonbn = $bbbbrokerinstance['bigbluebuttonbn']; |
62
|
|
|
$context = context_module::instance($cm->id); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
if (!isset($SESSION->bigbluebuttonbn_bbbsession) || is_null($SESSION->bigbluebuttonbn_bbbsession)) { |
66
|
|
|
header('HTTP/1.0 400 Bad Request. No session variable set'); |
67
|
|
|
return; |
68
|
|
|
} |
69
|
|
|
$bbbsession = $SESSION->bigbluebuttonbn_bbbsession; |
70
|
|
|
|
71
|
|
|
$userid = $USER->id; |
72
|
|
|
if (!isloggedin() && $PAGE->course->id == SITEID) { |
73
|
|
|
$userid = guest_user()->id; |
74
|
|
|
} |
75
|
|
|
$hascourseaccess = ($PAGE->course->id == SITEID) || can_access_course($PAGE->course, $userid); |
76
|
|
|
|
77
|
|
|
if (!$hascourseaccess) { |
78
|
|
|
header('HTTP/1.0 401 Unauthorized'); |
79
|
|
|
return; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
$type = null; |
83
|
|
|
if (isset($bbbsession['bigbluebuttonbn']->type)) { |
84
|
|
|
$type = $bbbsession['bigbluebuttonbn']->type; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
$typeprofiles = bigbluebuttonbn_get_instance_type_profiles(); |
88
|
|
|
$enabledfeatures = bigbluebuttonbn_get_enabled_features($typeprofiles, $type); |
89
|
|
|
try { |
90
|
|
|
header('Content-Type: application/javascript; charset=utf-8'); |
91
|
|
|
$a = strtolower($params['action']); |
92
|
|
|
if ($a == 'meeting_info') { |
93
|
|
|
$meetinginfo = bigbluebuttonbn_broker_meeting_info($bbbsession, $params, ($params['updatecache'] == 'true')); |
94
|
|
|
echo $meetinginfo; |
95
|
|
|
return; |
96
|
|
|
} |
97
|
|
|
if ($a == 'meeting_end') { |
98
|
|
|
$meetingend = bigbluebuttonbn_broker_meeting_end($bbbsession, $params); |
99
|
|
|
echo $meetingend; |
100
|
|
|
return; |
101
|
|
|
} |
102
|
|
|
if ($a == 'recording_play') { |
103
|
|
|
$recordingplay = bigbluebuttonbn_broker_recording_play($params); |
104
|
|
|
echo $recordingplay; |
105
|
|
|
return; |
106
|
|
|
} |
107
|
|
|
if ($a == 'recording_links') { |
108
|
|
|
$recordinglinks = bigbluebuttonbn_broker_recording_links($bbbsession, $params); |
109
|
|
|
echo $recordinglinks; |
110
|
|
|
return; |
111
|
|
|
} |
112
|
|
|
if ($a == 'recording_info') { |
113
|
|
|
$recordinginfo = bigbluebuttonbn_broker_recording_info($bbbsession, $params, $enabledfeatures['showroom']); |
114
|
|
|
echo $recordinginfo; |
115
|
|
|
return; |
116
|
|
|
} |
117
|
|
|
if ($a == 'recording_publish' || $a == 'recording_unpublish' || |
118
|
|
|
$a == 'recording_delete' || $a == 'recording_edit' || |
119
|
|
|
$a == 'recording_protect' || $a == 'recording_unprotect') { |
120
|
|
|
$recordingaction = bigbluebuttonbn_broker_recording_action($bbbsession, $params, $enabledfeatures['showroom']); |
121
|
|
|
echo $recordingaction; |
122
|
|
|
return; |
123
|
|
|
} |
124
|
|
|
if ($a == 'recording_import') { |
125
|
|
|
echo bigbluebuttonbn_broker_recording_import($bbbsession, $params); |
126
|
|
|
return; |
127
|
|
|
} |
128
|
|
|
if ($a == 'recording_list_table') { |
129
|
|
|
$PAGE->set_context(context_course::instance($PAGE->course->id)); |
130
|
|
|
$recordingdata = bigbluebuttonbn_broker_get_recording_data($bbbsession, $params, $enabledfeatures); |
131
|
|
|
echo $recordingdata; |
132
|
|
|
return; |
133
|
|
|
} |
134
|
|
|
if ($a == 'completion_validate') { |
135
|
|
|
$completionvalidate = bigbluebuttonbn_broker_completion_validate($bigbluebuttonbn, $params); |
|
|
|
|
136
|
|
|
echo $completionvalidate; |
137
|
|
|
return; |
138
|
|
|
} |
139
|
|
|
header('HTTP/1.0 400 Bad request. The action '. $a . ' doesn\'t exist'); |
140
|
|
|
} catch (Exception $e) { |
141
|
|
|
header('HTTP/1.0 500 Internal Server Error. '.$e->getMessage()); |
142
|
|
|
} |
143
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.