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