|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Internal library of functions for module BigBlueButtonBN. |
|
4
|
|
|
* |
|
5
|
|
|
* @package mod |
|
6
|
|
|
* @subpackage bigbluebuttonbn |
|
7
|
|
|
* @author Fred Dixon (ffdixon [at] blindsidenetworks [dt] com) |
|
8
|
|
|
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com) |
|
9
|
|
|
* @copyright 2010-2015 Blindside Networks Inc. |
|
10
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v2 or later |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
defined('MOODLE_INTERNAL') || die; |
|
14
|
|
|
|
|
15
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
16
|
|
|
|
|
17
|
|
|
require_once(dirname(__FILE__).'/lib.php'); |
|
18
|
|
|
|
|
19
|
|
|
const BIGBLUEBUTTONBN_FORCED = true; |
|
20
|
|
|
|
|
21
|
|
|
const BIGBLUEBUTTONBN_ROLE_VIEWER = 'viewer'; |
|
22
|
|
|
const BIGBLUEBUTTONBN_ROLE_MODERATOR = 'moderator'; |
|
23
|
|
|
const BIGBLUEBUTTONBN_METHOD_GET = 'GET'; |
|
24
|
|
|
const BIGBLUEBUTTONBN_METHOD_POST = 'POST'; |
|
25
|
|
|
|
|
26
|
|
|
const BIGBLUEBUTTON_EVENT_MEETING_CREATED = 'meeting_created'; |
|
27
|
|
|
const BIGBLUEBUTTON_EVENT_MEETING_JOINED = 'meeting_joined'; |
|
28
|
|
|
const BIGBLUEBUTTON_EVENT_MEETING_ENDED = 'meeting_ended'; |
|
29
|
|
|
const BIGBLUEBUTTON_EVENT_ACTIVITY_VIEWED = 'activity_viewed'; |
|
30
|
|
|
const BIGBLUEBUTTON_EVENT_RECORDING_PUBLISHED = 'recording_published'; |
|
31
|
|
|
const BIGBLUEBUTTON_EVENT_RECORDING_UNPUBLISHED = 'recording_unpublished'; |
|
32
|
|
|
const BIGBLUEBUTTON_EVENT_RECORDING_DELETED = 'recording_deleted'; |
|
33
|
|
|
const BIGBLUEBUTTON_EVENT_RECORDING_IMPORTED = 'recording_imported'; |
|
34
|
|
|
const BIGBLUEBUTTON_EVENT_MEETING_LEFT = "meeting_left"; |
|
35
|
|
|
|
|
36
|
|
|
function bigbluebuttonbn_logs(array $bbbsession, $event, array $overrides = [], $meta = NULL ) { |
|
37
|
|
|
global $DB; |
|
38
|
|
|
|
|
39
|
|
|
$log = new stdClass(); |
|
40
|
|
|
|
|
41
|
|
|
$log->courseid = isset($overrides['courseid'])? $overrides['courseid']: $bbbsession['course']->id; |
|
42
|
|
|
$log->bigbluebuttonbnid = isset($overrides['bigbluebuttonbnid'])? $overrides['bigbluebuttonbnid']: $bbbsession['bigbluebuttonbn']->id; |
|
43
|
|
|
$log->userid = isset($overrides['userid'])? $overrides['userid']: $bbbsession['userID']; |
|
44
|
|
|
$log->meetingid = isset($overrides['meetingid'])? $overrides['meetingid']: $bbbsession['meetingid']; |
|
45
|
|
|
$log->timecreated = isset($overrides['timecreated'])? $overrides['timecreated']: time(); |
|
46
|
|
|
$log->log = $event; |
|
47
|
|
|
if ( isset($meta) ) { |
|
48
|
|
|
$log->meta = $meta; |
|
49
|
|
|
} else if( $event == BIGBLUEBUTTONBN_LOG_EVENT_CREATE) { |
|
50
|
|
|
$log->meta = '{"record":'.($bbbsession['record']? 'true': 'false').'}'; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
$returnid = $DB->insert_record('bigbluebuttonbn_logs', $log); |
|
|
|
|
|
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
//////////////////////////// |
|
57
|
|
|
// BigBlueButton API Calls // |
|
58
|
|
|
//////////////////////////// |
|
59
|
|
|
function bigbluebuttonbn_getJoinURL( $meetingID, $userName, $PW, $SALT, $URL, $logoutURL ) { |
|
60
|
|
|
$url_join = $URL."api/join?"; |
|
61
|
|
|
$params = 'meetingID='.urlencode($meetingID).'&fullName='.urlencode($userName).'&password='.urlencode($PW).'&logoutURL='.urlencode($logoutURL); |
|
62
|
|
|
$url = $url_join.$params.'&checksum='.sha1("join".$params.$SALT); |
|
63
|
|
|
return $url; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
function bigbluebuttonbn_getCreateMeetingURL($name, $meetingID, $attendeePW, $moderatorPW, $welcome, $logoutURL, $SALT, $URL, $record = 'false', $duration=0, $voiceBridge=0, $maxParticipants=0, $metadata=array() ) { |
|
67
|
|
|
$url_create = $URL."api/create?"; |
|
68
|
|
|
|
|
69
|
|
|
$params = 'name='.urlencode($name).'&meetingID='.urlencode($meetingID).'&attendeePW='.urlencode($attendeePW).'&moderatorPW='.urlencode($moderatorPW).'&logoutURL='.urlencode($logoutURL).'&record='.$record; |
|
70
|
|
|
|
|
71
|
|
|
$voiceBridge = intval($voiceBridge); |
|
72
|
|
|
if ( $voiceBridge > 0 && $voiceBridge < 79999) |
|
73
|
|
|
$params .= '&voiceBridge='.$voiceBridge; |
|
74
|
|
|
|
|
75
|
|
|
$duration = intval($duration); |
|
76
|
|
|
if( $duration > 0 ) |
|
77
|
|
|
$params .= '&duration='.$duration; |
|
78
|
|
|
|
|
79
|
|
|
$maxParticipants = intval($maxParticipants); |
|
80
|
|
|
if( $maxParticipants > 0 ) |
|
81
|
|
|
$params .= '&maxParticipants='.$maxParticipants; |
|
82
|
|
|
|
|
83
|
|
|
if( trim( $welcome ) ) |
|
84
|
|
|
$params .= '&welcome='.urlencode($welcome); |
|
85
|
|
|
|
|
86
|
|
|
foreach ($metadata as $key => $value) { |
|
87
|
|
|
$params .= '&'.$key.'='.urlencode($value); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
$url = $url_create.$params.'&checksum='.sha1("create".$params.$SALT); |
|
91
|
|
|
return $url; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
function bigbluebuttonbn_getIsMeetingRunningURL( $meetingID, $URL, $SALT ) { |
|
95
|
|
|
$base_url = $URL."api/isMeetingRunning?"; |
|
96
|
|
|
$params = 'meetingID='.urlencode($meetingID); |
|
97
|
|
|
$url = $base_url.$params.'&checksum='.sha1("isMeetingRunning".$params.$SALT); |
|
98
|
|
|
return $url; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
View Code Duplication |
function bigbluebuttonbn_getMeetingInfoURL( $meetingID, $modPW, $URL, $SALT ) { |
|
|
|
|
|
|
102
|
|
|
$base_url = $URL."api/getMeetingInfo?"; |
|
103
|
|
|
$params = 'meetingID='.urlencode($meetingID).'&password='.urlencode($modPW); |
|
104
|
|
|
$url = $base_url.$params.'&checksum='.sha1("getMeetingInfo".$params.$SALT); |
|
105
|
|
|
return $url; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
function bigbluebuttonbn_getMeetingsURL( $URL, $SALT ) { |
|
109
|
|
|
$base_url = $URL."api/getMeetings?"; |
|
110
|
|
|
$url = $base_url.'&checksum='.sha1("getMeetings".$SALT); |
|
111
|
|
|
return $url; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
View Code Duplication |
function bigbluebuttonbn_getEndMeetingURL( $meetingID, $modPW, $URL, $SALT ) { |
|
|
|
|
|
|
115
|
|
|
$base_url = $URL."api/end?"; |
|
116
|
|
|
$params = 'meetingID='.urlencode($meetingID).'&password='.urlencode($modPW); |
|
117
|
|
|
$url = $base_url.$params.'&checksum='.sha1("end".$params.$SALT); |
|
118
|
|
|
return $url; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
function bigbluebuttonbn_getRecordingsURL( $URL, $SALT, $meetingID=null ) { |
|
122
|
|
|
$base_url_record = $URL."api/getRecordings?"; |
|
123
|
|
|
if( $meetingID == null ) { |
|
124
|
|
|
$params = ""; |
|
125
|
|
|
} else { |
|
126
|
|
|
$params = "meetingID=".urlencode($meetingID); |
|
127
|
|
|
} |
|
128
|
|
|
$url = $base_url_record.$params."&checksum=".sha1("getRecordings".$params.$SALT); |
|
129
|
|
|
return $url; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
function bigbluebuttonbn_getDeleteRecordingsURL( $recordID, $URL, $SALT ) { |
|
133
|
|
|
$url_delete = $URL."api/deleteRecordings?"; |
|
134
|
|
|
$params = 'recordID='.urlencode($recordID); |
|
135
|
|
|
$url = $url_delete.$params.'&checksum='.sha1("deleteRecordings".$params.$SALT); |
|
136
|
|
|
return $url; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
function bigbluebuttonbn_getPublishRecordingsURL( $recordID, $set, $URL, $SALT ) { |
|
140
|
|
|
$url_publish = $URL."api/publishRecordings?"; |
|
141
|
|
|
$params = 'recordID='.$recordID."&publish=".$set; |
|
142
|
|
|
$url = $url_publish.$params.'&checksum='.sha1("publishRecordings".$params.$SALT); |
|
143
|
|
|
return $url; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
function bigbluebuttonbn_getCreateMeetingArray( $username, $meetingID, $welcomeString, $mPW, $aPW, $SALT, $URL, $logoutURL, $record='false', $duration=0, $voiceBridge=0, $maxParticipants=0, $metadata=array(), $presentation_name=null, $presentation_url=null ) { |
|
147
|
|
|
$create_meeting_url = bigbluebuttonbn_getCreateMeetingURL($username, $meetingID, $aPW, $mPW, $welcomeString, $logoutURL, $SALT, $URL, $record, $duration, $voiceBridge, $maxParticipants, $metadata); |
|
148
|
|
|
if( !is_null($presentation_name) && !is_null($presentation_url) ) { |
|
149
|
|
|
$xml = bigbluebuttonbn_wrap_xml_load_file( $create_meeting_url, |
|
150
|
|
|
BIGBLUEBUTTONBN_METHOD_POST, |
|
151
|
|
|
"<?xml version='1.0' encoding='UTF-8'?><modules><module name='presentation'><document url='".$presentation_url."' /></module></modules>" |
|
152
|
|
|
); |
|
153
|
|
|
} else { |
|
154
|
|
|
$xml = bigbluebuttonbn_wrap_xml_load_file( $create_meeting_url ); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
if ( $xml ) { |
|
158
|
|
|
if ($xml->meetingID) |
|
159
|
|
|
return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey, 'meetingID' => $xml->meetingID, 'attendeePW' => $xml->attendeePW, 'moderatorPW' => $xml->moderatorPW, 'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded ); |
|
160
|
|
|
else |
|
161
|
|
|
return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey ); |
|
162
|
|
|
} else { |
|
163
|
|
|
return null; |
|
164
|
|
|
} |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
function bigbluebuttonbn_getMeetingsArray($meetingID, $URL, $SALT ) { |
|
|
|
|
|
|
168
|
|
|
$xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getMeetingsURL($URL, $SALT) ); |
|
169
|
|
|
|
|
170
|
|
|
if( $xml && $xml->returncode == 'SUCCESS' && $xml->messageKey ) { //The meetings were returned |
|
171
|
|
|
return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey); |
|
172
|
|
|
|
|
173
|
|
|
} else if($xml && $xml->returncode == 'SUCCESS'){ //If there were meetings already created |
|
174
|
|
|
foreach ($xml->meetings->meeting as $meeting) { |
|
175
|
|
|
$meetings[] = array( 'meetingID' => $meeting->meetingID, 'moderatorPW' => $meeting->moderatorPW, 'attendeePW' => $meeting->attendeePW, 'hasBeenForciblyEnded' => $meeting->hasBeenForciblyEnded, 'running' => $meeting->running ); |
|
|
|
|
|
|
176
|
|
|
} |
|
177
|
|
|
return $meetings; |
|
|
|
|
|
|
178
|
|
|
|
|
179
|
|
View Code Duplication |
} else if( $xml ) { //If the xml packet returned failure it displays the message to the user |
|
|
|
|
|
|
180
|
|
|
return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey); |
|
181
|
|
|
|
|
182
|
|
|
} else { //If the server is unreachable, then prompts the user of the necessary action |
|
183
|
|
|
return null; |
|
184
|
|
|
} |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
function bigbluebuttonbn_getMeetingInfo( $meetingID, $modPW, $URL, $SALT ) { |
|
188
|
|
|
$xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getMeetingInfoURL( $meetingID, $modPW, $URL, $SALT ) ); |
|
189
|
|
|
return $xml; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
function bigbluebuttonbn_getMeetingInfoArray( $meetingID, $modPW, $URL, $SALT ) { |
|
193
|
|
|
$xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getMeetingInfoURL( $meetingID, $modPW, $URL, $SALT ) ); |
|
194
|
|
|
|
|
195
|
|
|
if( $xml && $xml->returncode == 'SUCCESS' && $xml->messageKey == null){//The meeting info was returned |
|
196
|
|
|
return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey ); |
|
197
|
|
|
|
|
198
|
|
|
} else if($xml && $xml->returncode == 'SUCCESS'){ //If there were meetings already created |
|
199
|
|
|
return array('returncode' => $xml->returncode, 'meetingID' => $xml->meetingID, 'moderatorPW' => $xml->moderatorPW, 'attendeePW' => $xml->attendeePW, 'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded, 'running' => $xml->running, 'recording' => $xml->recording, 'startTime' => $xml->startTime, 'endTime' => $xml->endTime, 'participantCount' => $xml->participantCount, 'moderatorCount' => $xml->moderatorCount, 'attendees' => $xml->attendees, 'metadata' => $xml->metadata ); |
|
200
|
|
|
|
|
201
|
|
View Code Duplication |
} else if( ($xml && $xml->returncode == 'FAILED') || $xml) { //If the xml packet returned failure it displays the message to the user |
|
|
|
|
|
|
202
|
|
|
return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey); |
|
203
|
|
|
|
|
204
|
|
|
} else { //If the server is unreachable, then prompts the user of the necessary action |
|
205
|
|
|
return null; |
|
206
|
|
|
} |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
function bigbluebuttonbn_getRecordingsArray( $meetingIDs, $URL, $SALT ) { |
|
210
|
|
|
$recordings = array(); |
|
211
|
|
|
|
|
212
|
|
|
if ( is_array($meetingIDs) ) { |
|
213
|
|
|
// getRecordings is executes using a method POST (supported only on BBB 1.0 and later) |
|
214
|
|
|
$xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getRecordingsURL( $URL, $SALT ), BIGBLUEBUTTONBN_METHOD_POST, $meetingIDs ); |
|
215
|
|
|
} else { |
|
216
|
|
|
// getRecordings is executes using a method GET supported by any version of BBB |
|
217
|
|
|
$xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getRecordingsURL( $URL, $SALT, $meetingIDs ) ); |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
if ( $xml && $xml->returncode == 'SUCCESS' && isset($xml->recordings) ) { //If there were meetings already created |
|
221
|
|
|
foreach ( $xml->recordings->recording as $recording ) { |
|
222
|
|
|
$playbackArray = array(); |
|
223
|
|
|
foreach ( $recording->playback->format as $format ) { |
|
224
|
|
|
$playbackArray[(string) $format->type] = array( 'type' => (string) $format->type, 'url' => (string) $format->url ); |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
//Add the metadata to the recordings array |
|
228
|
|
|
$metadataArray = array(); |
|
229
|
|
|
$metadata = get_object_vars($recording->metadata); |
|
230
|
|
|
foreach ( $metadata as $key => $value ) { |
|
231
|
|
|
if ( is_object($value) ) $value = ''; |
|
232
|
|
|
$metadataArray['meta_'.$key] = $value; |
|
233
|
|
|
} |
|
234
|
|
|
|
|
235
|
|
|
$recordings[] = array( 'recordID' => (string) $recording->recordID, 'meetingID' => (string) $recording->meetingID, 'meetingName' => (string) $recording->name, 'published' => (string) $recording->published, 'startTime' => (string) $recording->startTime, 'endTime' => (string) $recording->endTime, 'playbacks' => $playbackArray ) + $metadataArray; |
|
236
|
|
|
} |
|
237
|
|
|
|
|
238
|
|
|
usort($recordings, 'bigbluebuttonbn_recordingBuildSorter'); |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
return $recordings; |
|
242
|
|
|
} |
|
243
|
|
|
|
|
244
|
|
|
function bigbluebuttonbn_index_recordings($recordings, $index_key='recordID') { |
|
245
|
|
|
$indexed_recordings = array(); |
|
246
|
|
|
|
|
247
|
|
|
foreach ($recordings as $recording) { |
|
248
|
|
|
$indexed_recordings[$recording[$index_key]] = $recording; |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
return $indexed_recordings; |
|
252
|
|
|
} |
|
253
|
|
|
|
|
254
|
|
|
function bigbluebuttonbn_getRecordingArray( $recordingID, $meetingID, $URL, $SALT ) { |
|
255
|
|
|
$recording = array(); |
|
256
|
|
|
|
|
257
|
|
|
$xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getRecordingsURL( $URL, $SALT, $meetingID ) ); |
|
258
|
|
|
|
|
259
|
|
|
if ( $xml && $xml->returncode == 'SUCCESS' && isset($xml->recordings) ) { //If there were meetings already created |
|
260
|
|
|
foreach ($xml->recordings->recording as $recording) { |
|
261
|
|
|
if( $recording->recordID == $recordingID ) { |
|
262
|
|
|
$playbackArray = array(); |
|
263
|
|
|
foreach ( $recording->playback->format as $format ){ |
|
264
|
|
|
$playbackArray[(string) $format->type] = array( 'type' => (string) $format->type, 'url' => (string) $format->url ); |
|
265
|
|
|
} |
|
266
|
|
|
|
|
267
|
|
|
//Add the metadata to the recordings array |
|
268
|
|
|
$metadataArray = array(); |
|
269
|
|
|
$metadata = get_object_vars($recording->metadata); |
|
270
|
|
|
foreach ($metadata as $key => $value) { |
|
271
|
|
|
if(is_object($value)) $value = ''; |
|
272
|
|
|
$metadataArray['meta_'.$key] = $value; |
|
273
|
|
|
} |
|
274
|
|
|
|
|
275
|
|
|
$recording = array( 'recordID' => (string) $recording->recordID, 'meetingID' => (string) $recording->meetingID, 'meetingName' => (string) $recording->name, 'published' => (string) $recording->published, 'startTime' => (string) $recording->startTime, 'endTime' => (string) $recording->endTime, 'playbacks' => $playbackArray ) + $metadataArray; |
|
276
|
|
|
break; |
|
277
|
|
|
} |
|
278
|
|
|
} |
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
|
|
return $recording; |
|
282
|
|
|
} |
|
283
|
|
|
|
|
284
|
|
|
function bigbluebuttonbn_recordingBuildSorter($a, $b){ |
|
285
|
|
|
if( $a['startTime'] < $b['startTime']) return -1; |
|
286
|
|
|
else if( $a['startTime'] == $b['startTime']) return 0; |
|
287
|
|
|
else return 1; |
|
288
|
|
|
} |
|
289
|
|
|
|
|
290
|
|
View Code Duplication |
function bigbluebuttonbn_doDeleteRecordings( $recordIDs, $URL, $SALT ) { |
|
|
|
|
|
|
291
|
|
|
$ids = explode(",", $recordIDs); |
|
292
|
|
|
foreach( $ids as $id){ |
|
293
|
|
|
$xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getDeleteRecordingsURL($id, $URL, $SALT) ); |
|
294
|
|
|
if( $xml && $xml->returncode != 'SUCCESS' ) |
|
295
|
|
|
return false; |
|
296
|
|
|
} |
|
297
|
|
|
return true; |
|
298
|
|
|
} |
|
299
|
|
|
|
|
300
|
|
View Code Duplication |
function bigbluebuttonbn_doPublishRecordings( $recordIDs, $set, $URL, $SALT ) { |
|
|
|
|
|
|
301
|
|
|
$ids = explode(",", $recordIDs); |
|
302
|
|
|
foreach( $ids as $id){ |
|
303
|
|
|
$xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getPublishRecordingsURL($id, $set, $URL, $SALT) ); |
|
304
|
|
|
if( $xml && $xml->returncode != 'SUCCESS' ) |
|
305
|
|
|
return false; |
|
306
|
|
|
} |
|
307
|
|
|
return true; |
|
308
|
|
|
} |
|
309
|
|
|
|
|
310
|
|
|
function bigbluebuttonbn_doEndMeeting( $meetingID, $modPW, $URL, $SALT ) { |
|
311
|
|
|
$xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getEndMeetingURL( $meetingID, $modPW, $URL, $SALT ) ); |
|
312
|
|
|
|
|
313
|
|
|
if( $xml ) { //If the xml packet returned failure it displays the message to the user |
|
314
|
|
|
return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey); |
|
315
|
|
|
} |
|
316
|
|
|
else { //If the server is unreachable, then prompts the user of the necessary action |
|
317
|
|
|
return null; |
|
318
|
|
|
} |
|
319
|
|
|
} |
|
320
|
|
|
|
|
321
|
|
|
function bigbluebuttonbn_isMeetingRunning( $meetingID, $URL, $SALT ) { |
|
322
|
|
|
$xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getIsMeetingRunningURL( $meetingID, $URL, $SALT ) ); |
|
323
|
|
|
if ( $xml && $xml->returncode == 'SUCCESS' ) { |
|
324
|
|
|
return ( ( $xml->running == 'true' ) ? true : false); |
|
325
|
|
|
} else { |
|
326
|
|
|
return ( false ); |
|
327
|
|
|
} |
|
328
|
|
|
} |
|
329
|
|
|
|
|
330
|
|
|
|
|
331
|
|
|
function bigbluebuttonbn_getServerVersion( $URL ){ |
|
332
|
|
|
$xml = bigbluebuttonbn_wrap_xml_load_file( $URL."api" ); |
|
333
|
|
|
if ( $xml && $xml->returncode == 'SUCCESS' ) { |
|
334
|
|
|
return $xml->version; |
|
335
|
|
|
} else { |
|
336
|
|
|
return NULL; |
|
337
|
|
|
} |
|
338
|
|
|
} |
|
339
|
|
|
|
|
340
|
|
|
function bigbluebuttonbn_getMeetingXML( $meetingID, $URL, $SALT ) { |
|
341
|
|
|
$xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getIsMeetingRunningURL( $meetingID, $URL, $SALT ) ); |
|
342
|
|
|
if ( $xml && $xml->returncode == 'SUCCESS') { |
|
343
|
|
|
return ( str_replace('</response>', '', str_replace("<?xml version=\"1.0\"?>\n<response>", '', $xml->asXML()))); |
|
344
|
|
|
} else { |
|
345
|
|
|
return 'false'; |
|
346
|
|
|
} |
|
347
|
|
|
} |
|
348
|
|
|
|
|
349
|
|
|
function bigbluebuttonbn_wrap_xml_load_file($url, $method=BIGBLUEBUTTONBN_METHOD_GET, $data=null) { |
|
350
|
|
|
if ( bigbluebuttonbn_debugdisplay() ) error_log("Request to: ".$url); |
|
351
|
|
|
|
|
352
|
|
|
if (extension_loaded('curl')) { |
|
353
|
|
|
$c = new curl(); |
|
354
|
|
|
$c->setopt( Array( "SSL_VERIFYPEER" => true)); |
|
355
|
|
|
if( $method == BIGBLUEBUTTONBN_METHOD_POST ) { |
|
356
|
|
|
if( !is_null($data) ) { |
|
357
|
|
|
if( !is_array($data) ) { |
|
358
|
|
|
$options['CURLOPT_HTTPHEADER'] = array( |
|
|
|
|
|
|
359
|
|
|
'Content-Type: text/xml', |
|
360
|
|
|
'Content-Length: '.strlen($data), |
|
361
|
|
|
'Content-Language: en-US' |
|
362
|
|
|
); |
|
363
|
|
|
$response = $c->post($url, $data, $options); |
|
364
|
|
|
|
|
365
|
|
|
} else { |
|
366
|
|
|
$response = $c->post($url, $data); |
|
367
|
|
|
} |
|
368
|
|
|
|
|
369
|
|
|
} else { |
|
370
|
|
|
$response = $c->post($url); |
|
371
|
|
|
} |
|
372
|
|
|
|
|
373
|
|
|
} else { |
|
374
|
|
|
$response = $c->get($url); |
|
375
|
|
|
} |
|
376
|
|
|
|
|
377
|
|
|
if ($response) { |
|
378
|
|
|
$previous = libxml_use_internal_errors(true); |
|
379
|
|
|
try { |
|
380
|
|
|
$xml = new SimpleXMLElement($response, LIBXML_NOCDATA); |
|
381
|
|
|
return $xml; |
|
382
|
|
|
} catch (Exception $e){ |
|
383
|
|
|
libxml_use_internal_errors($previous); |
|
384
|
|
|
$error = 'Caught exception: '.$e->getMessage(); |
|
385
|
|
|
error_log($error); |
|
386
|
|
|
return NULL; |
|
387
|
|
|
} |
|
388
|
|
|
} else { |
|
389
|
|
|
error_log("No response on wrap_simplexml_load_file"); |
|
390
|
|
|
return NULL; |
|
391
|
|
|
} |
|
392
|
|
|
|
|
393
|
|
|
} else { |
|
394
|
|
|
$previous = libxml_use_internal_errors(true); |
|
395
|
|
|
try { |
|
396
|
|
|
$xml = simplexml_load_file($url,'SimpleXMLElement', LIBXML_NOCDATA); |
|
397
|
|
|
return $xml; |
|
398
|
|
|
} catch (Exception $e){ |
|
399
|
|
|
libxml_use_internal_errors($previous); |
|
400
|
|
|
return NULL; |
|
401
|
|
|
} |
|
402
|
|
|
} |
|
403
|
|
|
} |
|
404
|
|
|
|
|
405
|
|
|
function bigbluebuttonbn_get_role_name($role_shortname){ |
|
406
|
|
|
$role = bigbluebuttonbn_get_db_moodle_roles($role_shortname); |
|
407
|
|
|
if( $role != null && $role->name != "") { |
|
408
|
|
|
$role_name = $role->name; |
|
409
|
|
|
} else { |
|
410
|
|
|
switch ($role_shortname) { |
|
411
|
|
|
case 'manager': $role_name = get_string('manager', 'role'); break; |
|
412
|
|
|
case 'coursecreator': $role_name = get_string('coursecreators'); break; |
|
413
|
|
|
case 'editingteacher': $role_name = get_string('defaultcourseteacher'); break; |
|
414
|
|
|
case 'teacher': $role_name = get_string('noneditingteacher'); break; |
|
415
|
|
|
case 'student': $role_name = get_string('defaultcoursestudent'); break; |
|
416
|
|
|
case 'guest': $role_name = get_string('guest'); break; |
|
417
|
|
|
case 'user': $role_name = get_string('authenticateduser'); break; |
|
418
|
|
|
case 'frontpage': $role_name = get_string('frontpageuser', 'role'); break; |
|
419
|
|
|
// We should not get here, the role UI should require the name for custom roles! |
|
420
|
|
|
default: $role_name = $role_shortname; break; |
|
421
|
|
|
} |
|
422
|
|
|
} |
|
423
|
|
|
|
|
424
|
|
|
return $role_name; |
|
425
|
|
|
} |
|
426
|
|
|
|
|
427
|
|
|
function bigbluebuttonbn_get_roles($rolename='all', $format='json'){ |
|
428
|
|
|
$roles = bigbluebuttonbn_get_db_moodle_roles($rolename); |
|
429
|
|
|
$roles_array = array(); |
|
430
|
|
|
foreach($roles as $role){ |
|
431
|
|
|
if( $format=='json' ) { |
|
432
|
|
|
array_push($roles_array, |
|
433
|
|
|
array( "id" => $role->shortname, |
|
434
|
|
|
"name" => bigbluebuttonbn_get_role_name($role->shortname) |
|
435
|
|
|
) |
|
436
|
|
|
); |
|
437
|
|
|
} else { |
|
438
|
|
|
$roles_array[$role->shortname] = bigbluebuttonbn_get_role_name($role->shortname); |
|
439
|
|
|
} |
|
440
|
|
|
} |
|
441
|
|
|
return $roles_array; |
|
442
|
|
|
} |
|
443
|
|
|
|
|
444
|
|
|
function bigbluebuttonbn_get_roles_json($rolename='all'){ |
|
445
|
|
|
return json_encode(bigbluebuttonbn_get_roles($rolename)); |
|
446
|
|
|
} |
|
447
|
|
|
|
|
448
|
|
|
function bigbluebuttonbn_get_users_json($users, $full=false) { |
|
449
|
|
|
if( $full ) { |
|
450
|
|
|
return json_encode($users); |
|
451
|
|
|
} else { |
|
452
|
|
|
$users_array = array(); |
|
453
|
|
|
foreach($users as $user){ |
|
454
|
|
|
array_push($users_array, |
|
455
|
|
|
array( "id" => $user->id, |
|
456
|
|
|
"name" => $user->firstname.' '.$user->lastname |
|
457
|
|
|
) |
|
458
|
|
|
); |
|
459
|
|
|
} |
|
460
|
|
|
return json_encode($users_array); |
|
461
|
|
|
} |
|
462
|
|
|
} |
|
463
|
|
|
|
|
464
|
|
|
function bigbluebuttonbn_get_participant_list($bigbluebuttonbn=null, $context=null){ |
|
465
|
|
|
global $CFG, $USER; |
|
466
|
|
|
|
|
467
|
|
|
$participant_list_array = array(); |
|
468
|
|
|
|
|
469
|
|
|
if( $bigbluebuttonbn != null ) { |
|
470
|
|
|
$participant_list = json_decode($bigbluebuttonbn->participants); |
|
471
|
|
|
if (is_array($participant_list)) { |
|
472
|
|
|
foreach($participant_list as $participant){ |
|
473
|
|
|
array_push($participant_list_array, |
|
474
|
|
|
array( |
|
475
|
|
|
"selectiontype" => $participant->selectiontype, |
|
476
|
|
|
"selectionid" => $participant->selectionid, |
|
477
|
|
|
"role" => $participant->role |
|
478
|
|
|
) |
|
479
|
|
|
); |
|
480
|
|
|
} |
|
481
|
|
|
} |
|
482
|
|
|
} else { |
|
483
|
|
|
array_push($participant_list_array, |
|
484
|
|
|
array( |
|
485
|
|
|
"selectiontype" => "all", |
|
486
|
|
|
"selectionid" => "all", |
|
487
|
|
|
"role" => BIGBLUEBUTTONBN_ROLE_VIEWER |
|
488
|
|
|
) |
|
489
|
|
|
); |
|
490
|
|
|
|
|
491
|
|
|
$moderator_defaults = bigbluebuttonbn_get_cfg_moderator_default(); |
|
492
|
|
|
if ( !isset($moderator_defaults) ) { |
|
493
|
|
|
$moderator_defaults = array('owner'); |
|
494
|
|
|
} else { |
|
495
|
|
|
$moderator_defaults = explode(',', $moderator_defaults); |
|
496
|
|
|
} |
|
497
|
|
|
foreach( $moderator_defaults as $moderator_default ) { |
|
498
|
|
|
if( $moderator_default == 'owner' ) { |
|
499
|
|
|
$users = bigbluebuttonbn_get_users($context); |
|
500
|
|
|
foreach( $users as $user ){ |
|
501
|
|
|
if( $user->id == $USER->id ){ |
|
502
|
|
|
array_push($participant_list_array, |
|
503
|
|
|
array( |
|
504
|
|
|
"selectiontype" => "user", |
|
505
|
|
|
"selectionid" => $USER->id, |
|
506
|
|
|
"role" => BIGBLUEBUTTONBN_ROLE_MODERATOR |
|
507
|
|
|
) |
|
508
|
|
|
); |
|
509
|
|
|
break; |
|
510
|
|
|
} |
|
511
|
|
|
} |
|
512
|
|
|
} else { |
|
513
|
|
|
array_push($participant_list_array, |
|
514
|
|
|
array( |
|
515
|
|
|
"selectiontype" => "role", |
|
516
|
|
|
"selectionid" => $moderator_default, |
|
517
|
|
|
"role" => BIGBLUEBUTTONBN_ROLE_MODERATOR |
|
518
|
|
|
) |
|
519
|
|
|
); |
|
520
|
|
|
} |
|
521
|
|
|
} |
|
522
|
|
|
} |
|
523
|
|
|
|
|
524
|
|
|
return $participant_list_array; |
|
525
|
|
|
} |
|
526
|
|
|
|
|
527
|
|
|
function bigbluebuttonbn_get_participant_list_json($bigbluebuttonbnid=null){ |
|
528
|
|
|
return json_encode(bigbluebuttonbn_get_participant_list($bigbluebuttonbnid)); |
|
529
|
|
|
} |
|
530
|
|
|
|
|
531
|
|
|
function bigbluebuttonbn_is_moderator($user, $roles, $participants) { |
|
532
|
|
|
$participant_list = json_decode($participants); |
|
533
|
|
|
|
|
534
|
|
|
if (is_array($participant_list)) { |
|
535
|
|
|
// Iterate looking for all configuration |
|
536
|
|
View Code Duplication |
foreach($participant_list as $participant){ |
|
|
|
|
|
|
537
|
|
|
if( $participant->selectiontype == 'all' ) { |
|
538
|
|
|
if ( $participant->role == BIGBLUEBUTTONBN_ROLE_MODERATOR ) |
|
539
|
|
|
return true; |
|
540
|
|
|
} |
|
541
|
|
|
} |
|
542
|
|
|
|
|
543
|
|
|
//Iterate looking for roles |
|
544
|
|
|
$db_moodle_roles = bigbluebuttonbn_get_db_moodle_roles(); |
|
545
|
|
|
foreach($participant_list as $participant){ |
|
546
|
|
|
if( $participant->selectiontype == 'role' ) { |
|
547
|
|
|
foreach( $roles as $role ) { |
|
548
|
|
|
$db_moodle_role = bigbluebuttonbn_moodle_db_role_lookup($db_moodle_roles, $role->roleid); |
|
549
|
|
|
if( $participant->selectionid == $db_moodle_role->shortname ) { |
|
550
|
|
|
if ( $participant->role == BIGBLUEBUTTONBN_ROLE_MODERATOR ) |
|
551
|
|
|
return true; |
|
552
|
|
|
} |
|
553
|
|
|
} |
|
554
|
|
|
} |
|
555
|
|
|
} |
|
556
|
|
|
|
|
557
|
|
|
//Iterate looking for users |
|
558
|
|
View Code Duplication |
foreach($participant_list as $participant){ |
|
|
|
|
|
|
559
|
|
|
if( $participant->selectiontype == 'user' ) { |
|
560
|
|
|
if( $participant->selectionid == $user ) { |
|
561
|
|
|
if ( $participant->role == BIGBLUEBUTTONBN_ROLE_MODERATOR ) |
|
562
|
|
|
return true; |
|
563
|
|
|
} |
|
564
|
|
|
} |
|
565
|
|
|
} |
|
566
|
|
|
} |
|
567
|
|
|
|
|
568
|
|
|
return false; |
|
569
|
|
|
} |
|
570
|
|
|
|
|
571
|
|
|
function bigbluebuttonbn_moodle_db_role_lookup($db_moodle_roles, $role_id) { |
|
572
|
|
|
foreach( $db_moodle_roles as $db_moodle_role ){ |
|
573
|
|
|
if( $role_id == $db_moodle_role->id ) { |
|
574
|
|
|
return $db_moodle_role; |
|
575
|
|
|
} |
|
576
|
|
|
} |
|
577
|
|
|
} |
|
578
|
|
|
|
|
579
|
|
|
function bigbluebuttonbn_get_error_key($messageKey, $defaultKey = null) { |
|
580
|
|
|
$key = $defaultKey; |
|
581
|
|
|
if ( $messageKey == "checksumError" ){ |
|
582
|
|
|
$key = 'index_error_checksum'; |
|
583
|
|
|
} else if ( $messageKey == 'maxConcurrent' ) { |
|
584
|
|
|
$key = 'view_error_max_concurrent'; |
|
585
|
|
|
} |
|
586
|
|
|
return $key; |
|
587
|
|
|
} |
|
588
|
|
|
|
|
589
|
|
|
function bigbluebuttonbn_voicebridge_unique($voicebridge, $id=null) { |
|
590
|
|
|
global $DB; |
|
591
|
|
|
|
|
592
|
|
|
$is_unique = true; |
|
593
|
|
|
if( $voicebridge != 0 ) { |
|
594
|
|
|
$table = "bigbluebuttonbn"; |
|
595
|
|
|
$select = "voicebridge = ".$voicebridge; |
|
596
|
|
|
if( $id ) $select .= " AND id <> ".$id; |
|
597
|
|
|
if ( $rooms = $DB->get_records_select($table, $select) ) { |
|
|
|
|
|
|
598
|
|
|
$is_unique = false; |
|
599
|
|
|
} |
|
600
|
|
|
} |
|
601
|
|
|
|
|
602
|
|
|
return $is_unique; |
|
603
|
|
|
} |
|
604
|
|
|
|
|
605
|
|
|
function bigbluebuttonbn_get_duration($openingtime, $closingtime) { |
|
|
|
|
|
|
606
|
|
|
global $CFG; |
|
607
|
|
|
|
|
608
|
|
|
$duration = 0; |
|
609
|
|
|
$now = time(); |
|
610
|
|
|
if( $closingtime > 0 && $now < $closingtime ) { |
|
611
|
|
|
$duration = ceil(($closingtime - $now)/60); |
|
612
|
|
|
$compensation_time = intval(bigbluebuttonbn_get_cfg_scheduled_duration_compensation()); |
|
613
|
|
|
$duration = intval($duration) + $compensation_time; |
|
614
|
|
|
} |
|
615
|
|
|
|
|
616
|
|
|
return $duration; |
|
617
|
|
|
} |
|
618
|
|
|
|
|
619
|
|
|
function bigbluebuttonbn_get_presentation_array($context, $presentation, $id=null) { |
|
620
|
|
|
$presentation_name = null; |
|
621
|
|
|
$presentation_url = null; |
|
622
|
|
|
$presentation_icon = null; |
|
623
|
|
|
$presentation_mimetype_description = null; |
|
624
|
|
|
|
|
625
|
|
|
if( !empty($presentation) ) { |
|
626
|
|
|
$fs = get_file_storage(); |
|
627
|
|
|
$files = $fs->get_area_files($context->id, 'mod_bigbluebuttonbn', 'presentation', 0, 'itemid, filepath, filename', false); |
|
628
|
|
|
if (count($files) < 1) { |
|
|
|
|
|
|
629
|
|
|
//resource_print_filenotfound($resource, $cm, $course); |
|
|
|
|
|
|
630
|
|
|
//die; |
|
631
|
|
|
//exit; |
|
632
|
|
|
} else { |
|
633
|
|
|
$file = reset($files); |
|
634
|
|
|
unset($files); |
|
635
|
|
|
$presentation_name = $file->get_filename(); |
|
636
|
|
|
$presentation_icon = file_file_icon($file, 24); |
|
637
|
|
|
$presentation_mimetype_description = get_mimetype_description($file); |
|
638
|
|
|
|
|
639
|
|
|
if( !is_null($id) ) { |
|
640
|
|
|
//Create the nonce component for granting a temporary public access |
|
641
|
|
|
$cache = cache::make_from_params(cache_store::MODE_APPLICATION, 'mod_bigbluebuttonbn', 'presentation_cache'); |
|
642
|
|
|
$presentation_nonce_key = sha1($id); |
|
643
|
|
|
$presentation_nonce_value = bigbluebuttonbn_generate_nonce(); |
|
644
|
|
|
$cache->set($presentation_nonce_key, array( "value" => $presentation_nonce_value, "counter" => 0 )); |
|
645
|
|
|
|
|
646
|
|
|
//The item id was adapted for granting public access to the presentation once in order to allow BigBlueButton to gather the file |
|
647
|
|
|
$url = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), $presentation_nonce_value, $file->get_filepath(), $file->get_filename()); |
|
648
|
|
|
} else { |
|
649
|
|
|
$url = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), null, $file->get_filepath(), $file->get_filename()); |
|
650
|
|
|
} |
|
651
|
|
|
$presentation_url = $url->out(false); |
|
652
|
|
|
} |
|
653
|
|
|
} |
|
654
|
|
|
|
|
655
|
|
|
$presentation_array = array( "url" => $presentation_url, "name" => $presentation_name, "icon" => $presentation_icon, "mimetype_description" => $presentation_mimetype_description); |
|
656
|
|
|
|
|
657
|
|
|
return $presentation_array; |
|
658
|
|
|
} |
|
659
|
|
|
|
|
660
|
|
|
function bigbluebuttonbn_generate_nonce() { |
|
661
|
|
|
|
|
662
|
|
|
$mt = microtime(); |
|
663
|
|
|
$rand = mt_rand(); |
|
664
|
|
|
|
|
665
|
|
|
return md5($mt.$rand); |
|
666
|
|
|
} |
|
667
|
|
|
|
|
668
|
|
|
function bigbluebuttonbn_random_password( $length = 8 ) { |
|
669
|
|
|
|
|
670
|
|
|
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?"; |
|
671
|
|
|
$password = substr( str_shuffle( $chars ), 0, $length ); |
|
672
|
|
|
|
|
673
|
|
|
return $password; |
|
674
|
|
|
} |
|
675
|
|
|
|
|
676
|
|
|
function bigbluebuttonbn_get_moodle_version_major() { |
|
677
|
|
|
global $CFG; |
|
678
|
|
|
|
|
679
|
|
|
$version_array = explode('.', $CFG->version); |
|
680
|
|
|
return $version_array[0]; |
|
681
|
|
|
} |
|
682
|
|
|
|
|
683
|
|
|
function bigbluebuttonbn_event_log_standard($event_type, $bigbluebuttonbn, $context, $cm) { |
|
|
|
|
|
|
684
|
|
|
$context = context_module::instance($cm->id); |
|
685
|
|
|
$event_properties = array('context' => $context, 'objectid' => $bigbluebuttonbn->id); |
|
686
|
|
|
|
|
687
|
|
|
switch ($event_type) { |
|
688
|
|
|
case BIGBLUEBUTTON_EVENT_MEETING_JOINED: |
|
689
|
|
|
$event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_meeting_joined::create($event_properties); |
|
690
|
|
|
break; |
|
691
|
|
|
case BIGBLUEBUTTON_EVENT_MEETING_CREATED: |
|
692
|
|
|
$event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_meeting_created::create($event_properties); |
|
693
|
|
|
break; |
|
694
|
|
|
case BIGBLUEBUTTON_EVENT_MEETING_ENDED: |
|
695
|
|
|
$event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_meeting_ended::create($event_properties); |
|
696
|
|
|
break; |
|
697
|
|
|
case BIGBLUEBUTTON_EVENT_MEETING_LEFT: |
|
698
|
|
|
$event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_meeting_left::create($event_properties); |
|
699
|
|
|
break; |
|
700
|
|
|
case BIGBLUEBUTTON_EVENT_RECORDING_PUBLISHED: |
|
701
|
|
|
$event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_recording_published::create($event_properties); |
|
702
|
|
|
break; |
|
703
|
|
|
case BIGBLUEBUTTON_EVENT_RECORDING_UNPUBLISHED: |
|
704
|
|
|
$event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_recording_unpublished::create($event_properties); |
|
705
|
|
|
break; |
|
706
|
|
|
case BIGBLUEBUTTON_EVENT_RECORDING_DELETED: |
|
707
|
|
|
$event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_recording_deleted::create($event_properties); |
|
708
|
|
|
break; |
|
709
|
|
|
case BIGBLUEBUTTON_EVENT_ACTIVITY_VIEWED: |
|
710
|
|
|
$event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_activity_viewed::create($event_properties); |
|
711
|
|
|
break; |
|
712
|
|
|
case BIGBLUEBUTTON_EVENT_ACTIVITY_MANAGEMENT_VIEWED: |
|
713
|
|
|
$event = \mod_bigbluebuttonbn\event\bigbluebuttonbn_activity_management_viewed::create($event_properties); |
|
714
|
|
|
break; |
|
715
|
|
|
} |
|
716
|
|
|
|
|
717
|
|
|
$event->trigger(); |
|
|
|
|
|
|
718
|
|
|
} |
|
719
|
|
|
|
|
720
|
|
|
function bigbluebuttonbn_event_log_legacy($event_type, $bigbluebuttonbn, $context, $cm) { |
|
|
|
|
|
|
721
|
|
|
global $DB; |
|
722
|
|
|
|
|
723
|
|
|
switch ($event_type) { |
|
724
|
|
|
case BIGBLUEBUTTON_EVENT_MEETING_JOINED: |
|
725
|
|
|
$event = 'join'; |
|
726
|
|
|
break; |
|
727
|
|
|
case BIGBLUEBUTTON_EVENT_MEETING_CREATED: |
|
728
|
|
|
$event = 'create'; |
|
729
|
|
|
break; |
|
730
|
|
|
case BIGBLUEBUTTON_EVENT_MEETING_ENDED: |
|
731
|
|
|
$event = 'end'; |
|
732
|
|
|
break; |
|
733
|
|
|
case BIGBLUEBUTTON_EVENT_MEETING_LEFT: |
|
734
|
|
|
$event = 'left'; |
|
735
|
|
|
break; |
|
736
|
|
|
case BIGBLUEBUTTON_EVENT_RECORDING_PUBLISHED: |
|
737
|
|
|
$event = 'publish'; |
|
738
|
|
|
break; |
|
739
|
|
|
case BIGBLUEBUTTON_EVENT_RECORDING_UNPUBLISHED: |
|
740
|
|
|
$event = 'unpublish'; |
|
741
|
|
|
break; |
|
742
|
|
|
case BIGBLUEBUTTON_EVENT_RECORDING_DELETED: |
|
743
|
|
|
$event = 'delete'; |
|
744
|
|
|
break; |
|
745
|
|
|
case BIGBLUEBUTTON_EVENT_ACTIVITY_VIEWED: |
|
746
|
|
|
$event = 'view'; |
|
747
|
|
|
break; |
|
748
|
|
|
case BIGBLUEBUTTON_EVENT_ACTIVITY_MANAGEMENT_VIEWED: |
|
749
|
|
|
$event = 'view all'; |
|
750
|
|
|
break; |
|
751
|
|
|
default: |
|
752
|
|
|
return; |
|
753
|
|
|
} |
|
754
|
|
|
$course = $DB->get_record('course', array('id' => $bigbluebuttonbn->course), '*', MUST_EXIST); |
|
755
|
|
|
|
|
756
|
|
|
add_to_log($course->id, 'bigbluebuttonbn', $event, '', $bigbluebuttonbn->name, $cm->id); |
|
757
|
|
|
} |
|
758
|
|
|
|
|
759
|
|
|
function bigbluebuttonbn_event_log($event_type, $bigbluebuttonbn, $context, $cm) { |
|
760
|
|
|
global $CFG; |
|
761
|
|
|
|
|
762
|
|
|
$version_major = bigbluebuttonbn_get_moodle_version_major(); |
|
763
|
|
|
if ( $version_major < '2014051200' ) { |
|
764
|
|
|
//This is valid before v2.7 |
|
765
|
|
|
bigbluebuttonbn_event_log_legacy($event_type, $bigbluebuttonbn, $context, $cm); |
|
766
|
|
|
|
|
767
|
|
|
} else { |
|
768
|
|
|
//This is valid after v2.7 |
|
769
|
|
|
bigbluebuttonbn_event_log_standard($event_type, $bigbluebuttonbn, $context, $cm); |
|
770
|
|
|
} |
|
771
|
|
|
} |
|
772
|
|
|
|
|
773
|
|
|
function bigbluebuttonbn_bbb_broker_get_recordings($meetingid, $password, $forced=false) { |
|
|
|
|
|
|
774
|
|
|
global $CFG; |
|
775
|
|
|
|
|
776
|
|
|
$recordings = array(); |
|
|
|
|
|
|
777
|
|
|
$endpoint = bigbluebuttonbn_get_cfg_server_url(); |
|
|
|
|
|
|
778
|
|
|
$shared_secret = bigbluebuttonbn_get_cfg_shared_secret(); |
|
|
|
|
|
|
779
|
|
|
$cache_ttl = bigbluebuttonbn_get_cfg_waitformoderator_cache_ttl(); |
|
|
|
|
|
|
780
|
|
|
|
|
781
|
|
|
$cache = cache::make_from_params(cache_store::MODE_APPLICATION, 'mod_bigbluebuttonbn', 'meetings_cache'); |
|
|
|
|
|
|
782
|
|
|
} |
|
783
|
|
|
|
|
784
|
|
|
function bigbluebuttonbn_bbb_broker_participant_joined($meetingid, $is_moderator) { |
|
785
|
|
|
$cache = cache::make_from_params(cache_store::MODE_APPLICATION, 'mod_bigbluebuttonbn', 'meetings_cache'); |
|
786
|
|
|
$result = $cache->get($meetingid); |
|
787
|
|
|
$meeting_info = json_decode($result['meeting_info']); |
|
788
|
|
|
$meeting_info->participantCount += 1; |
|
789
|
|
|
if( $is_moderator ) { |
|
790
|
|
|
$meeting_info->moderatorCount += 1; |
|
791
|
|
|
} |
|
792
|
|
|
$cache->set($meetingid, array('creation_time' => $result['creation_time'], 'meeting_info' => json_encode($meeting_info) )); |
|
793
|
|
|
} |
|
794
|
|
|
|
|
795
|
|
|
function bigbluebuttonbn_bbb_broker_is_meeting_running($meeting_info) { |
|
796
|
|
|
$meeting_running = ( isset($meeting_info) && isset($meeting_info->returncode) && $meeting_info->returncode == 'SUCCESS' ); |
|
797
|
|
|
|
|
798
|
|
|
return $meeting_running; |
|
799
|
|
|
} |
|
800
|
|
|
|
|
801
|
|
|
function bigbluebuttonbn_bbb_broker_get_meeting_info($meetingid, $password, $forced=false) { |
|
802
|
|
|
global $CFG; |
|
803
|
|
|
|
|
804
|
|
|
$meeting_info = array(); |
|
|
|
|
|
|
805
|
|
|
$endpoint = bigbluebuttonbn_get_cfg_server_url(); |
|
806
|
|
|
$shared_secret = bigbluebuttonbn_get_cfg_shared_secret(); |
|
807
|
|
|
$cache_ttl = bigbluebuttonbn_get_cfg_waitformoderator_cache_ttl(); |
|
808
|
|
|
|
|
809
|
|
|
$cache = cache::make_from_params(cache_store::MODE_APPLICATION, 'mod_bigbluebuttonbn', 'meetings_cache'); |
|
810
|
|
|
$result = $cache->get($meetingid); |
|
811
|
|
|
$now = time(); |
|
812
|
|
|
if( isset($result) && $now < ($result['creation_time'] + $cache_ttl) && !$forced ) { |
|
813
|
|
|
//Use the value in the cache |
|
814
|
|
|
$meeting_info = json_decode($result['meeting_info']); |
|
815
|
|
|
} else { |
|
816
|
|
|
//Ping again and refresh the cache |
|
817
|
|
|
$meeting_info = (array) bigbluebuttonbn_getMeetingInfo( $meetingid, $password, $endpoint, $shared_secret ); |
|
818
|
|
|
$cache->set($meetingid, array('creation_time' => time(), 'meeting_info' => json_encode($meeting_info) )); |
|
819
|
|
|
} |
|
820
|
|
|
|
|
821
|
|
|
return $meeting_info; |
|
822
|
|
|
} |
|
823
|
|
|
|
|
824
|
|
|
function bigbluebuttonbn_bbb_broker_do_end_meeting($meetingid, $password){ |
|
825
|
|
|
global $CFG; |
|
826
|
|
|
|
|
827
|
|
|
$endpoint = bigbluebuttonbn_get_cfg_server_url(); |
|
828
|
|
|
$shared_secret = bigbluebuttonbn_get_cfg_shared_secret(); |
|
829
|
|
|
|
|
830
|
|
|
bigbluebuttonbn_doEndMeeting($meetingid, $password, $endpoint, $shared_secret); |
|
831
|
|
|
} |
|
832
|
|
|
|
|
833
|
|
|
function bigbluebuttonbn_bbb_broker_do_publish_recording($recordingid, $publish=true){ |
|
834
|
|
|
global $CFG; |
|
835
|
|
|
|
|
836
|
|
|
$endpoint = bigbluebuttonbn_get_cfg_server_url(); |
|
837
|
|
|
$shared_secret = bigbluebuttonbn_get_cfg_shared_secret(); |
|
838
|
|
|
|
|
839
|
|
|
bigbluebuttonbn_doPublishRecordings($recordingid, ($publish)? 'true': 'false', $endpoint, $shared_secret); |
|
840
|
|
|
} |
|
841
|
|
|
|
|
842
|
|
|
function bigbluebuttonbn_bbb_broker_do_publish_recording_imported($recordingid, $courseID, $bigbluebuttonbnID, $publish=true){ |
|
|
|
|
|
|
843
|
|
|
global $DB; |
|
844
|
|
|
|
|
845
|
|
|
//Locate the record to be updated |
|
846
|
|
|
$records = $DB->get_records('bigbluebuttonbn_logs', array('bigbluebuttonbnid' => $bigbluebuttonbnID, 'log' => BIGBLUEBUTTONBN_LOG_EVENT_IMPORT)); |
|
847
|
|
|
|
|
848
|
|
|
$recordings_imported = array(); |
|
|
|
|
|
|
849
|
|
|
foreach ($records as $key => $record) { |
|
850
|
|
|
$meta = json_decode($record->meta, true); |
|
851
|
|
|
if( $recordingid == $meta['recording']['recordID'] ) { |
|
852
|
|
|
// Found, prepare data for the update |
|
853
|
|
|
$meta['recording']['published'] = ($publish)? 'true': 'false'; |
|
854
|
|
|
$records[$key]->meta = json_encode($meta); |
|
855
|
|
|
|
|
856
|
|
|
// Proceed with the update |
|
857
|
|
|
$DB->update_record("bigbluebuttonbn_logs", $records[$key]); |
|
858
|
|
|
} |
|
859
|
|
|
} |
|
860
|
|
|
} |
|
861
|
|
|
|
|
862
|
|
|
function bigbluebuttonbn_bbb_broker_do_delete_recording($recordingid){ |
|
863
|
|
|
global $CFG; |
|
864
|
|
|
|
|
865
|
|
|
$endpoint = bigbluebuttonbn_get_cfg_server_url(); |
|
866
|
|
|
$shared_secret = bigbluebuttonbn_get_cfg_shared_secret(); |
|
867
|
|
|
|
|
868
|
|
|
bigbluebuttonbn_doDeleteRecordings($recordingid, $endpoint, $shared_secret); |
|
869
|
|
|
} |
|
870
|
|
|
|
|
871
|
|
|
function bigbluebuttonbn_bbb_broker_do_delete_recording_imported($recordingid, $courseID, $bigbluebuttonbnID){ |
|
|
|
|
|
|
872
|
|
|
global $DB; |
|
873
|
|
|
|
|
874
|
|
|
//Locate the record to be updated |
|
875
|
|
|
$records = $DB->get_records('bigbluebuttonbn_logs', array('bigbluebuttonbnid' => $bigbluebuttonbnID, 'log' => BIGBLUEBUTTONBN_LOG_EVENT_IMPORT)); |
|
876
|
|
|
|
|
877
|
|
|
$recordings_imported = array(); |
|
|
|
|
|
|
878
|
|
|
foreach ($records as $key => $record) { |
|
879
|
|
|
$meta = json_decode($record->meta, true); |
|
880
|
|
|
if( $recordingid == $meta['recording']['recordID'] ) { |
|
881
|
|
|
// Execute delete |
|
882
|
|
|
$DB->delete_records("bigbluebuttonbn_logs", array('id' => $key)); |
|
883
|
|
|
} |
|
884
|
|
|
} |
|
885
|
|
|
} |
|
886
|
|
|
|
|
887
|
|
|
function bigbluebuttonbn_bbb_broker_validate_parameters($params) { |
|
888
|
|
|
$error = ''; |
|
889
|
|
|
|
|
890
|
|
|
if ( !isset($params['callback']) ) { |
|
891
|
|
|
$error = $bigbluebuttonbn_bbb_broker_add_error($error, 'This call must include a javascript callback.'); |
|
|
|
|
|
|
892
|
|
|
} |
|
893
|
|
|
|
|
894
|
|
|
if ( !isset($params['action']) ) { |
|
895
|
|
|
$error = $bigbluebuttonbn_bbb_broker_add_error($error, 'Action parameter must be included.'); |
|
896
|
|
|
} else { |
|
897
|
|
|
switch ( strtolower($params['action']) ){ |
|
898
|
|
|
case 'server_ping': |
|
899
|
|
|
case 'meeting_info': |
|
900
|
|
|
case 'meeting_end': |
|
901
|
|
|
if ( !isset($params['id']) ) { |
|
902
|
|
|
$error = $bigbluebuttonbn_bbb_broker_add_error($error, 'The meetingID must be specified.'); |
|
903
|
|
|
} |
|
904
|
|
|
break; |
|
905
|
|
|
case 'recording_list': |
|
906
|
|
|
case 'recording_info': |
|
907
|
|
|
case 'recording_publish': |
|
908
|
|
|
case 'recording_unpublish': |
|
909
|
|
|
case 'recording_delete': |
|
910
|
|
|
case 'recording_import': |
|
911
|
|
|
if ( !isset($params['id']) ) { |
|
912
|
|
|
$error = bigbluebuttonbn_bbb_broker_add_error($error, 'The recordingID must be specified.'); |
|
913
|
|
|
} |
|
914
|
|
|
break; |
|
915
|
|
|
case 'recording_ready': |
|
916
|
|
|
if( empty($params['signed_parameters']) ) { |
|
917
|
|
|
$error = bigbluebuttonbn_bbb_broker_add_error($error, 'A JWT encoded string must be included as [signed_parameters].'); |
|
918
|
|
|
} |
|
919
|
|
|
break; |
|
920
|
|
|
default: |
|
921
|
|
|
$error = bigbluebuttonbn_bbb_broker_add_error($error, 'Action '.$params['action'].' can not be performed.'); |
|
922
|
|
|
} |
|
923
|
|
|
} |
|
924
|
|
|
|
|
925
|
|
|
return $error; |
|
926
|
|
|
} |
|
927
|
|
|
|
|
928
|
|
|
function bigbluebuttonbn_bbb_broker_add_error($org_msg, $new_msg='') { |
|
929
|
|
|
$error = $org_msg; |
|
930
|
|
|
|
|
931
|
|
|
if( !empty($new_msg) ) { |
|
932
|
|
|
if( !empty($error) ) $error .= ' '; |
|
933
|
|
|
$error .= $new_msg; |
|
934
|
|
|
} |
|
935
|
|
|
|
|
936
|
|
|
return $error; |
|
937
|
|
|
} |
|
938
|
|
|
|
|
939
|
|
|
function bigbluebuttonbn_get_recording_data_row($bbbsession, $recording, $tools=["publishing", "deleting"]) { |
|
940
|
|
|
global $OUTPUT, $CFG, $USER; |
|
941
|
|
|
|
|
942
|
|
|
$row = null; |
|
943
|
|
|
|
|
944
|
|
|
if ( $bbbsession['managerecordings'] || $recording['published'] == 'true' ) { |
|
945
|
|
|
$length = 0; |
|
|
|
|
|
|
946
|
|
|
$endTime = isset($recording['endTime'])? floatval($recording['endTime']):0; |
|
947
|
|
|
$endTime = $endTime - ($endTime % 1000); |
|
948
|
|
|
$startTime = isset($recording['startTime'])? floatval($recording['startTime']):0; |
|
949
|
|
|
$startTime = $startTime - ($startTime % 1000); |
|
950
|
|
|
$duration = intval(($endTime - $startTime) / 60000); |
|
951
|
|
|
|
|
952
|
|
|
//$meta_course = isset($recording['meta_context'])?str_replace('"', '\"', $recording['meta_context']):''; |
|
|
|
|
|
|
953
|
|
|
//For backward compatibility |
|
954
|
|
|
if( isset($recording['meta_contextactivity']) ) { |
|
955
|
|
|
$meta_activity = str_replace('"', '\"', $recording['meta_contextactivity']); |
|
|
|
|
|
|
956
|
|
|
} if( isset($recording['meta_bbb-recording-name']) ) { |
|
957
|
|
|
$meta_activity = str_replace('"', '\"', $recording['meta_bbb-recording-name']); |
|
958
|
|
|
} else { |
|
959
|
|
|
$meta_activity = str_replace('"', '\"', $recording['meetingName']); |
|
960
|
|
|
} |
|
961
|
|
|
|
|
962
|
|
|
if( isset($recording['meta_contextactivitydescription']) ) { |
|
963
|
|
|
$meta_description = str_replace('"', '\"', $recording['meta_contextactivitydescription']); |
|
964
|
|
|
} else if( isset($recording['meta_bbb-recording-description']) ) { |
|
965
|
|
|
$meta_description = str_replace('"', '\"', $recording['meta_bbb-recording-description']); |
|
966
|
|
|
} else { |
|
967
|
|
|
$meta_description = ''; |
|
968
|
|
|
} |
|
969
|
|
|
|
|
970
|
|
|
//Set recording_types |
|
971
|
|
|
if ( isset($recording['imported']) ) { |
|
972
|
|
|
$attributes = 'data-imported="true" title='.get_string('view_recording_link_warning', 'bigbluebuttonbn'); |
|
973
|
|
|
} else { |
|
974
|
|
|
$attributes = 'data-imported="false"'; |
|
975
|
|
|
} |
|
976
|
|
|
|
|
977
|
|
|
$recording_types = ''; |
|
978
|
|
|
if ($recording['published'] == 'true') { |
|
979
|
|
|
$recording_types .= '<div id="playbacks-'.$recording['recordID'].'" '.$attributes.'>'; |
|
980
|
|
|
} else { |
|
981
|
|
|
$recording_types .= '<div id="playbacks-'.$recording['recordID'].'" '.$attributes.'" hidden>'; |
|
982
|
|
|
} |
|
983
|
|
|
foreach ( $recording['playbacks'] as $playback ) { |
|
984
|
|
|
$recording_types .= $OUTPUT->action_link($playback['url'], get_string('view_recording_format_'.$playback['type'], 'bigbluebuttonbn'), null, array('title' => get_string('view_recording_format_'.$playback['type'], 'bigbluebuttonbn'), 'target' => '_new') ).' '; |
|
985
|
|
|
} |
|
986
|
|
|
$recording_types .= '</div>'; |
|
987
|
|
|
|
|
988
|
|
|
//Initialize variables for styling text |
|
989
|
|
|
$head = $tail = ''; |
|
990
|
|
|
|
|
991
|
|
|
//Set actionbar, if user is allowed to manage recordings |
|
992
|
|
|
$actionbar = ''; |
|
993
|
|
|
if ( $bbbsession['managerecordings'] ) { |
|
994
|
|
|
// Set style for imported links |
|
995
|
|
|
if( isset($recording['imported']) ) { |
|
996
|
|
|
$recordings_imported_count = 0; |
|
997
|
|
|
$tag_tail = ' '.get_string('view_recording_link', 'bigbluebuttonbn'); |
|
998
|
|
|
$head = '<i>'; |
|
999
|
|
|
$tail = '</i>'; |
|
1000
|
|
|
|
|
1001
|
|
|
} else { |
|
1002
|
|
|
$recordings_imported_array = bigbluebuttonbn_getRecordingsImportedAllInstancesArray($recording['recordID']); |
|
1003
|
|
|
$recordings_imported_count = count($recordings_imported_array); |
|
1004
|
|
|
$tag_tail = ''; |
|
1005
|
|
|
} |
|
1006
|
|
|
|
|
1007
|
|
|
$url = '#'; |
|
1008
|
|
|
$action = null; |
|
1009
|
|
|
|
|
1010
|
|
|
|
|
1011
|
|
|
if (in_array("publishing", $tools)) { |
|
1012
|
|
|
///Set action [show|hide] |
|
1013
|
|
|
if ( $recording['published'] == 'true' ){ |
|
1014
|
|
|
$manage_tag = 'hide'; |
|
1015
|
|
|
$manage_action = 'unpublish'; |
|
1016
|
|
|
} else { |
|
1017
|
|
|
$manage_tag = 'show'; |
|
1018
|
|
|
$manage_action = 'publish'; |
|
1019
|
|
|
} |
|
1020
|
|
|
$onclick = 'M.mod_bigbluebuttonbn.broker_manageRecording("'.$manage_action.'", "'.$recording['recordID'].'", "'.$recording['meetingID'].'");'; |
|
1021
|
|
|
|
|
1022
|
|
|
if ( bigbluebuttonbn_get_cfg_recording_icons_enabled() ) { |
|
1023
|
|
|
//With icon for publish/unpublish |
|
1024
|
|
|
$icon_attributes = array('id' => 'recording-btn-'.$manage_action.'-'.$recording['recordID']); |
|
1025
|
|
|
$icon = new pix_icon('t/'.$manage_tag, get_string($manage_tag).$tag_tail, 'moodle', $icon_attributes); |
|
1026
|
|
|
$link_attributes = array('id' => 'recording-link-'.$manage_action.'-'.$recording['recordID'], 'onclick' => $onclick, 'data-links' => $recordings_imported_count); |
|
1027
|
|
|
$actionbar .= $OUTPUT->action_icon($url, $icon, $action, $link_attributes, false); |
|
1028
|
|
|
|
|
1029
|
|
|
} else { |
|
1030
|
|
|
//With text for publish/unpublish |
|
1031
|
|
|
$link_attributes = array('title' => get_string($manage_tag).$tag_tail, 'class' => 'btn btn-xs', 'onclick' => $onclick, 'data-links' => $recordings_imported_count); |
|
1032
|
|
|
$actionbar .= $OUTPUT->action_link($url, get_string($manage_tag).$tag_tail, $action, $link_attributes); |
|
1033
|
|
|
$actionbar .= " "; |
|
1034
|
|
|
} |
|
1035
|
|
|
} |
|
1036
|
|
|
|
|
1037
|
|
|
if (in_array("deleting", $tools)) { |
|
1038
|
|
|
$onclick = 'M.mod_bigbluebuttonbn.broker_manageRecording("delete", "'.$recording['recordID'].'", "'.$recording['meetingID'].'");'; |
|
1039
|
|
|
|
|
1040
|
|
|
if ( bigbluebuttonbn_get_cfg_recording_icons_enabled() ) { |
|
1041
|
|
|
//With icon for delete |
|
1042
|
|
|
$icon_attributes = array('id' => 'recording-btn-delete-'.$recording['recordID']); |
|
1043
|
|
|
$icon = new pix_icon('t/delete', get_string('delete').$tag_tail, 'moodle', $icon_attributes); |
|
1044
|
|
|
$link_attributes = array('id' => 'recording-link-delete-'.$recording['recordID'], 'onclick' => $onclick, 'data-links' => $recordings_imported_count); |
|
1045
|
|
|
$actionbar .= $OUTPUT->action_icon($url, $icon, $action, $link_attributes, false); |
|
1046
|
|
|
|
|
1047
|
|
|
} else { |
|
1048
|
|
|
//With text for delete |
|
1049
|
|
|
$link_attributes = array('title' => get_string('delete').$tag_tail, 'class' => 'btn btn-xs btn-danger', 'onclick' => $onclick, 'data-links' => $recordings_imported_count); |
|
1050
|
|
|
$actionbar .= $OUTPUT->action_link($url, get_string('delete').$tag_tail, $action, $link_attributes); |
|
1051
|
|
|
} |
|
1052
|
|
|
} |
|
1053
|
|
|
|
|
1054
|
|
|
if (in_array("importing", $tools)) { |
|
1055
|
|
|
$onclick = 'M.mod_bigbluebuttonbn.broker_manageRecording("import", "'.$recording['recordID'].'", "'.$recording['meetingID'].'");'; |
|
1056
|
|
|
|
|
1057
|
|
|
if ( bigbluebuttonbn_get_cfg_recording_icons_enabled() ) { |
|
1058
|
|
|
//With icon for import |
|
1059
|
|
|
$icon_attributes = array('id' => 'recording-btn-import-'.$recording['recordID']); |
|
1060
|
|
|
$icon = new pix_icon('i/import', get_string('import'), 'moodle', $icon_attributes); |
|
1061
|
|
|
$link_attributes = array('id' => 'recording-link-import-'.$recording['recordID'], 'onclick' => $onclick); |
|
1062
|
|
|
$actionbar .= $OUTPUT->action_icon($url, $icon, $action, $link_attributes, false); |
|
1063
|
|
|
|
|
1064
|
|
|
} else { |
|
1065
|
|
|
//With text for import |
|
1066
|
|
|
$link_attributes = array('title' => get_string('import'), 'class' => 'btn btn-xs btn-danger', 'onclick' => $onclick); |
|
1067
|
|
|
$actionbar .= $OUTPUT->action_link($url, get_string('import'), $action, $link_attributes); |
|
1068
|
|
|
} |
|
1069
|
|
|
} |
|
1070
|
|
|
} |
|
1071
|
|
|
|
|
1072
|
|
|
//Set corresponding format |
|
1073
|
|
|
$format = '%a %h %d, %Y %H:%M:%S %Z'; |
|
1074
|
|
|
$formattedStartDate = userdate($startTime / 1000, $format, usertimezone($USER->timezone)); |
|
1075
|
|
|
|
|
1076
|
|
|
$row = new stdClass(); |
|
1077
|
|
|
$row->recording = "{$head}{$recording_types}{$tail}"; |
|
1078
|
|
|
$row->activity = "{$head}{$meta_activity}{$tail}"; |
|
1079
|
|
|
$row->description = "{$head}{$meta_description}{$tail}"; |
|
1080
|
|
|
$row->date = floatval($recording['startTime']); |
|
1081
|
|
|
$row->date_formatted = "{$head}{$formattedStartDate}{$tail}"; |
|
1082
|
|
|
$row->duration = "{$head}{$duration}{$tail}"; |
|
1083
|
|
|
if ( $bbbsession['managerecordings'] ) { |
|
1084
|
|
|
$row->actionbar = $actionbar; |
|
1085
|
|
|
} |
|
1086
|
|
|
} |
|
1087
|
|
|
|
|
1088
|
|
|
return $row; |
|
1089
|
|
|
} |
|
1090
|
|
|
|
|
1091
|
|
|
function bigbluebuttonbn_get_recording_columns($bbbsession, $recordings) { |
|
|
|
|
|
|
1092
|
|
|
///Set strings to show |
|
1093
|
|
|
$view_recording_recording = get_string('view_recording_recording', 'bigbluebuttonbn'); |
|
1094
|
|
|
$view_recording_activity = get_string('view_recording_activity', 'bigbluebuttonbn'); |
|
1095
|
|
|
$view_recording_description = get_string('view_recording_description', 'bigbluebuttonbn'); |
|
1096
|
|
|
$view_recording_date = get_string('view_recording_date', 'bigbluebuttonbn'); |
|
1097
|
|
|
$view_recording_duration = get_string('view_recording_duration', 'bigbluebuttonbn'); |
|
1098
|
|
|
$view_recording_actionbar = get_string('view_recording_actionbar', 'bigbluebuttonbn'); |
|
1099
|
|
|
|
|
1100
|
|
|
///Initialize table headers |
|
1101
|
|
|
$recordingsbn_columns = array( |
|
1102
|
|
|
array("key" =>"recording", "label" => $view_recording_recording, "width" => "125px", "allowHTML" => true), |
|
1103
|
|
|
array("key" =>"activity", "label" => $view_recording_activity, "sortable" => true, "width" => "175px"), |
|
1104
|
|
|
array("key" =>"description", "label" => $view_recording_description, "sortable" => true, "width" => "250px"), |
|
1105
|
|
|
array("key" =>"date", "label" => $view_recording_date, "sortable" => true, "width" => "220px"), |
|
1106
|
|
|
array("key" =>"duration", "label" => $view_recording_duration, "width" => "50px") |
|
1107
|
|
|
); |
|
1108
|
|
|
|
|
1109
|
|
|
if ( $bbbsession['managerecordings'] ) { |
|
1110
|
|
|
array_push($recordingsbn_columns, array("key" =>"actionbar", "label" => $view_recording_actionbar, "width" => "75px", "allowHTML" => true)); |
|
1111
|
|
|
} |
|
1112
|
|
|
|
|
1113
|
|
|
return $recordingsbn_columns; |
|
1114
|
|
|
} |
|
1115
|
|
|
|
|
1116
|
|
|
function bigbluebuttonbn_get_recording_data($bbbsession, $recordings, $tools=["publishing", "deleting"]) { |
|
1117
|
|
|
$table_data = array(); |
|
1118
|
|
|
|
|
1119
|
|
|
///Build table content |
|
1120
|
|
|
if ( isset($recordings) && !array_key_exists('messageKey', $recordings)) { // There are recordings for this meeting |
|
1121
|
|
|
foreach ( $recordings as $recording ) { |
|
1122
|
|
|
$row = bigbluebuttonbn_get_recording_data_row($bbbsession, $recording, $tools); |
|
1123
|
|
|
if( $row != null ) { |
|
1124
|
|
|
array_push($table_data, $row); |
|
1125
|
|
|
} |
|
1126
|
|
|
} |
|
1127
|
|
|
} |
|
1128
|
|
|
|
|
1129
|
|
|
return $table_data; |
|
1130
|
|
|
} |
|
1131
|
|
|
|
|
1132
|
|
|
function bigbluebuttonbn_get_recording_table($bbbsession, $recordings, $tools=['publishing','deleting']) { |
|
1133
|
|
|
global $OUTPUT, $CFG; |
|
1134
|
|
|
|
|
1135
|
|
|
///Set strings to show |
|
1136
|
|
|
$view_recording_recording = get_string('view_recording_recording', 'bigbluebuttonbn'); |
|
1137
|
|
|
$view_recording_course = get_string('view_recording_course', 'bigbluebuttonbn'); |
|
|
|
|
|
|
1138
|
|
|
$view_recording_activity = get_string('view_recording_activity', 'bigbluebuttonbn'); |
|
1139
|
|
|
$view_recording_description = get_string('view_recording_description', 'bigbluebuttonbn'); |
|
1140
|
|
|
$view_recording_date = get_string('view_recording_date', 'bigbluebuttonbn'); |
|
1141
|
|
|
$view_recording_length = get_string('view_recording_length', 'bigbluebuttonbn'); |
|
|
|
|
|
|
1142
|
|
|
$view_recording_duration = get_string('view_recording_duration', 'bigbluebuttonbn'); |
|
1143
|
|
|
$view_recording_actionbar = get_string('view_recording_actionbar', 'bigbluebuttonbn'); |
|
1144
|
|
|
$view_duration_min = get_string('view_recording_duration_min', 'bigbluebuttonbn'); |
|
|
|
|
|
|
1145
|
|
|
|
|
1146
|
|
|
///Declare the table |
|
1147
|
|
|
$table = new html_table(); |
|
1148
|
|
|
$table->data = array(); |
|
1149
|
|
|
|
|
1150
|
|
|
///Initialize table headers |
|
1151
|
|
|
if ( $bbbsession['managerecordings'] ) { |
|
1152
|
|
|
$table->head = array ($view_recording_recording, $view_recording_activity, $view_recording_description, $view_recording_date, $view_recording_duration, $view_recording_actionbar); |
|
1153
|
|
|
$table->align = array ('left', 'left', 'left', 'left', 'center', 'left'); |
|
1154
|
|
|
} else { |
|
1155
|
|
|
$table->head = array ($view_recording_recording, $view_recording_activity, $view_recording_description, $view_recording_date, $view_recording_duration); |
|
1156
|
|
|
$table->align = array ('left', 'left', 'left', 'left', 'center'); |
|
1157
|
|
|
} |
|
1158
|
|
|
|
|
1159
|
|
|
///Build table content |
|
1160
|
|
|
if ( isset($recordings) && !array_key_exists('messageKey', $recordings)) { // There are recordings for this meeting |
|
1161
|
|
|
foreach ( $recordings as $recording ){ |
|
1162
|
|
|
$row = new html_table_row(); |
|
1163
|
|
|
$row->id = 'recording-td-'.$recording['recordID']; |
|
1164
|
|
|
if ( isset($recording['imported']) ) { |
|
1165
|
|
|
$row->attributes['data-imported'] = 'true'; |
|
1166
|
|
|
$row->attributes['title'] = get_string('view_recording_link_warning', 'bigbluebuttonbn'); |
|
1167
|
|
|
} else { |
|
1168
|
|
|
$row->attributes['data-imported'] = 'false'; |
|
1169
|
|
|
} |
|
1170
|
|
|
|
|
1171
|
|
|
$row_data = bigbluebuttonbn_get_recording_data_row($bbbsession, $recording, $tools); |
|
1172
|
|
|
if( $row_data != null ) { |
|
1173
|
|
|
$row_data->date_formatted = str_replace(" ", " ", $row_data->date_formatted); |
|
1174
|
|
|
if ( $bbbsession['managerecordings'] ) { |
|
1175
|
|
|
$row->cells = array ($row_data->recording, $row_data->activity, $row_data->description, $row_data->date_formatted, $row_data->duration, $row_data->actionbar ); |
|
1176
|
|
|
} else { |
|
1177
|
|
|
$row->cells = array ($row_data->recording, $row_data->activity, $row_data->description, $row_data->date_formatted, $row_data->duration ); |
|
1178
|
|
|
} |
|
1179
|
|
|
|
|
1180
|
|
|
array_push($table->data, $row); |
|
1181
|
|
|
} |
|
1182
|
|
|
} |
|
1183
|
|
|
} |
|
1184
|
|
|
|
|
1185
|
|
|
return $table; |
|
1186
|
|
|
} |
|
1187
|
|
|
|
|
1188
|
|
|
function bigbluebuttonbn_send_notification_recording_ready($bigbluebuttonbn) { |
|
1189
|
|
|
$sender = get_admin(); |
|
1190
|
|
|
|
|
1191
|
|
|
// Prepare message |
|
1192
|
|
|
$msg = new stdClass(); |
|
1193
|
|
|
|
|
1194
|
|
|
/// Build the message_body |
|
1195
|
|
|
$msg->activity_type = ""; |
|
1196
|
|
|
$msg->activity_title = $bigbluebuttonbn->name; |
|
1197
|
|
|
$message_text = '<p>'.get_string('email_body_recording_ready_for', 'bigbluebuttonbn').' '.$msg->activity_type.' "'.$msg->activity_title.'" '.get_string('email_body_recording_ready_is_ready', 'bigbluebuttonbn').'.</p>'; |
|
1198
|
|
|
|
|
1199
|
|
|
bigbluebuttonbn_send_notification($sender, $bigbluebuttonbn, $message_text); |
|
1200
|
|
|
} |
|
1201
|
|
|
|
|
1202
|
|
|
function bigbluebuttonbn_server_offers($capability_name){ |
|
1203
|
|
|
global $CFG; |
|
1204
|
|
|
|
|
1205
|
|
|
$capability_offered = null; |
|
1206
|
|
|
|
|
1207
|
|
|
$endpoint = bigbluebuttonbn_get_cfg_server_url(); |
|
1208
|
|
|
$shared_secret = bigbluebuttonbn_get_cfg_shared_secret(); |
|
1209
|
|
|
|
|
1210
|
|
|
//Validates if the server may have extended capabilities |
|
1211
|
|
|
$parse = parse_url($endpoint); |
|
1212
|
|
|
$host = $parse['host']; |
|
1213
|
|
|
$host_ends = explode(".", $host); |
|
1214
|
|
|
$host_ends_length = count($host_ends); |
|
1215
|
|
|
|
|
1216
|
|
|
if( $host_ends_length > 0 && $host_ends[$host_ends_length -1] == 'com' && $host_ends[$host_ends_length -2] == 'blindsidenetworks' ) { |
|
1217
|
|
|
//Validate the capabilities offered |
|
1218
|
|
|
$capabilities = bigbluebuttonbn_getCapabilitiesArray( $endpoint, $shared_secret ); |
|
1219
|
|
|
if( $capabilities ) { |
|
1220
|
|
|
foreach ($capabilities as $capability) { |
|
1221
|
|
|
if( $capability["name"] == $capability_name) |
|
1222
|
|
|
$capability_offered = $capability; |
|
1223
|
|
|
} |
|
1224
|
|
|
} |
|
1225
|
|
|
} |
|
1226
|
|
|
|
|
1227
|
|
|
return $capability_offered; |
|
1228
|
|
|
} |
|
1229
|
|
|
|
|
1230
|
|
|
function bigbluebuttonbn_server_offers_bn_capabilities(){ |
|
1231
|
|
|
//Validates if the server may have extended capabilities |
|
1232
|
|
|
$parsed_url = parse_url(bigbluebuttonbn_get_cfg_server_url()); |
|
1233
|
|
|
$host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
|
1234
|
|
|
$host_ends = explode(".", $host); |
|
1235
|
|
|
$host_ends_length = count($host_ends); |
|
1236
|
|
|
|
|
1237
|
|
|
return ( $host_ends_length > 0 && $host_ends[$host_ends_length -1] == 'com' && $host_ends[$host_ends_length -2] == 'blindsidenetworks' ); |
|
1238
|
|
|
} |
|
1239
|
|
|
|
|
1240
|
|
|
function bigbluebuttonbn_get_locales_for_ui() { |
|
1241
|
|
|
$locales = array( |
|
1242
|
|
|
'not_started' => get_string('view_message_conference_not_started', 'bigbluebuttonbn'), |
|
1243
|
|
|
'wait_for_moderator' => get_string('view_message_conference_wait_for_moderator', 'bigbluebuttonbn'), |
|
1244
|
|
|
'in_progress' => get_string('view_message_conference_in_progress', 'bigbluebuttonbn'), |
|
1245
|
|
|
'started_at' => get_string('view_message_session_started_at', 'bigbluebuttonbn'), |
|
1246
|
|
|
'session_no_users' => get_string('view_message_session_no_users', 'bigbluebuttonbn'), |
|
1247
|
|
|
'session_has_user' => get_string('view_message_session_has_user', 'bigbluebuttonbn'), |
|
1248
|
|
|
'session_has_users' => get_string('view_message_session_has_users', 'bigbluebuttonbn'), |
|
1249
|
|
|
'has_joined' => get_string('view_message_has_joined', 'bigbluebuttonbn'), |
|
1250
|
|
|
'have_joined' => get_string('view_message_have_joined', 'bigbluebuttonbn'), |
|
1251
|
|
|
'user' => get_string('view_message_user', 'bigbluebuttonbn'), |
|
1252
|
|
|
'users' => get_string('view_message_users', 'bigbluebuttonbn'), |
|
1253
|
|
|
'viewer' => get_string('view_message_viewer', 'bigbluebuttonbn'), |
|
1254
|
|
|
'viewers' => get_string('view_message_viewers', 'bigbluebuttonbn'), |
|
1255
|
|
|
'moderator' => get_string('view_message_moderator', 'bigbluebuttonbn'), |
|
1256
|
|
|
'moderators' => get_string('view_message_moderators', 'bigbluebuttonbn'), |
|
1257
|
|
|
'publish' => get_string('view_recording_list_actionbar_publish', 'bigbluebuttonbn'), |
|
1258
|
|
|
'publishing' => get_string('view_recording_list_actionbar_publishing', 'bigbluebuttonbn'), |
|
1259
|
|
|
'unpublish' => get_string('view_recording_list_actionbar_unpublish', 'bigbluebuttonbn'), |
|
1260
|
|
|
'unpublishing' => get_string('view_recording_list_actionbar_unpublishing', 'bigbluebuttonbn'), |
|
1261
|
|
|
'modal_title' => get_string('view_recording_modal_title', 'bigbluebuttonbn'), |
|
1262
|
|
|
'modal_button' => get_string('view_recording_modal_button', 'bigbluebuttonbn'), |
|
1263
|
|
|
'userlimit_reached' => get_string('view_error_userlimit_reached', 'bigbluebuttonbn'), |
|
1264
|
|
|
'recording' => get_string('view_recording', 'bigbluebuttonbn'), |
|
1265
|
|
|
'recording_link' => get_string('view_recording_link', 'bigbluebuttonbn'), |
|
1266
|
|
|
'recording_link_warning' => get_string('view_recording_link_warning', 'bigbluebuttonbn'), |
|
1267
|
|
|
'unpublish_confirmation' => get_string('view_recording_unpublish_confirmation', 'bigbluebuttonbn'), |
|
1268
|
|
|
'unpublish_confirmation_warning_s' => get_string('view_recording_unpublish_confirmation_warning_s', 'bigbluebuttonbn'), |
|
1269
|
|
|
'unpublish_confirmation_warning_p' => get_string('view_recording_unpublish_confirmation_warning_p', 'bigbluebuttonbn'), |
|
1270
|
|
|
'delete_confirmation' => get_string('view_recording_delete_confirmation', 'bigbluebuttonbn'), |
|
1271
|
|
|
'delete_confirmation_warning_s' => get_string('view_recording_delete_confirmation_warning_s', 'bigbluebuttonbn'), |
|
1272
|
|
|
'delete_confirmation_warning_p' => get_string('view_recording_delete_confirmation_warning_p', 'bigbluebuttonbn'), |
|
1273
|
|
|
'import_confirmation' => get_string('view_recording_import_confirmation', 'bigbluebuttonbn'), |
|
1274
|
|
|
); |
|
1275
|
|
|
return $locales; |
|
1276
|
|
|
} |
|
1277
|
|
|
|
|
1278
|
|
|
function bigbluebuttonbn_get_cfg_server_url_default() { |
|
1279
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1280
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_server_url)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_server_url: (isset($CFG->bigbluebuttonbn_server_url)? $CFG->bigbluebuttonbn_server_url: (isset($CFG->BigBlueButtonBNServerURL)? $CFG->BigBlueButtonBNServerURL: 'http://test-install.blindsidenetworks.com/bigbluebutton/'))); |
|
1281
|
|
|
} |
|
1282
|
|
|
|
|
1283
|
|
|
function bigbluebuttonbn_get_cfg_shared_secret_default() { |
|
1284
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1285
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_shared_secret)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_shared_secret: (isset($CFG->bigbluebuttonbn_shared_secret)? $CFG->bigbluebuttonbn_shared_secret: (isset($CFG->BigBlueButtonBNSecuritySalt)? $CFG->BigBlueButtonBNSecuritySalt: '8cd8ef52e8e101574e400365b55e11a6'))); |
|
1286
|
|
|
} |
|
1287
|
|
|
|
|
1288
|
|
|
function bigbluebuttonbn_get_cfg_voicebridge_editable() { |
|
1289
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1290
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_voicebridge_editable)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_voicebridge_editable: (isset($CFG->bigbluebuttonbn_voicebridge_editable)? $CFG->bigbluebuttonbn_voicebridge_editable: false)); |
|
1291
|
|
|
} |
|
1292
|
|
|
|
|
1293
|
|
|
function bigbluebuttonbn_get_cfg_recording_default() { |
|
1294
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1295
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_default)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_default: (isset($CFG->bigbluebuttonbn_recording_default)? $CFG->bigbluebuttonbn_recording_default: true)); |
|
1296
|
|
|
} |
|
1297
|
|
|
|
|
1298
|
|
|
function bigbluebuttonbn_get_cfg_recording_editable() { |
|
1299
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1300
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_editable)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_editable: (isset($CFG->bigbluebuttonbn_recording_editable)? $CFG->bigbluebuttonbn_recording_editable: true)); |
|
1301
|
|
|
} |
|
1302
|
|
|
|
|
1303
|
|
|
function bigbluebuttonbn_get_cfg_recording_tagging_default() { |
|
1304
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1305
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_default)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_default: (isset($CFG->bigbluebuttonbn_recordingtagging_default)? $CFG->bigbluebuttonbn_recordingtagging_default: false)); |
|
1306
|
|
|
} |
|
1307
|
|
|
|
|
1308
|
|
|
function bigbluebuttonbn_get_cfg_recording_tagging_editable() { |
|
1309
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1310
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_editable)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_editable: (isset($CFG->bigbluebuttonbn_recordingtagging_editable)? $CFG->bigbluebuttonbn_recordingtagging_editable: false)); |
|
1311
|
|
|
} |
|
1312
|
|
|
|
|
1313
|
|
|
function bigbluebuttonbn_get_cfg_recording_icons_enabled() { |
|
1314
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1315
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_icons_enabled)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_icons_enabled: (isset($CFG->bigbluebuttonbn_recording_icons_enabled)? $CFG->bigbluebuttonbn_recording_icons_enabled: true)); |
|
1316
|
|
|
} |
|
1317
|
|
|
|
|
1318
|
|
|
function bigbluebuttonbn_get_cfg_importrecordings_enabled() { |
|
1319
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1320
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_importrecordings_enabled)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_importrecordings_enabled: (isset($CFG->bigbluebuttonbn_importrecordings_enabled)? $CFG->bigbluebuttonbn_importrecordings_enabled: false)); |
|
1321
|
|
|
} |
|
1322
|
|
|
|
|
1323
|
|
|
function bigbluebuttonbn_get_cfg_waitformoderator_default() { |
|
1324
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1325
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_default)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_default: (isset($CFG->bigbluebuttonbn_waitformoderator_default)? $CFG->bigbluebuttonbn_waitformoderator_default: false)); |
|
1326
|
|
|
} |
|
1327
|
|
|
|
|
1328
|
|
|
function bigbluebuttonbn_get_cfg_waitformoderator_editable() { |
|
1329
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1330
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_editable)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_editable: (isset($CFG->bigbluebuttonbn_waitformoderator_editable)? $CFG->bigbluebuttonbn_waitformoderator_editable: true)); |
|
1331
|
|
|
} |
|
1332
|
|
|
|
|
1333
|
|
|
function bigbluebuttonbn_get_cfg_waitformoderator_ping_interval() { |
|
1334
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1335
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_ping_interval)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_ping_interval: (isset($CFG->bigbluebuttonbn_waitformoderator_ping_interval)? $CFG->bigbluebuttonbn_waitformoderator_ping_interval: 15)); |
|
1336
|
|
|
} |
|
1337
|
|
|
|
|
1338
|
|
|
function bigbluebuttonbn_get_cfg_waitformoderator_cache_ttl() { |
|
1339
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1340
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_cache_ttl)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_cache_ttl: (isset($CFG->bigbluebuttonbn_waitformoderator_cache_ttl)? $CFG->bigbluebuttonbn_waitformoderator_cache_ttl: 60)); |
|
1341
|
|
|
} |
|
1342
|
|
|
|
|
1343
|
|
|
function bigbluebuttonbn_get_cfg_userlimit_default() { |
|
1344
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1345
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_default)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_default: (isset($CFG->bigbluebuttonbn_userlimit_default)? $CFG->bigbluebuttonbn_userlimit_default: 0)); |
|
1346
|
|
|
} |
|
1347
|
|
|
|
|
1348
|
|
|
function bigbluebuttonbn_get_cfg_userlimit_editable() { |
|
1349
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1350
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_editable)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_editable: (isset($CFG->bigbluebuttonbn_userlimit_editable)? $CFG->bigbluebuttonbn_userlimit_editable: false)); |
|
1351
|
|
|
} |
|
1352
|
|
|
|
|
1353
|
|
|
function bigbluebuttonbn_get_cfg_preuploadpresentation_enabled() { |
|
1354
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1355
|
|
|
if (extension_loaded('curl')) { |
|
1356
|
|
|
// This feature only works if curl is installed |
|
1357
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_preuploadpresentation_enabled)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_preuploadpresentation_enabled: (isset($CFG->bigbluebuttonbn_preuploadpresentation_enabled)? $CFG->bigbluebuttonbn_preuploadpresentation_enabled: false)); |
|
1358
|
|
|
} else { |
|
1359
|
|
|
return false; |
|
1360
|
|
|
} |
|
1361
|
|
|
} |
|
1362
|
|
|
|
|
1363
|
|
|
function bigbluebuttonbn_get_cfg_sendnotifications_enabled() { |
|
1364
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1365
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_sendnotifications_enabled)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_sendnotifications_enabled: (isset($CFG->bigbluebuttonbn_sendnotifications_enabled)? $CFG->bigbluebuttonbn_sendnotifications_enabled: false)); |
|
1366
|
|
|
} |
|
1367
|
|
|
|
|
1368
|
|
|
function bigbluebuttonbn_get_cfg_recordingready_enabled() { |
|
1369
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1370
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingready_enabled)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingready_enabled: (isset($CFG->bigbluebuttonbn_recordingready_enabled)? $CFG->bigbluebuttonbn_recordingready_enabled: false)); |
|
1371
|
|
|
} |
|
1372
|
|
|
|
|
1373
|
|
|
function bigbluebuttonbn_get_cfg_moderator_default() { |
|
1374
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1375
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_moderator_default)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_moderator_default: (isset($CFG->bigbluebuttonbn_moderator_default)? $CFG->bigbluebuttonbn_moderator_default: 'owner')); |
|
1376
|
|
|
} |
|
1377
|
|
|
|
|
1378
|
|
|
function bigbluebuttonbn_get_cfg_scheduled_duration_enabled() { |
|
1379
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1380
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_scheduled_duration_enabled)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_scheduled_duration_enabled: (isset($CFG->bigbluebuttonbn_scheduled_duration_enabled)? $CFG->bigbluebuttonbn_scheduled_duration_enabled: false)); |
|
1381
|
|
|
} |
|
1382
|
|
|
|
|
1383
|
|
|
function bigbluebuttonbn_get_cfg_scheduled_duration_compensation() { |
|
1384
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1385
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_scheduled_duration_compensation)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_scheduled_duration_compensation: (isset($CFG->bigbluebuttonbn_scheduled_duration_compensation)? $CFG->bigbluebuttonbn_scheduled_duration_compensation: 10)); |
|
1386
|
|
|
} |
|
1387
|
|
|
|
|
1388
|
|
|
function bigbluebuttonbn_get_cfg_scheduled_pre_opening() { |
|
1389
|
|
|
global $BIGBLUEBUTTONBN_CFG, $CFG; |
|
1390
|
|
|
return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_scheduled_pre_opening)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_scheduled_pre_opening: (isset($CFG->bigbluebuttonbn_scheduled_pre_opening)? $CFG->bigbluebuttonbn_scheduled_pre_opening: 10)); |
|
1391
|
|
|
} |
|
1392
|
|
|
|
|
1393
|
|
|
function bigbluebuttonbn_import_get_courses_for_select(array $bbbsession) { |
|
1394
|
|
|
|
|
1395
|
|
|
if( $bbbsession['administrator'] ) { |
|
1396
|
|
|
$courses = get_courses('all', 'c.id ASC', 'c.id,c.shortname,c.fullname'); |
|
1397
|
|
|
//It includes the name of the site as a course (category 0), so remove the first one |
|
1398
|
|
|
unset($courses["1"]); |
|
1399
|
|
|
} else { |
|
1400
|
|
|
$courses = enrol_get_users_courses($bbbsession['userID'], false, 'id,shortname,fullname'); |
|
1401
|
|
|
} |
|
1402
|
|
|
|
|
1403
|
|
|
$courses_for_select = []; |
|
1404
|
|
|
foreach($courses as $course) { |
|
1405
|
|
|
if( $course->id != $bbbsession['course']->id ) { |
|
1406
|
|
|
$courses_for_select[$course->id] = $course->fullname; |
|
1407
|
|
|
} |
|
1408
|
|
|
} |
|
1409
|
|
|
return $courses_for_select; |
|
1410
|
|
|
} |
|
1411
|
|
|
|
|
1412
|
|
|
function bigbluebuttonbn_getRecordedMeetings_old($courseID) { |
|
1413
|
|
|
global $DB; |
|
1414
|
|
|
|
|
1415
|
|
|
$records = $DB->get_records('bigbluebuttonbn_logs', array('courseid' => $courseID, 'log' => BIGBLUEBUTTONBN_LOG_EVENT_CREATE)); |
|
1416
|
|
|
|
|
1417
|
|
|
//Remove duplicates |
|
1418
|
|
|
$unique_records = array(); |
|
1419
|
|
|
foreach ($records as $key => $record) { |
|
1420
|
|
View Code Duplication |
if (array_key_exists($record->meetingid, $unique_records) ) { |
|
|
|
|
|
|
1421
|
|
|
unset($records[$key]); |
|
1422
|
|
|
} else { |
|
1423
|
|
|
$meta = json_decode($record->meta); |
|
1424
|
|
|
if ( !$meta->record ) { |
|
1425
|
|
|
unset($records[$key]); |
|
1426
|
|
|
} else { |
|
1427
|
|
|
array_push($unique_records, $record->meetingid); |
|
1428
|
|
|
} |
|
1429
|
|
|
} |
|
1430
|
|
|
} |
|
1431
|
|
|
|
|
1432
|
|
|
return $records; |
|
1433
|
|
|
} |
|
1434
|
|
|
|
|
1435
|
|
|
function bigbluebuttonbn_getRecordedMeetingsDeleted($courseID) { |
|
1436
|
|
|
global $DB; |
|
1437
|
|
|
|
|
1438
|
|
|
$records_deleted = array(); |
|
1439
|
|
|
|
|
1440
|
|
|
$bigbluebuttonbns_deleted = $DB->get_records('bigbluebuttonbn_logs', array('courseid' => $courseID, 'log' => BIGBLUEBUTTONBN_LOG_EVENT_DELETE)); |
|
1441
|
|
|
|
|
1442
|
|
|
foreach ($bigbluebuttonbns_deleted as $key => $bigbluebuttonbn_deleted) { |
|
1443
|
|
|
$records = $DB->get_records('bigbluebuttonbn_logs', array('courseid' => $courseID, 'log' => BIGBLUEBUTTONBN_LOG_EVENT_CREATE)); |
|
1444
|
|
|
|
|
1445
|
|
|
if( !empty($records) ) { |
|
1446
|
|
|
//Remove duplicates |
|
1447
|
|
|
$unique_records = array(); |
|
1448
|
|
|
foreach ($records as $key => $record) { |
|
1449
|
|
|
if (array_key_exists($record->meetingid, $unique_records) ) { |
|
1450
|
|
|
unset($records[$key]); |
|
1451
|
|
|
} else { |
|
1452
|
|
|
$meta = json_decode($record->meta); |
|
1453
|
|
View Code Duplication |
if ( !$meta->record ) { |
|
|
|
|
|
|
1454
|
|
|
unset($records[$key]); |
|
1455
|
|
|
} else if ( $bigbluebuttonbn_deleted->meetingid != substr($record->meetingid, 0, strlen($bigbluebuttonbn_deleted->meetingid))) { |
|
1456
|
|
|
unset($records[$key]); |
|
1457
|
|
|
} else { |
|
1458
|
|
|
array_push($unique_records, $record->meetingid); |
|
1459
|
|
|
} |
|
1460
|
|
|
} |
|
1461
|
|
|
} |
|
1462
|
|
|
|
|
1463
|
|
|
$records_deleted = array_merge($records_deleted, $records); |
|
1464
|
|
|
} |
|
1465
|
|
|
} |
|
1466
|
|
|
|
|
1467
|
|
|
return $records_deleted; |
|
1468
|
|
|
} |
|
1469
|
|
|
|
|
1470
|
|
|
function bigbluebuttonbn_getRecordedMeetings($courseID) { |
|
1471
|
|
|
global $DB; |
|
1472
|
|
|
|
|
1473
|
|
|
$records = Array(); |
|
1474
|
|
|
|
|
1475
|
|
|
$bigbluebuttonbns = $DB->get_records('bigbluebuttonbn', array('course' => $courseID)); |
|
1476
|
|
|
|
|
1477
|
|
|
if ( !empty($bigbluebuttonbns) ) { |
|
1478
|
|
|
$table = 'bigbluebuttonbn_logs'; |
|
1479
|
|
|
|
|
1480
|
|
|
//Prepare select for loading records based on existent bigbluebuttonbns |
|
1481
|
|
|
$select = ""; |
|
1482
|
|
|
foreach ($bigbluebuttonbns as $key => $bigbluebuttonbn) { |
|
1483
|
|
|
$select .= strlen($select) == 0? "(": " OR "; |
|
1484
|
|
|
$select .= "bigbluebuttonbnid=".$bigbluebuttonbn->id; |
|
1485
|
|
|
} |
|
1486
|
|
|
$select .= ") AND log='".BIGBLUEBUTTONBN_LOG_EVENT_CREATE."'"; |
|
1487
|
|
|
|
|
1488
|
|
|
//Execute select for loading records based on existent bigbluebuttonbns |
|
1489
|
|
|
$records = $DB->get_records_select($table, $select); |
|
1490
|
|
|
|
|
1491
|
|
|
//Remove duplicates |
|
1492
|
|
|
$unique_records = array(); |
|
1493
|
|
|
foreach ($records as $key => $record) { |
|
1494
|
|
|
$record_key = $record->meetingid.','.$record->bigbluebuttonbnid.','.$record->meta; |
|
1495
|
|
|
if( array_search($record_key, $unique_records) === false ) { |
|
1496
|
|
|
array_push($unique_records, $record_key); |
|
1497
|
|
|
} else { |
|
1498
|
|
|
unset($records[$key]); |
|
1499
|
|
|
} |
|
1500
|
|
|
} |
|
1501
|
|
|
|
|
1502
|
|
|
//Remove the ones with record=false |
|
1503
|
|
|
foreach ($records as $key => $record) { |
|
1504
|
|
|
$meta = json_decode($record->meta); |
|
1505
|
|
|
if ( !$meta || !$meta->record ) { |
|
1506
|
|
|
unset($records[$key]); |
|
1507
|
|
|
} |
|
1508
|
|
|
} |
|
1509
|
|
|
} |
|
1510
|
|
|
|
|
1511
|
|
|
return $records; |
|
1512
|
|
|
} |
|
1513
|
|
|
|
|
1514
|
|
|
function bigbluebuttonbn_getRecordingsArrayByCourse($courseID, $URL, $SALT) { |
|
1515
|
|
|
$recordings = array(); |
|
1516
|
|
|
|
|
1517
|
|
|
// Load the meetingIDs to be used in the getRecordings request |
|
1518
|
|
|
$meetingID = ''; |
|
1519
|
|
|
if ( is_numeric($courseID) ) { |
|
1520
|
|
|
$results = bigbluebuttonbn_getRecordedMeetings($courseID); |
|
1521
|
|
|
if( $results ) { |
|
1522
|
|
|
//Eliminates duplicates |
|
1523
|
|
|
$mIDs = array(); |
|
1524
|
|
|
foreach ($results as $result) { |
|
1525
|
|
|
$mIDs[$result->meetingid] = $result->meetingid; |
|
1526
|
|
|
} |
|
1527
|
|
|
//Generates the meetingID string |
|
1528
|
|
|
foreach ($mIDs as $mID) { |
|
1529
|
|
|
if (strlen($meetingID) > 0) $meetingID .= ','; |
|
1530
|
|
|
$meetingID .= $mID; |
|
1531
|
|
|
} |
|
1532
|
|
|
} |
|
1533
|
|
|
} |
|
1534
|
|
|
|
|
1535
|
|
|
// If there were meetingIDs excecute the getRecordings request |
|
1536
|
|
|
if ( $meetingID != '' ) { |
|
1537
|
|
|
$recordings = bigbluebuttonbn_getRecordingsArray($meetingID, $URL, $SALT); |
|
1538
|
|
|
} |
|
1539
|
|
|
|
|
1540
|
|
|
return $recordings; |
|
1541
|
|
|
} |
|
1542
|
|
|
|
|
1543
|
|
|
function bigbluebuttonbn_import_get_recordings_imported($records) { |
|
1544
|
|
|
$recordings_imported = array(); |
|
1545
|
|
|
|
|
1546
|
|
|
foreach ($records as $key => $record) { |
|
1547
|
|
|
$meta = json_decode($record->meta, true); |
|
1548
|
|
|
$recordings_imported[] = $meta['recording']; |
|
1549
|
|
|
} |
|
1550
|
|
|
|
|
1551
|
|
|
return $recordings_imported; |
|
1552
|
|
|
} |
|
1553
|
|
|
|
|
1554
|
|
|
function bigbluebuttonbn_import_exlcude_recordings_already_imported($courseID, $bigbluebuttonbnID, $recordings) { |
|
1555
|
|
|
$recordings_already_imported = bigbluebuttonbn_getRecordingsImportedArray($courseID, $bigbluebuttonbnID); |
|
1556
|
|
|
$recordings_already_imported_indexed = bigbluebuttonbn_index_recordings($recordings_already_imported); |
|
1557
|
|
|
|
|
1558
|
|
|
foreach ($recordings as $key => $recording) { |
|
1559
|
|
|
if( isset($recordings_already_imported_indexed[$recording['recordID']]) ) { |
|
1560
|
|
|
unset($recordings[$key]); |
|
1561
|
|
|
} |
|
1562
|
|
|
} |
|
1563
|
|
|
return $recordings; |
|
1564
|
|
|
} |
|
1565
|
|
|
|
|
1566
|
|
|
function bigbluebutton_output_recording_table($bbbsession, $recordings, $tools=['publishing','deleting']) { |
|
1567
|
|
|
|
|
1568
|
|
|
if ( isset($recordings) && !empty($recordings) ) { // There are recordings for this meeting |
|
1569
|
|
|
$table = bigbluebuttonbn_get_recording_table($bbbsession, $recordings, $tools); |
|
1570
|
|
|
} |
|
1571
|
|
|
|
|
1572
|
|
|
$output = ''; |
|
1573
|
|
|
if( isset($table->data) ) { |
|
1574
|
|
|
//Print the table |
|
1575
|
|
|
$output .= '<div id="bigbluebuttonbn_html_table">'."\n"; |
|
1576
|
|
|
$output .= html_writer::table($table)."\n"; |
|
|
|
|
|
|
1577
|
|
|
$output .= '</div>'."\n"; |
|
1578
|
|
|
|
|
1579
|
|
|
} else { |
|
1580
|
|
|
$output .= get_string('view_message_norecordings', 'bigbluebuttonbn').'<br>'."\n"; |
|
1581
|
|
|
} |
|
1582
|
|
|
|
|
1583
|
|
|
return $output; |
|
1584
|
|
|
} |
|
1585
|
|
|
|
|
1586
|
|
|
function bigbluebuttonbn_getRecordingsImported($courseID, $bigbluebuttonbnID) { |
|
1587
|
|
|
global $DB; |
|
1588
|
|
|
|
|
1589
|
|
|
if ( $bigbluebuttonbnID != NULL ) { |
|
1590
|
|
|
// Fetch only those related to the $courseID and $bigbluebuttonbnID requested |
|
1591
|
|
|
$recordings_imported = $DB->get_records('bigbluebuttonbn_logs', array('courseid' => $courseID, 'bigbluebuttonbnid' => $bigbluebuttonbnID, 'log' => BIGBLUEBUTTONBN_LOG_EVENT_IMPORT)); |
|
1592
|
|
|
} else { |
|
1593
|
|
|
// Fetch all the ones corresponding to the $courseID requested |
|
1594
|
|
|
$recordings_imported = $DB->get_records('bigbluebuttonbn_logs', array('courseid' => $courseID, 'log' => BIGBLUEBUTTONBN_LOG_EVENT_IMPORT)); |
|
1595
|
|
|
} |
|
1596
|
|
|
return $recordings_imported; |
|
1597
|
|
|
} |
|
1598
|
|
|
|
|
1599
|
|
|
function bigbluebuttonbn_getRecordingsImportedArray($courseID, $bigbluebuttonbnID) { |
|
1600
|
|
|
$recordings_imported = bigbluebuttonbn_getRecordingsImported($courseID, $bigbluebuttonbnID); |
|
1601
|
|
|
$recordings_imported_array = bigbluebuttonbn_import_get_recordings_imported($recordings_imported); |
|
1602
|
|
|
return $recordings_imported_array; |
|
1603
|
|
|
} |
|
1604
|
|
|
|
|
1605
|
|
|
function bigbluebuttonbn_getRecordingsImportedAllInstances($recordID) { |
|
1606
|
|
|
global $DB, $CFG; |
|
1607
|
|
|
|
|
1608
|
|
|
$recordings_imported = $DB->get_records_sql('SELECT * FROM '.$CFG->prefix.'bigbluebuttonbn_logs WHERE log=? AND '.$DB->sql_like('meta', '?'), array( BIGBLUEBUTTONBN_LOG_EVENT_IMPORT, '%'.$recordID.'%' )); |
|
1609
|
|
|
return $recordings_imported; |
|
1610
|
|
|
} |
|
1611
|
|
|
|
|
1612
|
|
|
function bigbluebuttonbn_getRecordingsImportedAllInstancesArray($recordID) { |
|
1613
|
|
|
$recordings_imported = bigbluebuttonbn_getRecordingsImportedAllInstances($recordID); |
|
1614
|
|
|
$recordings_imported_array = bigbluebuttonbn_import_get_recordings_imported($recordings_imported); |
|
1615
|
|
|
return $recordings_imported_array; |
|
1616
|
|
|
} |
|
1617
|
|
|
|
|
1618
|
|
|
function bigbluebuttonbn_debugdisplay() { |
|
1619
|
|
|
global $CFG; |
|
1620
|
|
|
|
|
1621
|
|
|
return (bool)$CFG->debugdisplay; |
|
1622
|
|
|
} |
|
1623
|
|
|
|
|
1624
|
|
|
function bigbluebuttonbn_html2text($html, $len) { |
|
1625
|
|
|
$text = strip_tags($html); |
|
1626
|
|
|
$text = str_replace(" ", ' ', $text); |
|
1627
|
|
|
if( strlen($text) > $len ) |
|
1628
|
|
|
$text = substr($text, 0, $len)."..."; |
|
1629
|
|
|
else |
|
1630
|
|
|
$text = substr($text, 0, $len); |
|
1631
|
|
|
return $text; |
|
1632
|
|
|
} |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.