1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* For licensing terms, see /license.txt */ |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class bbb |
7
|
|
|
* This script initiates a video conference session, calling the BigBlueButton |
8
|
|
|
* API BigBlueButton-Chamilo connector class |
9
|
|
|
*/ |
10
|
|
|
class bbb |
11
|
|
|
{ |
12
|
|
|
public $url; |
13
|
|
|
public $salt; |
14
|
|
|
public $api; |
15
|
|
|
public $userCompleteName = ''; |
16
|
|
|
public $protocol = 'http://'; |
17
|
|
|
public $debug = false; |
18
|
|
|
public $logoutUrl = ''; |
19
|
|
|
public $pluginEnabled = false; |
20
|
|
|
public $enableGlobalConference = false; |
21
|
|
|
public $enableGlobalConferencePerUser = false; |
22
|
|
|
public $isGlobalConference = false; |
23
|
|
|
public $groupSupport = false; |
24
|
|
|
public $userSupport = false; |
25
|
|
|
public $accessUrl = 1; |
26
|
|
|
public $userId = 0; |
27
|
|
|
public $plugin; |
28
|
|
|
private $courseCode; |
29
|
|
|
private $courseId; |
30
|
|
|
private $sessionId; |
31
|
|
|
private $groupId; |
32
|
|
|
private $maxUsersLimit; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Constructor (generates a connection to the API and the Chamilo settings |
36
|
|
|
* required for the connection to the video conference server) |
37
|
|
|
* |
38
|
|
|
* @param string $host |
39
|
|
|
* @param string $salt |
40
|
|
|
* @param bool $isGlobalConference |
41
|
|
|
* @param int $isGlobalPerUser |
42
|
|
|
*/ |
43
|
|
|
public function __construct( |
44
|
|
|
$host = '', |
45
|
|
|
$salt = '', |
46
|
|
|
$isGlobalConference = false, |
47
|
|
|
$isGlobalPerUser = 0 |
48
|
|
|
) { |
49
|
|
|
$this->courseCode = api_get_course_id(); |
50
|
|
|
$this->courseId = api_get_course_int_id(); |
51
|
|
|
$this->sessionId = api_get_session_id(); |
52
|
|
|
$this->groupId = api_get_group_id(); |
53
|
|
|
|
54
|
|
|
// Initialize video server settings from global settings |
55
|
|
|
$this->plugin = BBBPlugin::create(); |
56
|
|
|
$bbbPluginEnabled = $this->plugin->get('tool_enable'); |
|
|
|
|
57
|
|
|
|
58
|
|
|
$bbb_host = !empty($host) ? $host : $this->plugin->get('host'); |
59
|
|
|
$bbb_salt = !empty($salt) ? $salt : $this->plugin->get('salt'); |
60
|
|
|
|
61
|
|
|
$this->table = Database::get_main_table('plugin_bbb_meeting'); |
62
|
|
|
$this->enableGlobalConference = $this->plugin->get('enable_global_conference') === 'true'; |
63
|
|
|
$this->isGlobalConference = (bool) $isGlobalConference; |
64
|
|
|
|
65
|
|
|
$columns = Database::listTableColumns($this->table); |
66
|
|
|
$this->groupSupport = isset($columns['group_id']) ? true : false; |
67
|
|
|
$this->userSupport = isset($columns['user_id']) ? true : false; |
68
|
|
|
$this->accessUrl = api_get_current_access_url_id(); |
69
|
|
|
|
70
|
|
|
$this->enableGlobalConferencePerUser = false; |
71
|
|
|
if ($this->userSupport && !empty($isGlobalPerUser)) { |
72
|
|
|
$this->enableGlobalConferencePerUser = $this->plugin->get('enable_global_conference_per_user') === 'true'; |
73
|
|
|
$this->userId = $isGlobalPerUser; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
if ($this->groupSupport) { |
77
|
|
|
// Plugin check |
78
|
|
|
$this->groupSupport = $this->plugin->get('enable_conference_in_course_groups') === 'true' ? true : false; |
79
|
|
|
if ($this->groupSupport) { |
80
|
|
|
// Platform check |
81
|
|
|
$bbbSetting = api_get_setting('bbb_enable_conference_in_course_groups'); |
82
|
|
|
$bbbSetting = isset($bbbSetting['bbb']) ? $bbbSetting['bbb'] === 'true' : false; |
83
|
|
|
|
84
|
|
|
if ($bbbSetting) { |
85
|
|
|
// Course check |
86
|
|
|
$courseInfo = api_get_course_info(); |
87
|
|
|
if ($courseInfo) { |
88
|
|
|
$this->groupSupport = api_get_course_plugin_setting( |
89
|
|
|
'bbb', |
90
|
|
|
'bbb_enable_conference_in_groups', |
91
|
|
|
$courseInfo |
92
|
|
|
) === '1'; |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
$this->maxUsersLimit = $this->plugin->get('max_users_limit'); |
98
|
|
|
|
99
|
|
|
if ($bbbPluginEnabled === 'true') { |
100
|
|
|
$userInfo = api_get_user_info(); |
101
|
|
|
if (empty($userInfo) && !empty($isGlobalPerUser)) { |
102
|
|
|
// If we are following a link to a global "per user" conference |
103
|
|
|
// then generate a random guest name to join the conference |
104
|
|
|
// because there is no part of the process where we give a name |
105
|
|
|
//$this->userCompleteName = 'Guest'.rand(1000, 9999); |
106
|
|
|
} else { |
107
|
|
|
$this->userCompleteName = $userInfo['complete_name']; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
if (api_is_anonymous()) { |
111
|
|
|
$this->userCompleteName = get_lang('Guest').'_'.rand(1000, 9999); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
$this->salt = $bbb_salt; |
115
|
|
|
if (!empty($bbb_host)) { |
116
|
|
|
if (substr($bbb_host, -1, 1) !== '/') { |
117
|
|
|
$bbb_host .= '/'; |
118
|
|
|
} |
119
|
|
|
$this->url = $bbb_host; |
120
|
|
|
if (!preg_match('#/bigbluebutton/$#', $bbb_host)) { |
121
|
|
|
$this->url = $bbb_host.'bigbluebutton/'; |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
$info = parse_url($bbb_host); |
125
|
|
|
|
126
|
|
|
if (isset($info['scheme'])) { |
127
|
|
|
$this->protocol = $info['scheme'].'://'; |
128
|
|
|
$this->url = str_replace($this->protocol, '', $this->url); |
129
|
|
|
$urlWithProtocol = $bbb_host; |
130
|
|
|
} else { |
131
|
|
|
// We assume it's an http, if user wants to use https, the host *must* include the protocol. |
132
|
|
|
$this->protocol = 'http://'; |
133
|
|
|
$urlWithProtocol = $this->protocol.$bbb_host; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
// Setting BBB api |
137
|
|
|
define('CONFIG_SECURITY_SALT', $this->salt); |
138
|
|
|
define('CONFIG_SERVER_URL_WITH_PROTOCOL', $urlWithProtocol); |
139
|
|
|
define('CONFIG_SERVER_BASE_URL', $this->url); |
140
|
|
|
define('CONFIG_SERVER_PROTOCOL', $this->protocol); |
141
|
|
|
|
142
|
|
|
$this->api = new BigBlueButtonBN(); |
143
|
|
|
$this->pluginEnabled = true; |
144
|
|
|
$this->logoutUrl = $this->getListingUrl(); |
145
|
|
|
} |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @param int $courseId Optional. Course ID. |
150
|
|
|
* @param int $sessionId Optional. Session ID. |
151
|
|
|
* @param int $groupId Optional. Group ID. |
152
|
|
|
* |
153
|
|
|
* @return string |
154
|
|
|
*/ |
155
|
|
|
public function getListingUrl($courseId = 0, $sessionId = 0, $groupId = 0) |
156
|
|
|
{ |
157
|
|
|
return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?' |
158
|
|
|
.$this->getUrlParams($courseId, $sessionId, $groupId); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @param int $courseId Optional. Course ID. |
163
|
|
|
* @param int $sessionId Optional. Session ID. |
164
|
|
|
* @param int $groupId Optional. Group ID. |
165
|
|
|
* |
166
|
|
|
* @return string |
167
|
|
|
*/ |
168
|
|
|
public function getUrlParams($courseId = 0, $sessionId = 0, $groupId = 0) |
169
|
|
|
{ |
170
|
|
|
if (empty($this->courseCode) && !$courseId) { |
171
|
|
|
if ($this->isGlobalConferencePerUserEnabled()) { |
172
|
|
|
return 'global=1&user_id='.$this->userId; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
if ($this->isGlobalConference()) { |
176
|
|
|
return 'global=1'; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
return ''; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
$courseCode = $this->courseCode; |
183
|
|
|
if (!empty($courseId)) { |
184
|
|
|
$course = api_get_course_info_by_id($courseId); |
185
|
|
|
if ($course) { |
186
|
|
|
$courseCode = $course['code']; |
187
|
|
|
} |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
return http_build_query( |
191
|
|
|
[ |
192
|
|
|
'cidReq' => $courseCode, |
193
|
|
|
'id_session' => $sessionId ?: $this->sessionId, |
194
|
|
|
'gidReq' => $groupId ?: $this->groupId, |
195
|
|
|
] |
196
|
|
|
); |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @return bool |
201
|
|
|
*/ |
202
|
|
|
public function isGlobalConferencePerUserEnabled() |
203
|
|
|
{ |
204
|
|
|
return $this->enableGlobalConferencePerUser; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* @return bool |
209
|
|
|
*/ |
210
|
|
|
public function isGlobalConference() |
211
|
|
|
{ |
212
|
|
|
if ($this->isGlobalConferenceEnabled() === false) { |
213
|
|
|
return false; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
return (bool) $this->isGlobalConference; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* @return bool |
221
|
|
|
*/ |
222
|
|
|
public function isGlobalConferenceEnabled() |
223
|
|
|
{ |
224
|
|
|
return $this->enableGlobalConference; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* @param array $userInfo |
229
|
|
|
* |
230
|
|
|
* @return bool |
231
|
|
|
*/ |
232
|
|
|
public static function showGlobalConferenceLink($userInfo) |
233
|
|
|
{ |
234
|
|
|
if (empty($userInfo)) { |
235
|
|
|
return false; |
236
|
|
|
} |
237
|
|
|
$setting = api_get_plugin_setting('bbb', 'enable_global_conference'); |
238
|
|
|
$settingLink = api_get_plugin_setting('bbb', 'enable_global_conference_link'); |
239
|
|
|
if ($setting === 'true' && $settingLink === 'true') { |
240
|
|
|
//$content = Display::url(get_lang('LaunchVideoConferenceRoom'), $url); |
241
|
|
|
$allowedRoles = api_get_plugin_setting( |
242
|
|
|
'bbb', |
243
|
|
|
'global_conference_allow_roles' |
244
|
|
|
); |
245
|
|
|
|
246
|
|
|
if (api_is_platform_admin()) { |
247
|
|
|
$userInfo['status'] = PLATFORM_ADMIN; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
$showGlobalLink = true; |
251
|
|
|
if (!empty($allowedRoles)) { |
252
|
|
|
if (!in_array($userInfo['status'], $allowedRoles)) { |
253
|
|
|
$showGlobalLink = false; |
254
|
|
|
} |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
return $showGlobalLink; |
258
|
|
|
} |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* Gets the global limit of users in a video-conference room. |
263
|
|
|
* This value can be overridden by course-specific values |
264
|
|
|
* @return int Maximum number of users set globally |
265
|
|
|
*/ |
266
|
|
|
public function getMaxUsersLimit() |
267
|
|
|
{ |
268
|
|
|
$limit = $this->maxUsersLimit; |
269
|
|
|
if ($limit <= 0) { |
270
|
|
|
$limit = 0; |
271
|
|
|
} |
272
|
|
|
$courseLimit = 0; |
273
|
|
|
$sessionLimit = 0; |
274
|
|
|
// Check the extra fields for this course and session |
275
|
|
|
// Session limit takes priority over course limit |
276
|
|
|
// Course limit takes priority over global limit |
277
|
|
|
if (!empty($this->courseId)) { |
278
|
|
|
$extraField = new ExtraField('course'); |
279
|
|
|
$fieldId = $extraField->get_all( |
280
|
|
|
array('variable = ?' => 'plugin_bbb_course_users_limit') |
281
|
|
|
); |
282
|
|
|
$extraValue = new ExtraFieldValue('course'); |
283
|
|
|
$value = $extraValue->get_values_by_handler_and_field_id($this->courseId, $fieldId[0]['id']); |
284
|
|
|
if (!empty($value['value'])) { |
285
|
|
|
$courseLimit = (int) $value['value']; |
286
|
|
|
} |
287
|
|
|
} |
288
|
|
|
if (!empty($this->sessionId)) { |
289
|
|
|
$extraField = new ExtraField('session'); |
290
|
|
|
$fieldId = $extraField->get_all( |
291
|
|
|
array('variable = ?' => 'plugin_bbb_session_users_limit') |
292
|
|
|
); |
293
|
|
|
$extraValue = new ExtraFieldValue('session'); |
294
|
|
|
$value = $extraValue->get_values_by_handler_and_field_id($this->sessionId, $fieldId[0]['id']); |
295
|
|
|
if (!empty($value['value'])) { |
296
|
|
|
$sessionLimit = (int) $value['value']; |
297
|
|
|
} |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
if (!empty($sessionLimit)) { |
301
|
|
|
return $sessionLimit; |
302
|
|
|
} elseif (!empty($courseLimit)) { |
303
|
|
|
return $courseLimit; |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
return (int) $limit; |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
/** |
310
|
|
|
* Sets the global limit of users in a video-conference room. |
311
|
|
|
* |
312
|
|
|
* @param int Maximum number of users (globally) |
313
|
|
|
*/ |
314
|
|
|
public function setMaxUsersLimit($max) |
315
|
|
|
{ |
316
|
|
|
if ($max < 0) { |
317
|
|
|
$max = 0; |
318
|
|
|
} |
319
|
|
|
$this->maxUsersLimit = (int) $max; |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
/** |
323
|
|
|
* See this file in you BBB to set up default values |
324
|
|
|
* |
325
|
|
|
* @param array $params Array of parameters that will be completed if not containing all expected variables |
326
|
|
|
* |
327
|
|
|
* /var/lib/tomcat6/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties |
328
|
|
|
* |
329
|
|
|
* More record information: |
330
|
|
|
* http://code.google.com/p/bigbluebutton/wiki/RecordPlaybackSpecification |
331
|
|
|
* |
332
|
|
|
* Default maximum number of users a meeting can have. |
333
|
|
|
* Doesn't get enforced yet but is the default value when the create |
334
|
|
|
* API doesn't pass a value. |
335
|
|
|
* defaultMaxUsers=20 |
336
|
|
|
* |
337
|
|
|
* Default duration of the meeting in minutes. |
338
|
|
|
* Current default is 0 (meeting doesn't end). |
339
|
|
|
* defaultMeetingDuration=0 |
340
|
|
|
* |
341
|
|
|
* Remove the meeting from memory when the end API is called. |
342
|
|
|
* This allows 3rd-party apps to recycle the meeting right-away |
343
|
|
|
* instead of waiting for the meeting to expire (see below). |
344
|
|
|
* removeMeetingWhenEnded=false |
345
|
|
|
* |
346
|
|
|
* The number of minutes before the system removes the meeting from memory. |
347
|
|
|
* defaultMeetingExpireDuration=1 |
348
|
|
|
* |
349
|
|
|
* The number of minutes the system waits when a meeting is created and when |
350
|
|
|
* a user joins. If after this period, a user hasn't joined, the meeting is |
351
|
|
|
* removed from memory. |
352
|
|
|
* defaultMeetingCreateJoinDuration=5 |
353
|
|
|
* |
354
|
|
|
* @return mixed |
355
|
|
|
*/ |
356
|
|
|
public function createMeeting($params) |
357
|
|
|
{ |
358
|
|
|
$params['c_id'] = api_get_course_int_id(); |
359
|
|
|
$params['session_id'] = api_get_session_id(); |
360
|
|
|
|
361
|
|
|
if ($this->hasGroupSupport()) { |
362
|
|
|
$params['group_id'] = api_get_group_id(); |
363
|
|
|
} |
364
|
|
|
|
365
|
|
|
if ($this->isGlobalConferencePerUserEnabled() && !empty($this->userId)) { |
366
|
|
|
$params['user_id'] = (int) $this->userId; |
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
$params['attendee_pw'] = isset($params['attendee_pw']) ? $params['attendee_pw'] : $this->getUserMeetingPassword(); |
370
|
|
|
$attendeePassword = $params['attendee_pw']; |
371
|
|
|
$params['moderator_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : $this->getModMeetingPassword(); |
372
|
|
|
$moderatorPassword = $params['moderator_pw']; |
373
|
|
|
|
374
|
|
|
$params['record'] = api_get_course_plugin_setting('bbb', 'big_blue_button_record_and_store') == 1; |
375
|
|
|
$max = api_get_course_plugin_setting('bbb', 'max_users_limit'); |
376
|
|
|
$max = isset($max) ? $max : -1; |
377
|
|
|
|
378
|
|
|
$params['status'] = 1; |
379
|
|
|
// Generate a pseudo-global-unique-id to avoid clash of conferences on |
380
|
|
|
// the same BBB server with several Chamilo portals |
381
|
|
|
$params['remote_id'] = uniqid(true, true); |
382
|
|
|
// Each simultaneous conference room needs to have a different |
383
|
|
|
// voice_bridge composed of a 5 digits number, so generating a random one |
384
|
|
|
$params['voice_bridge'] = rand(10000, 99999); |
385
|
|
|
$params['created_at'] = api_get_utc_datetime(); |
386
|
|
|
$params['access_url'] = $this->accessUrl; |
387
|
|
|
|
388
|
|
|
$id = Database::insert($this->table, $params); |
389
|
|
|
|
390
|
|
|
if ($id) { |
|
|
|
|
391
|
|
|
Event::addEvent( |
|
|
|
|
392
|
|
|
'bbb_create_meeting', |
393
|
|
|
'meeting_id', |
394
|
|
|
(int) $id, |
395
|
|
|
null, |
396
|
|
|
api_get_user_id(), |
397
|
|
|
api_get_course_int_id(), |
398
|
|
|
api_get_session_id() |
399
|
|
|
); |
400
|
|
|
|
401
|
|
|
$meetingName = $params['meeting_name'] ?? $this->generateVideoConferenceName(); |
402
|
|
|
$welcomeMessage = $params['welcome_msg'] ?? null; |
403
|
|
|
$record = $params['record'] ? 'true' : 'false'; |
404
|
|
|
//$duration = isset($params['duration']) ? intval($params['duration']) : 0; |
405
|
|
|
// This setting currently limits the maximum conference duration, |
406
|
|
|
// to avoid lingering sessions on the video-conference server #6261 |
407
|
|
|
$duration = 300; |
408
|
|
|
$meetingDuration = (int) $this->plugin->get('meeting_duration'); |
409
|
|
|
if (!empty($meetingDuration)) { |
410
|
|
|
$duration = $meetingDuration; |
411
|
|
|
} |
412
|
|
|
$url = api_get_access_url(api_get_current_access_url_id())['url']; |
413
|
|
|
$bbbParams = array( |
414
|
|
|
'meetingId' => $params['remote_id'], // REQUIRED |
415
|
|
|
'meetingName' => $meetingName, // REQUIRED |
416
|
|
|
'attendeePw' => $attendeePassword, // Match this value in getJoinMeetingURL() to join as attendee. |
417
|
|
|
'moderatorPw' => $moderatorPassword, // Match this value in getJoinMeetingURL() to join as moderator. |
418
|
|
|
'welcomeMsg' => $welcomeMessage, // ''= use default. Change to customize. |
419
|
|
|
'dialNumber' => '', // The main number to call into. Optional. |
420
|
|
|
'voiceBridge' => $params['voice_bridge'], // PIN to join voice. Required. |
421
|
|
|
'webVoice' => '', // Alphanumeric to join voice. Optional. |
422
|
|
|
'logoutUrl' => $this->logoutUrl.'&action=logout&remote_id='.$params['remote_id'], |
423
|
|
|
'maxParticipants' => $max, // Optional. -1 = unlimitted. Not supported in BBB. [number] |
424
|
|
|
'record' => $record, // New. 'true' will tell BBB to record the meeting. |
425
|
|
|
'duration' => $duration, // Default = 0 which means no set duration in minutes. [number] |
426
|
|
|
'meta_OriginURL' => $url, // Add url information to BBB meeting info (see 'meta' info at https://docs.bigbluebutton.org/dev/api.html#create) |
427
|
|
|
//'meta_category' => '', // Use to pass additional info to BBB server. See API docs. |
428
|
|
|
); |
429
|
|
|
|
430
|
|
|
$status = false; |
431
|
|
|
$meeting = null; |
432
|
|
|
while ($status === false) { |
433
|
|
|
$result = $this->api->createMeetingWithXmlResponseArray($bbbParams); |
434
|
|
|
if (isset($result) && strval($result['returncode']) == 'SUCCESS') { |
435
|
|
|
if ($this->plugin->get('allow_regenerate_recording') === 'true') { |
436
|
|
|
$internalId = Database::escape_string($result['internalMeetingID']); |
437
|
|
|
$sql = "UPDATE $this->table SET internal_meeting_id = '".$internalId."' |
438
|
|
|
WHERE id = $id"; |
439
|
|
|
Database::query($sql); |
440
|
|
|
} |
441
|
|
|
$meeting = $this->joinMeeting($meetingName, true); |
442
|
|
|
|
443
|
|
|
return $meeting; |
444
|
|
|
} |
445
|
|
|
} |
446
|
|
|
} |
447
|
|
|
|
448
|
|
|
return false; |
449
|
|
|
} |
450
|
|
|
|
451
|
|
|
/** |
452
|
|
|
* @return bool |
453
|
|
|
*/ |
454
|
|
|
public function hasGroupSupport() |
455
|
|
|
{ |
456
|
|
|
return $this->groupSupport; |
457
|
|
|
} |
458
|
|
|
|
459
|
|
|
/** |
460
|
|
|
* Gets the password for a specific meeting for the current user |
461
|
|
|
* |
462
|
|
|
* @param string $courseCode |
463
|
|
|
* |
464
|
|
|
* @return string A moderator password if user is teacher, or the course code otherwise |
465
|
|
|
* |
466
|
|
|
*/ |
467
|
|
|
public function getUserMeetingPassword($courseCode = null) |
468
|
|
|
{ |
469
|
|
|
if ($this->isGlobalConferencePerUserEnabled()) { |
470
|
|
|
return 'url_'.$this->userId.'_'.api_get_current_access_url_id(); |
471
|
|
|
} |
472
|
|
|
|
473
|
|
|
if ($this->isGlobalConference()) { |
474
|
|
|
return 'url_'.api_get_current_access_url_id(); |
475
|
|
|
} |
476
|
|
|
$courseCode = empty($courseCode) ? api_get_course_id() : $courseCode; |
477
|
|
|
|
478
|
|
|
return $courseCode; |
479
|
|
|
} |
480
|
|
|
|
481
|
|
|
/** |
482
|
|
|
* Generated a moderator password for the meeting. |
483
|
|
|
* |
484
|
|
|
* @param string $courseCode |
485
|
|
|
* |
486
|
|
|
* @return string A password for the moderation of the videoconference |
487
|
|
|
*/ |
488
|
|
|
public function getModMeetingPassword($courseCode = null) |
489
|
|
|
{ |
490
|
|
|
if ($this->isGlobalConferencePerUserEnabled()) { |
491
|
|
|
return 'url_'.$this->userId.'_'.api_get_current_access_url_id().'_mod'; |
492
|
|
|
} |
493
|
|
|
|
494
|
|
|
if ($this->isGlobalConference()) { |
495
|
|
|
return 'url_'.api_get_current_access_url_id().'_mod'; |
496
|
|
|
} |
497
|
|
|
|
498
|
|
|
$courseCode = empty($courseCode) ? api_get_course_id() : $courseCode; |
499
|
|
|
|
500
|
|
|
return $courseCode.'mod'; |
501
|
|
|
} |
502
|
|
|
|
503
|
|
|
/** |
504
|
|
|
* Get the info from the current open videoconference. |
505
|
|
|
* Otherwise, return false. |
506
|
|
|
* |
507
|
|
|
* @return array|bool |
508
|
|
|
*/ |
509
|
|
|
public function getCurrentVideoConference() |
510
|
|
|
{ |
511
|
|
|
$whereConditions = [ |
512
|
|
|
'status = ?' => 1, |
513
|
|
|
]; |
514
|
|
|
|
515
|
|
|
if ($this->isGlobalConferencePerUserEnabled()) { |
516
|
|
|
$whereConditions[' AND user_id = ?'] = $this->userId; |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
if ($this->isGlobalConference()) { |
520
|
|
|
$whereConditions[' AND access_url = ?'] = api_get_current_access_url_id(); |
521
|
|
|
} |
522
|
|
|
|
523
|
|
|
if ($this->hasGroupSupport()) { |
524
|
|
|
$whereConditions[' AND group_id = ?'] = api_get_group_id(); |
525
|
|
|
} |
526
|
|
|
|
527
|
|
|
$cId = api_get_course_int_id(); |
528
|
|
|
$sessionId = api_get_session_id(); |
529
|
|
|
|
530
|
|
|
if ($cId) { |
531
|
|
|
$whereConditions[' AND c_id = ?'] = api_get_course_int_id(); |
532
|
|
|
} |
533
|
|
|
|
534
|
|
|
if ($sessionId) { |
535
|
|
|
$whereConditions[' AND session_id = ?'] = api_get_session_id(); |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
return Database::select( |
539
|
|
|
'*', |
540
|
|
|
$this->table, |
541
|
|
|
[ |
542
|
|
|
'where' => $whereConditions, |
543
|
|
|
'order' => 'created_at DESC', |
544
|
|
|
], |
545
|
|
|
'first' |
546
|
|
|
); |
547
|
|
|
} |
548
|
|
|
|
549
|
|
|
public function generateVideoConferenceName(string $defaultName = null): string |
550
|
|
|
{ |
551
|
|
|
$nameFilter = function ($name) { |
552
|
|
|
return URLify::filter( |
553
|
|
|
$name, |
554
|
|
|
64, |
555
|
|
|
'', |
556
|
|
|
true, |
557
|
|
|
true, |
558
|
|
|
true, |
559
|
|
|
false |
560
|
|
|
); |
561
|
|
|
}; |
562
|
|
|
|
563
|
|
|
if (!empty($defaultName)) { |
564
|
|
|
$name = $nameFilter($defaultName); |
565
|
|
|
|
566
|
|
|
if (!empty($name)) { |
567
|
|
|
return $name; |
568
|
|
|
} |
569
|
|
|
} |
570
|
|
|
|
571
|
|
|
$urlId = api_get_current_access_url_id(); |
572
|
|
|
|
573
|
|
|
if ($this->isGlobalConferencePerUserEnabled()) { |
574
|
|
|
return $nameFilter("url_{$this->userId}_$urlId"); |
575
|
|
|
} |
576
|
|
|
|
577
|
|
|
if ($this->isGlobalConference()) { |
578
|
|
|
return $nameFilter("url_$urlId"); |
579
|
|
|
} |
580
|
|
|
|
581
|
|
|
$course = api_get_course_entity(); |
582
|
|
|
$session = api_get_session_entity(); |
583
|
|
|
$group = api_get_group_entity(); |
584
|
|
|
|
585
|
|
|
if ($this->hasGroupSupport()) { |
586
|
|
|
$name = implode( |
587
|
|
|
'-', |
588
|
|
|
[ |
589
|
|
|
$course->getCode(), |
590
|
|
|
$session ? $session->getName() : '', |
|
|
|
|
591
|
|
|
$group ? $group->getName() : '', |
592
|
|
|
] |
593
|
|
|
); |
594
|
|
|
|
595
|
|
|
return $nameFilter($name); |
596
|
|
|
} |
597
|
|
|
|
598
|
|
|
$name = implode( |
599
|
|
|
'-', |
600
|
|
|
[ |
601
|
|
|
$course->getCode(), |
602
|
|
|
$session ? $session->getName() : '', |
|
|
|
|
603
|
|
|
] |
604
|
|
|
); |
605
|
|
|
|
606
|
|
|
return $nameFilter($name); |
607
|
|
|
} |
608
|
|
|
|
609
|
|
|
/** |
610
|
|
|
* Returns a meeting "join" URL |
611
|
|
|
* |
612
|
|
|
* @param string The name of the meeting (usually the course code) |
613
|
|
|
* |
614
|
|
|
* @return mixed The URL to join the meeting, or false on error |
615
|
|
|
* @todo implement moderator pass |
616
|
|
|
* @assert ('') === false |
617
|
|
|
* @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false |
618
|
|
|
*/ |
619
|
|
|
public function joinMeeting($meetingName) |
620
|
|
|
{ |
621
|
|
|
if ($this->debug) { |
622
|
|
|
error_log("joinMeeting: $meetingName"); |
623
|
|
|
} |
624
|
|
|
|
625
|
|
|
if (empty($meetingName)) { |
626
|
|
|
return false; |
627
|
|
|
} |
628
|
|
|
|
629
|
|
|
$manager = $this->isConferenceManager(); |
630
|
|
|
if ($manager) { |
631
|
|
|
$pass = $this->getModMeetingPassword(); |
632
|
|
|
} else { |
633
|
|
|
$pass = $this->getUserMeetingPassword(); |
634
|
|
|
} |
635
|
|
|
|
636
|
|
|
$meetingData = Database::select( |
637
|
|
|
'*', |
638
|
|
|
$this->table, |
639
|
|
|
array( |
640
|
|
|
'where' => array( |
641
|
|
|
'meeting_name = ? AND status = 1' => array( |
642
|
|
|
$meetingName, |
643
|
|
|
), |
644
|
|
|
), |
645
|
|
|
), |
646
|
|
|
'first' |
647
|
|
|
); |
648
|
|
|
|
649
|
|
|
if (empty($meetingData) || !is_array($meetingData)) { |
650
|
|
|
if ($this->debug) { |
651
|
|
|
error_log("meeting does not exist: $meetingName"); |
652
|
|
|
} |
653
|
|
|
|
654
|
|
|
return false; |
655
|
|
|
} |
656
|
|
|
|
657
|
|
|
$params = array( |
658
|
|
|
'meetingId' => $meetingData['remote_id'], |
659
|
|
|
// -- REQUIRED - The unique id for the meeting |
660
|
|
|
'password' => $this->getModMeetingPassword() |
661
|
|
|
// -- REQUIRED - The moderator password for the meeting |
662
|
|
|
); |
663
|
|
|
|
664
|
|
|
$meetingInfoExists = false; |
665
|
|
|
$meetingIsRunningInfo = $this->getMeetingInfo($params); |
666
|
|
|
if ($this->debug) { |
667
|
|
|
error_log('Searching meeting with params:'); |
668
|
|
|
error_log(print_r($params, 1)); |
669
|
|
|
error_log('Result:'); |
670
|
|
|
error_log(print_r($meetingIsRunningInfo, 1)); |
671
|
|
|
} |
672
|
|
|
|
673
|
|
|
if ($meetingIsRunningInfo === false) { |
674
|
|
|
// checking with the remote_id didn't work, so just in case and |
675
|
|
|
// to provide backwards support, check with the id |
676
|
|
|
$params = array( |
677
|
|
|
'meetingId' => $meetingData['id'], |
678
|
|
|
// -- REQUIRED - The unique id for the meeting |
679
|
|
|
'password' => $this->getModMeetingPassword() |
680
|
|
|
// -- REQUIRED - The moderator password for the meeting |
681
|
|
|
); |
682
|
|
|
$meetingIsRunningInfo = $this->getMeetingInfo($params); |
683
|
|
|
if ($this->debug) { |
684
|
|
|
error_log('Searching meetingId with params:'); |
685
|
|
|
error_log(print_r($params, 1)); |
686
|
|
|
error_log('Result:'); |
687
|
|
|
error_log(print_r($meetingIsRunningInfo, 1)); |
688
|
|
|
} |
689
|
|
|
} |
690
|
|
|
|
691
|
|
|
if (strval($meetingIsRunningInfo['returncode']) === 'SUCCESS' && |
692
|
|
|
isset($meetingIsRunningInfo['meetingName']) && |
693
|
|
|
!empty($meetingIsRunningInfo['meetingName']) |
694
|
|
|
) { |
695
|
|
|
$meetingInfoExists = true; |
696
|
|
|
} |
697
|
|
|
|
698
|
|
|
if ($this->debug) { |
699
|
|
|
error_log( |
700
|
|
|
"meeting is running: ".intval($meetingInfoExists) |
701
|
|
|
); |
702
|
|
|
} |
703
|
|
|
|
704
|
|
|
$url = false; |
705
|
|
|
if ($meetingInfoExists) { |
706
|
|
|
$joinParams = [ |
707
|
|
|
'meetingId' => $meetingData['remote_id'], |
708
|
|
|
// -- REQUIRED - A unique id for the meeting |
709
|
|
|
'username' => $this->userCompleteName, |
710
|
|
|
//-- REQUIRED - The name that will display for the user in the meeting |
711
|
|
|
'password' => $pass, |
712
|
|
|
//-- REQUIRED - The attendee or moderator password, depending on what's passed here |
713
|
|
|
//'createTime' => api_get_utc_datetime(), //-- OPTIONAL - string. Leave blank ('') unless you set this correctly. |
714
|
|
|
'userID' => api_get_user_id(), |
715
|
|
|
//-- OPTIONAL - string |
716
|
|
|
'webVoiceConf' => '', |
717
|
|
|
]; |
718
|
|
|
$url = $this->api->getJoinMeetingURL($joinParams); |
719
|
|
|
$url = $this->protocol.$url; |
720
|
|
|
} |
721
|
|
|
|
722
|
|
|
if ($this->debug) { |
723
|
|
|
error_log("return url :".$url); |
|
|
|
|
724
|
|
|
} |
725
|
|
|
|
726
|
|
|
return $url; |
727
|
|
|
} |
728
|
|
|
|
729
|
|
|
/** |
730
|
|
|
* Checks whether a user is teacher in the current course |
731
|
|
|
* @return bool True if the user can be considered a teacher in this course, false otherwise |
732
|
|
|
*/ |
733
|
|
|
public function isConferenceManager() |
734
|
|
|
{ |
735
|
|
|
if (api_is_coach() || api_is_platform_admin(false, true)) { |
736
|
|
|
return true; |
737
|
|
|
} |
738
|
|
|
|
739
|
|
|
if ($this->isGlobalConferencePerUserEnabled()) { |
740
|
|
|
$currentUserId = api_get_user_id(); |
741
|
|
|
if ($this->userId === $currentUserId) { |
742
|
|
|
return true; |
743
|
|
|
} else { |
744
|
|
|
return false; |
745
|
|
|
} |
746
|
|
|
} |
747
|
|
|
|
748
|
|
|
$courseInfo = api_get_course_info(); |
749
|
|
|
$groupId = api_get_group_id(); |
750
|
|
|
if (!empty($groupId) && !empty($courseInfo)) { |
751
|
|
|
$groupEnabled = api_get_course_plugin_setting('bbb', 'bbb_enable_conference_in_groups') === '1'; |
752
|
|
|
if ($groupEnabled) { |
753
|
|
|
$studentCanStartConference = api_get_course_plugin_setting( |
754
|
|
|
'bbb', |
755
|
|
|
'big_blue_button_students_start_conference_in_groups' |
756
|
|
|
) === '1'; |
757
|
|
|
|
758
|
|
|
if ($studentCanStartConference) { |
759
|
|
|
$isSubscribed = GroupManager::is_user_in_group( |
760
|
|
|
api_get_user_id(), |
761
|
|
|
GroupManager::get_group_properties($groupId) |
762
|
|
|
); |
763
|
|
|
if ($isSubscribed) { |
764
|
|
|
return true; |
765
|
|
|
} |
766
|
|
|
} |
767
|
|
|
} |
768
|
|
|
} |
769
|
|
|
|
770
|
|
|
if (!empty($courseInfo)) { |
771
|
|
|
return api_is_course_admin(); |
772
|
|
|
} |
773
|
|
|
|
774
|
|
|
return false; |
775
|
|
|
} |
776
|
|
|
|
777
|
|
|
/** |
778
|
|
|
* Get information about the given meeting |
779
|
|
|
* |
780
|
|
|
* @param array ...? |
781
|
|
|
* |
782
|
|
|
* @return mixed Array of information on success, false on error |
783
|
|
|
* @assert (array()) === false |
784
|
|
|
*/ |
785
|
|
|
public function getMeetingInfo($params) |
786
|
|
|
{ |
787
|
|
|
try { |
788
|
|
|
$result = $this->api->getMeetingInfoWithXmlResponseArray($params); |
789
|
|
|
if ($result == null) { |
790
|
|
|
if ($this->debug) { |
791
|
|
|
error_log("Failed to get any response. Maybe we can't contact the BBB server."); |
792
|
|
|
} |
793
|
|
|
} |
794
|
|
|
|
795
|
|
|
return $result; |
796
|
|
|
} catch (Exception $e) { |
797
|
|
|
if ($this->debug) { |
798
|
|
|
error_log('Caught exception: ', $e->getMessage(), "\n"); |
799
|
|
|
} |
800
|
|
|
} |
801
|
|
|
|
802
|
|
|
return false; |
803
|
|
|
} |
804
|
|
|
|
805
|
|
|
|
806
|
|
|
/** |
807
|
|
|
* @param int $meetingId |
808
|
|
|
* @param int $userId |
809
|
|
|
* |
810
|
|
|
* @return array |
811
|
|
|
*/ |
812
|
|
|
public function getMeetingParticipantInfo($meetingId, $userId) |
813
|
|
|
{ |
814
|
|
|
$meetingData = Database::select( |
815
|
|
|
'*', |
816
|
|
|
'plugin_bbb_room', |
817
|
|
|
array('where' => array('meeting_id = ? AND participant_id = ?' => [$meetingId, $userId])), |
818
|
|
|
'first' |
819
|
|
|
); |
820
|
|
|
|
821
|
|
|
if ($meetingData) { |
|
|
|
|
822
|
|
|
return $meetingData; |
823
|
|
|
} |
824
|
|
|
|
825
|
|
|
return []; |
826
|
|
|
} |
827
|
|
|
|
828
|
|
|
/** |
829
|
|
|
* Save a participant in a meeting room |
830
|
|
|
* |
831
|
|
|
* @param int $meetingId |
832
|
|
|
* @param int $participantId |
833
|
|
|
* |
834
|
|
|
* @return false|int The last inserted ID. Otherwise return false |
835
|
|
|
*/ |
836
|
|
|
public function saveParticipant($meetingId, $participantId) |
837
|
|
|
{ |
838
|
|
|
$meetingData = Database::select( |
839
|
|
|
'*', |
840
|
|
|
'plugin_bbb_room', |
841
|
|
|
[ |
842
|
|
|
'where' => [ |
843
|
|
|
'meeting_id = ? AND participant_id = ? AND close = ?' => [ |
844
|
|
|
$meetingId, |
845
|
|
|
$participantId, |
846
|
|
|
BBBPlugin::ROOM_OPEN, |
847
|
|
|
], |
848
|
|
|
], |
849
|
|
|
] |
850
|
|
|
); |
851
|
|
|
|
852
|
|
|
foreach ($meetingData as $roomItem) { |
853
|
|
|
$inAt = $roomItem['in_at']; |
854
|
|
|
$outAt = $roomItem['out_at']; |
855
|
|
|
$roomId = $roomItem['id']; |
856
|
|
|
if (!empty($roomId)) { |
857
|
|
|
if ($inAt != $outAt) { |
858
|
|
|
Database::update( |
859
|
|
|
'plugin_bbb_room', |
860
|
|
|
['close' => BBBPlugin::ROOM_CLOSE], |
861
|
|
|
['id = ? ' => $roomId] |
862
|
|
|
); |
863
|
|
|
} else { |
864
|
|
|
Database::update( |
865
|
|
|
'plugin_bbb_room', |
866
|
|
|
['out_at' => api_get_utc_datetime(), 'close' => BBBPlugin::ROOM_CLOSE], |
867
|
|
|
['id = ? ' => $roomId] |
868
|
|
|
); |
869
|
|
|
} |
870
|
|
|
} |
871
|
|
|
} |
872
|
|
|
|
873
|
|
|
$params = [ |
874
|
|
|
'meeting_id' => $meetingId, |
875
|
|
|
'participant_id' => $participantId, |
876
|
|
|
'in_at' => api_get_utc_datetime(), |
877
|
|
|
'out_at' => api_get_utc_datetime(), |
878
|
|
|
'close' => BBBPlugin::ROOM_OPEN, |
879
|
|
|
]; |
880
|
|
|
|
881
|
|
|
return Database::insert( |
882
|
|
|
'plugin_bbb_room', |
883
|
|
|
$params |
884
|
|
|
); |
885
|
|
|
} |
886
|
|
|
|
887
|
|
|
/** |
888
|
|
|
* Tells whether the given meeting exists and is running |
889
|
|
|
* (using course code as name) |
890
|
|
|
* |
891
|
|
|
* @param string $meetingName Meeting name (usually the course code) |
892
|
|
|
* |
893
|
|
|
* @return bool True if meeting exists, false otherwise |
894
|
|
|
* @assert ('') === false |
895
|
|
|
* @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false |
896
|
|
|
*/ |
897
|
|
|
public function meetingExists($meetingName) |
898
|
|
|
{ |
899
|
|
|
$meetingData = $this->getMeetingByName($meetingName); |
900
|
|
|
|
901
|
|
|
return !empty($meetingData); |
902
|
|
|
} |
903
|
|
|
|
904
|
|
|
/** |
905
|
|
|
* @param string $meetingName |
906
|
|
|
* |
907
|
|
|
* @return array |
908
|
|
|
*/ |
909
|
|
|
public function getMeetingByName($meetingName) |
910
|
|
|
{ |
911
|
|
|
if (empty($meetingName)) { |
912
|
|
|
return []; |
913
|
|
|
} |
914
|
|
|
|
915
|
|
|
$courseId = api_get_course_int_id(); |
916
|
|
|
$sessionId = api_get_session_id(); |
917
|
|
|
$conditions = array( |
918
|
|
|
'where' => array( |
919
|
|
|
'c_id = ? AND session_id = ? AND meeting_name = ? AND status = 1' => |
920
|
|
|
array($courseId, $sessionId, $meetingName), |
921
|
|
|
)); |
922
|
|
|
|
923
|
|
|
if ($this->hasGroupSupport()) { |
924
|
|
|
$groupId = api_get_group_id(); |
925
|
|
|
$conditions = array( |
926
|
|
|
'where' => array( |
927
|
|
|
'c_id = ? AND session_id = ? AND meeting_name = ? AND group_id = ? AND status = 1 AND access_url = ?' => |
928
|
|
|
array( |
929
|
|
|
$courseId, |
930
|
|
|
$sessionId, |
931
|
|
|
$meetingName, |
932
|
|
|
$groupId, |
933
|
|
|
$this->accessUrl, |
934
|
|
|
), |
935
|
|
|
), |
936
|
|
|
); |
937
|
|
|
} |
938
|
|
|
|
939
|
|
|
$meetingData = Database::select( |
940
|
|
|
'*', |
941
|
|
|
$this->table, |
942
|
|
|
$conditions, |
943
|
|
|
'first' |
944
|
|
|
); |
945
|
|
|
|
946
|
|
|
if ($this->debug) { |
947
|
|
|
error_log('meeting_exists '.print_r($meetingData, 1)); |
|
|
|
|
948
|
|
|
} |
949
|
|
|
|
950
|
|
|
return $meetingData; |
951
|
|
|
} |
952
|
|
|
|
953
|
|
|
/** |
954
|
|
|
* Gets a list from the database of all meetings attached to a course with the given status |
955
|
|
|
* @param int $courseId |
956
|
|
|
* @param int $sessionId |
957
|
|
|
* @param int $status 0 for closed meetings, 1 for open meetings |
958
|
|
|
* |
959
|
|
|
* @return array |
960
|
|
|
*/ |
961
|
|
|
public function getAllMeetingsInCourse($courseId, $sessionId, $status) |
962
|
|
|
{ |
963
|
|
|
$conditions = array( |
964
|
|
|
'where' => array( |
965
|
|
|
'status = ? AND c_id = ? AND session_id = ? ' => array( |
966
|
|
|
$status, |
967
|
|
|
$courseId, |
968
|
|
|
$sessionId, |
969
|
|
|
), |
970
|
|
|
), |
971
|
|
|
); |
972
|
|
|
|
973
|
|
|
return Database::select( |
974
|
|
|
'*', |
975
|
|
|
$this->table, |
976
|
|
|
$conditions |
977
|
|
|
); |
978
|
|
|
} |
979
|
|
|
|
980
|
|
|
/** |
981
|
|
|
* Gets all the course meetings saved in the plugin_bbb_meeting table and |
982
|
|
|
* generate actionable links (join/close/delete/etc) |
983
|
|
|
* |
984
|
|
|
* @param int $courseId |
985
|
|
|
* @param int $sessionId |
986
|
|
|
* @param int $groupId |
987
|
|
|
* @param bool $isAdminReport Optional. Set to true then the report is for admins |
988
|
|
|
* @param array $dateRange Optional |
989
|
|
|
* @param int $start Optional |
990
|
|
|
* @param int $limit Optional |
991
|
|
|
* |
992
|
|
|
* @return array Array of current open meeting rooms |
993
|
|
|
* @throws Exception |
994
|
|
|
*/ |
995
|
|
|
public function getMeetings( |
996
|
|
|
$courseId = 0, |
997
|
|
|
$sessionId = 0, |
998
|
|
|
$groupId = 0, |
999
|
|
|
$isAdminReport = false, |
1000
|
|
|
$dateRange = [], |
1001
|
|
|
$start = 0, |
1002
|
|
|
$limit = 0 |
1003
|
|
|
) { |
1004
|
|
|
$em = Database::getManager(); |
1005
|
|
|
$manager = $this->isConferenceManager(); |
1006
|
|
|
|
1007
|
|
|
$conditions = []; |
1008
|
|
|
if ($courseId || $sessionId || $groupId) { |
1009
|
|
|
$conditions = array( |
1010
|
|
|
'where' => array( |
1011
|
|
|
'c_id = ? AND session_id = ? ' => array($courseId, $sessionId), |
1012
|
|
|
), |
1013
|
|
|
); |
1014
|
|
|
|
1015
|
|
|
if ($this->hasGroupSupport()) { |
1016
|
|
|
$conditions = array( |
1017
|
|
|
'where' => array( |
1018
|
|
|
'c_id = ? AND session_id = ? AND group_id = ? ' => array( |
1019
|
|
|
$courseId, |
1020
|
|
|
$sessionId, |
1021
|
|
|
$groupId, |
1022
|
|
|
), |
1023
|
|
|
), |
1024
|
|
|
); |
1025
|
|
|
} |
1026
|
|
|
|
1027
|
|
|
if ($this->isGlobalConferencePerUserEnabled()) { |
1028
|
|
|
$conditions = array( |
1029
|
|
|
'where' => array( |
1030
|
|
|
'c_id = ? AND session_id = ? AND user_id = ?' => array( |
1031
|
|
|
$courseId, |
1032
|
|
|
$sessionId, |
1033
|
|
|
$this->userId, |
1034
|
|
|
), |
1035
|
|
|
), |
1036
|
|
|
); |
1037
|
|
|
} |
1038
|
|
|
} |
1039
|
|
|
if ($this->isGlobalConference()) { |
1040
|
|
|
$conditions = array( |
1041
|
|
|
'where' => array( |
1042
|
|
|
'c_id = ? AND user_id = ?' => array( |
1043
|
|
|
0, |
1044
|
|
|
$this->userId, |
1045
|
|
|
), |
1046
|
|
|
), |
1047
|
|
|
); |
1048
|
|
|
} |
1049
|
|
|
|
1050
|
|
|
if (!empty($dateRange)) { |
1051
|
|
|
$dateStart = date_create($dateRange['search_meeting_start']); |
1052
|
|
|
$dateStart = date_format($dateStart, 'Y-m-d H:i:s'); |
1053
|
|
|
$dateEnd = date_create($dateRange['search_meeting_end']); |
1054
|
|
|
$dateEnd = $dateEnd->add(new DateInterval('P1D')); |
1055
|
|
|
$dateEnd = date_format($dateEnd, 'Y-m-d H:i:s'); |
1056
|
|
|
|
1057
|
|
|
$conditions = array( |
1058
|
|
|
'where' => array( |
1059
|
|
|
'created_at BETWEEN ? AND ? ' => array($dateStart, $dateEnd), |
1060
|
|
|
), |
1061
|
|
|
); |
1062
|
|
|
} |
1063
|
|
|
|
1064
|
|
|
$conditions['order'] = 'created_at ASC'; |
1065
|
|
|
|
1066
|
|
|
if ($limit) { |
1067
|
|
|
$conditions['limit'] = "$start , $limit"; |
1068
|
|
|
} |
1069
|
|
|
|
1070
|
|
|
$meetingList = Database::select( |
1071
|
|
|
'*', |
1072
|
|
|
$this->table, |
1073
|
|
|
$conditions |
1074
|
|
|
); |
1075
|
|
|
$isGlobal = $this->isGlobalConference(); |
1076
|
|
|
$newMeetingList = array(); |
1077
|
|
|
foreach ($meetingList as $meetingDB) { |
1078
|
|
|
$item = array(); |
1079
|
|
|
$item['metting_name'] = $meetingDB['meeting_name']; |
1080
|
|
|
$courseId = $meetingDB['c_id']; |
1081
|
|
|
$courseInfo = api_get_course_info_by_id($courseId); |
1082
|
|
|
$courseCode = ''; |
1083
|
|
|
if (!empty($courseInfo)) { |
1084
|
|
|
$courseCode = $courseInfo['code']; |
1085
|
|
|
} |
1086
|
|
|
|
1087
|
|
|
if ($manager) { |
1088
|
|
|
$pass = $meetingDB['moderator_pw']; |
1089
|
|
|
} else { |
1090
|
|
|
$pass = $meetingDB['attendee_pw']; |
1091
|
|
|
} |
1092
|
|
|
|
1093
|
|
|
$meetingBBB = $this->getMeetingInfo( |
1094
|
|
|
[ |
1095
|
|
|
'meetingId' => $meetingDB['remote_id'], |
1096
|
|
|
'password' => $pass, |
1097
|
|
|
] |
1098
|
|
|
); |
1099
|
|
|
|
1100
|
|
|
if ($meetingBBB === false) { |
1101
|
|
|
// Checking with the remote_id didn't work, so just in case and |
1102
|
|
|
// to provide backwards support, check with the id |
1103
|
|
|
$params = array( |
1104
|
|
|
'meetingId' => $meetingDB['id'], |
1105
|
|
|
// -- REQUIRED - The unique id for the meeting |
1106
|
|
|
'password' => $pass |
1107
|
|
|
// -- REQUIRED - The moderator password for the meeting |
1108
|
|
|
); |
1109
|
|
|
$meetingBBB = $this->getMeetingInfo($params); |
1110
|
|
|
} |
1111
|
|
|
|
1112
|
|
|
if ($meetingDB['visibility'] == 0 && $this->isConferenceManager() === false) { |
1113
|
|
|
continue; |
1114
|
|
|
} |
1115
|
|
|
|
1116
|
|
|
$meetingBBB['end_url'] = $this->endUrl($meetingDB); |
1117
|
|
|
|
1118
|
|
|
if (isset($meetingBBB['returncode']) && (string) $meetingBBB['returncode'] === 'FAILED') { |
1119
|
|
|
if ($meetingDB['status'] == 1 && $this->isConferenceManager()) { |
1120
|
|
|
$this->endMeeting($meetingDB['id'], $courseCode); |
1121
|
|
|
} |
1122
|
|
|
} else { |
1123
|
|
|
$meetingBBB['add_to_calendar_url'] = $this->addToCalendarUrl($meetingDB); |
1124
|
|
|
} |
1125
|
|
|
|
1126
|
|
|
if ($meetingDB['record'] == 1) { |
1127
|
|
|
// backwards compatibility (when there was no remote ID) |
1128
|
|
|
$mId = $meetingDB['remote_id']; |
1129
|
|
|
if (empty($mId)) { |
1130
|
|
|
$mId = $meetingDB['id']; |
1131
|
|
|
} |
1132
|
|
|
if (empty($mId)) { |
1133
|
|
|
// if the id is still empty (should *never* occur as 'id' is |
1134
|
|
|
// the table's primary key), skip this conference |
1135
|
|
|
continue; |
1136
|
|
|
} |
1137
|
|
|
|
1138
|
|
|
$record = []; |
1139
|
|
|
$recordingParams = ['meetingId' => $mId]; |
1140
|
|
|
$records = $this->api->getRecordingsWithXmlResponseArray($recordingParams); |
1141
|
|
|
|
1142
|
|
|
if (!empty($records)) { |
1143
|
|
|
if (!isset($records['messageKey']) || $records['messageKey'] !== 'noRecordings') { |
1144
|
|
|
$record = end($records); |
1145
|
|
|
if (!is_array($record) || !isset($record['recordId'])) { |
1146
|
|
|
continue; |
1147
|
|
|
} |
1148
|
|
|
|
1149
|
|
|
if (!empty($record['playbackFormat'])) { |
1150
|
|
|
$this->updateMeetingVideoUrl($meetingDB['id'], $record['playbackFormatUrl']); |
1151
|
|
|
} |
1152
|
|
|
} |
1153
|
|
|
} |
1154
|
|
|
|
1155
|
|
|
if (isset($record['playbackFormat']) && !empty($record['playbackFormat'])) { |
1156
|
|
|
$recordLink = []; |
1157
|
|
|
foreach ($record['playbackFormat'] as $format) { |
1158
|
|
|
$this->insertMeetingFormat(intval($meetingDB['id']), $format->type->__toString(), $format->url->__toString()); |
1159
|
|
|
$recordLink['record'][] = 1; |
1160
|
|
|
$recordLink[] = Display::url( |
1161
|
|
|
$this->plugin->get_lang($format->type->__toString()), |
1162
|
|
|
$format->url->__toString(), |
1163
|
|
|
['target' => '_blank', 'class' => 'btn btn-default'] |
1164
|
|
|
); |
1165
|
|
|
} |
1166
|
|
|
} else { |
1167
|
|
|
$recordLink = $this->plugin->get_lang('NoRecording'); |
1168
|
|
|
} |
1169
|
|
|
|
1170
|
|
|
if ($isAdminReport) { |
1171
|
|
|
$this->forceCIdReq( |
1172
|
|
|
$courseInfo['code'], |
1173
|
|
|
$meetingDB['session_id'], |
1174
|
|
|
$meetingDB['group_id'] |
1175
|
|
|
); |
1176
|
|
|
} |
1177
|
|
|
|
1178
|
|
|
$actionLinks = $this->getActionLinks( |
1179
|
|
|
$meetingDB, |
1180
|
|
|
$record, |
1181
|
|
|
$isGlobal, |
1182
|
|
|
$isAdminReport |
1183
|
|
|
); |
1184
|
|
|
$item['show_links'] = $recordLink; |
1185
|
|
|
$item['record'] = true; |
1186
|
|
|
} else { |
1187
|
|
|
$actionLinks = $this->getActionLinks( |
1188
|
|
|
$meetingDB, |
1189
|
|
|
[], |
1190
|
|
|
$isGlobal, |
1191
|
|
|
$isAdminReport |
1192
|
|
|
); |
1193
|
|
|
|
1194
|
|
|
$item['show_links'] = $this->plugin->get_lang('NoRecording'); |
1195
|
|
|
$item['record'] = false; |
1196
|
|
|
} |
1197
|
|
|
|
1198
|
|
|
$item['action_links'] = implode(PHP_EOL, $actionLinks); |
1199
|
|
|
$item['created_at'] = api_convert_and_format_date($meetingDB['created_at']); |
1200
|
|
|
// created_at |
1201
|
|
|
$meetingDB['created_at'] = $item['created_at']; //avoid overwrite in array_merge() below |
1202
|
|
|
|
1203
|
|
|
$item['closed_at'] = ''; |
1204
|
|
|
if (!empty($meetingDB['closed_at'])) { |
1205
|
|
|
$item['closed_at'] = api_convert_and_format_date($meetingDB['closed_at']); |
1206
|
|
|
$meetingDB['closed_at'] = $item['closed_at']; |
1207
|
|
|
} |
1208
|
|
|
|
1209
|
|
|
$item['publish_url'] = $this->publishUrl($meetingDB); |
1210
|
|
|
$item['unpublish_url'] = $this->unPublishUrl($meetingBBB); |
1211
|
|
|
|
1212
|
|
|
if ($meetingDB['status'] == 1) { |
1213
|
|
|
$joinParams = [ |
1214
|
|
|
'meetingId' => $meetingDB['remote_id'], |
1215
|
|
|
//-- REQUIRED - A unique id for the meeting |
1216
|
|
|
'username' => $this->userCompleteName, |
1217
|
|
|
//-- REQUIRED - The name that will display for the user in the meeting |
1218
|
|
|
'password' => $pass, |
1219
|
|
|
//-- REQUIRED - The attendee or moderator password, depending on what's passed here |
1220
|
|
|
'createTime' => '', |
1221
|
|
|
//-- OPTIONAL - string. Leave blank ('') unless you set this correctly. |
1222
|
|
|
'userID' => '', |
1223
|
|
|
// -- OPTIONAL - string |
1224
|
|
|
'webVoiceConf' => '', |
1225
|
|
|
]; |
1226
|
|
|
$item['go_url'] = $this->protocol.$this->api->getJoinMeetingURL($joinParams); |
1227
|
|
|
} |
1228
|
|
|
$item = array_merge($item, $meetingDB, $meetingBBB); |
1229
|
|
|
|
1230
|
|
|
$item['course'] = $em->find('ChamiloCoreBundle:Course', $item['c_id']); |
1231
|
|
|
$item['session'] = $em->find('ChamiloCoreBundle:Session', $item['session_id']); |
1232
|
|
|
$newMeetingList[] = $item; |
1233
|
|
|
} |
1234
|
|
|
|
1235
|
|
|
return $newMeetingList; |
1236
|
|
|
} |
1237
|
|
|
|
1238
|
|
|
/** |
1239
|
|
|
* Counts all the course meetings saved in the plugin_bbb_meeting table. |
1240
|
|
|
* |
1241
|
|
|
* @param int $courseId |
1242
|
|
|
* @param int $sessionId |
1243
|
|
|
* @param int $groupId |
1244
|
|
|
* @param array $dateRange |
1245
|
|
|
* |
1246
|
|
|
* @return int Count of meetings |
1247
|
|
|
* @throws Exception |
1248
|
|
|
*/ |
1249
|
|
|
public function getCountMeetings( |
1250
|
|
|
$courseId = 0, |
1251
|
|
|
$sessionId = 0, |
1252
|
|
|
$groupId = 0, |
1253
|
|
|
$dateRange = [] |
1254
|
|
|
) { |
1255
|
|
|
$conditions = []; |
1256
|
|
|
if ($courseId || $sessionId || $groupId) { |
1257
|
|
|
$conditions = array( |
1258
|
|
|
'where' => array( |
1259
|
|
|
'c_id = ? AND session_id = ? ' => array($courseId, $sessionId), |
1260
|
|
|
), |
1261
|
|
|
); |
1262
|
|
|
|
1263
|
|
|
if ($this->hasGroupSupport()) { |
1264
|
|
|
$conditions = array( |
1265
|
|
|
'where' => array( |
1266
|
|
|
'c_id = ? AND session_id = ? AND group_id = ? ' => array( |
1267
|
|
|
$courseId, |
1268
|
|
|
$sessionId, |
1269
|
|
|
$groupId, |
1270
|
|
|
), |
1271
|
|
|
), |
1272
|
|
|
); |
1273
|
|
|
} |
1274
|
|
|
|
1275
|
|
|
if ($this->isGlobalConferencePerUserEnabled()) { |
1276
|
|
|
$conditions = array( |
1277
|
|
|
'where' => array( |
1278
|
|
|
'c_id = ? AND session_id = ? AND user_id = ?' => array( |
1279
|
|
|
$courseId, |
1280
|
|
|
$sessionId, |
1281
|
|
|
$this->userId, |
1282
|
|
|
), |
1283
|
|
|
), |
1284
|
|
|
); |
1285
|
|
|
} |
1286
|
|
|
} |
1287
|
|
|
|
1288
|
|
|
if (!empty($dateRange)) { |
1289
|
|
|
$dateStart = date_create($dateRange['search_meeting_start']); |
1290
|
|
|
$dateStart = date_format($dateStart, 'Y-m-d H:i:s'); |
1291
|
|
|
$dateEnd = date_create($dateRange['search_meeting_end']); |
1292
|
|
|
$dateEnd = $dateEnd->add(new DateInterval('P1D')); |
1293
|
|
|
$dateEnd = date_format($dateEnd, 'Y-m-d H:i:s'); |
1294
|
|
|
|
1295
|
|
|
$conditions = array( |
1296
|
|
|
'where' => array( |
1297
|
|
|
'created_at BETWEEN ? AND ? ' => array($dateStart, $dateEnd), |
1298
|
|
|
), |
1299
|
|
|
); |
1300
|
|
|
} |
1301
|
|
|
|
1302
|
|
|
$row = Database::select( |
1303
|
|
|
'count(*) as count', |
1304
|
|
|
$this->table, |
1305
|
|
|
$conditions, |
1306
|
|
|
'first' |
1307
|
|
|
); |
1308
|
|
|
|
1309
|
|
|
return $row['count']; |
1310
|
|
|
} |
1311
|
|
|
|
1312
|
|
|
/** |
1313
|
|
|
* @param array $meeting |
1314
|
|
|
* |
1315
|
|
|
* @return string |
1316
|
|
|
*/ |
1317
|
|
|
public function endUrl($meeting) |
1318
|
|
|
{ |
1319
|
|
|
if (!isset($meeting['id'])) { |
1320
|
|
|
return ''; |
1321
|
|
|
} |
1322
|
|
|
|
1323
|
|
|
return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams().'&action=end&id='.$meeting['id']; |
1324
|
|
|
} |
1325
|
|
|
|
1326
|
|
|
/** |
1327
|
|
|
* Closes a meeting (usually when the user click on the close button from |
1328
|
|
|
* the conferences listing. |
1329
|
|
|
* |
1330
|
|
|
* @param string The internal ID of the meeting (id field for this meeting) |
1331
|
|
|
* @param string $courseCode |
1332
|
|
|
* |
1333
|
|
|
* @return void |
1334
|
|
|
* @assert (0) === false |
1335
|
|
|
*/ |
1336
|
|
|
public function endMeeting($id, $courseCode = null) |
1337
|
|
|
{ |
1338
|
|
|
if (empty($id)) { |
1339
|
|
|
return false; |
1340
|
|
|
} |
1341
|
|
|
|
1342
|
|
|
$meetingData = Database::select( |
1343
|
|
|
'*', |
1344
|
|
|
$this->table, |
1345
|
|
|
array('where' => array('id = ?' => array($id))), |
1346
|
|
|
'first' |
1347
|
|
|
); |
1348
|
|
|
$manager = $this->isConferenceManager(); |
1349
|
|
|
if ($manager) { |
1350
|
|
|
$pass = $meetingData['moderator_pw']; |
1351
|
|
|
} else { |
1352
|
|
|
$pass = $meetingData['attendee_pw']; |
1353
|
|
|
} |
1354
|
|
|
|
1355
|
|
|
Event::addEvent( |
1356
|
|
|
'bbb_end_meeting', |
1357
|
|
|
'meeting_id', |
1358
|
|
|
(int) $id, |
1359
|
|
|
null, |
1360
|
|
|
api_get_user_id(), |
1361
|
|
|
api_get_course_int_id(), |
1362
|
|
|
api_get_session_id() |
1363
|
|
|
); |
1364
|
|
|
|
1365
|
|
|
$endParams = array( |
1366
|
|
|
'meetingId' => $meetingData['remote_id'], // REQUIRED - We have to know which meeting to end. |
1367
|
|
|
'password' => $pass, // REQUIRED - Must match moderator pass for meeting. |
1368
|
|
|
); |
1369
|
|
|
$this->api->endMeetingWithXmlResponseArray($endParams); |
1370
|
|
|
Database::update( |
1371
|
|
|
$this->table, |
1372
|
|
|
array('status' => 0, 'closed_at' => api_get_utc_datetime()), |
1373
|
|
|
array('id = ? ' => $id) |
1374
|
|
|
); |
1375
|
|
|
|
1376
|
|
|
// Update users with in_at y ou_at field equal |
1377
|
|
|
$roomTable = Database::get_main_table('plugin_bbb_room'); |
1378
|
|
|
$conditions['where'] = ['meeting_id=? AND in_at=out_at AND close=?' => [$id, BBBPlugin::ROOM_OPEN]]; |
|
|
|
|
1379
|
|
|
$roomList = Database::select( |
1380
|
|
|
'*', |
1381
|
|
|
$roomTable, |
1382
|
|
|
$conditions |
1383
|
|
|
); |
1384
|
|
|
|
1385
|
|
|
foreach ($roomList as $roomDB) { |
1386
|
|
|
$roomId = $roomDB['id']; |
1387
|
|
|
if (!empty($roomId)) { |
1388
|
|
|
Database::update( |
1389
|
|
|
$roomTable, |
1390
|
|
|
['out_at' => api_get_utc_datetime(), 'close' => BBBPlugin::ROOM_CLOSE], |
1391
|
|
|
['id = ? ' => $roomId] |
1392
|
|
|
); |
1393
|
|
|
} |
1394
|
|
|
} |
1395
|
|
|
|
1396
|
|
|
// Close all meeting rooms with meeting ID |
1397
|
|
|
Database::update( |
1398
|
|
|
$roomTable, |
1399
|
|
|
['close' => BBBPlugin::ROOM_CLOSE], |
1400
|
|
|
['meeting_id = ? ' => $id] |
1401
|
|
|
); |
1402
|
|
|
} |
1403
|
|
|
|
1404
|
|
|
/** |
1405
|
|
|
* @param array $meeting |
1406
|
|
|
* @param array $record |
1407
|
|
|
* |
1408
|
|
|
* @return string |
1409
|
|
|
*/ |
1410
|
|
|
public function addToCalendarUrl($meeting, $record = []) |
1411
|
|
|
{ |
1412
|
|
|
$url = isset($record['playbackFormatUrl']) ? $record['playbackFormatUrl'] : ''; |
1413
|
|
|
|
1414
|
|
|
return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams( |
1415
|
|
|
).'&action=add_to_calendar&id='.$meeting['id'].'&start='.api_strtotime($meeting['created_at']).'&url='.$url; |
1416
|
|
|
} |
1417
|
|
|
|
1418
|
|
|
/** |
1419
|
|
|
* @param int $meetingId |
1420
|
|
|
* @param string $videoUrl |
1421
|
|
|
* |
1422
|
|
|
* @return bool|int |
1423
|
|
|
*/ |
1424
|
|
|
public function updateMeetingVideoUrl($meetingId, $videoUrl) |
1425
|
|
|
{ |
1426
|
|
|
return Database::update( |
1427
|
|
|
'plugin_bbb_meeting', |
1428
|
|
|
['video_url' => $videoUrl], |
1429
|
|
|
['id = ?' => intval($meetingId)] |
1430
|
|
|
); |
1431
|
|
|
} |
1432
|
|
|
|
1433
|
|
|
/** |
1434
|
|
|
* @param int $meetingId |
1435
|
|
|
* @param string $formatType |
1436
|
|
|
* @param string $resourceUrl |
1437
|
|
|
* |
1438
|
|
|
* @return bool|int |
1439
|
|
|
*/ |
1440
|
|
|
public function insertMeetingFormat(int $meetingId, string $formatType, string $resourceUrl) |
1441
|
|
|
{ |
1442
|
|
|
$em = Database::getManager(); |
1443
|
|
|
$sm = $em->getConnection()->getSchemaManager(); |
1444
|
|
|
if ($sm->tablesExist('plugin_bbb_meeting_format')) { |
1445
|
|
|
return Database::insert( |
1446
|
|
|
'plugin_bbb_meeting_format', |
1447
|
|
|
[ |
1448
|
|
|
'format_type' => $formatType, |
1449
|
|
|
'resource_url' => $resourceUrl, |
1450
|
|
|
'meeting_id' => $meetingId |
1451
|
|
|
] |
1452
|
|
|
); |
1453
|
|
|
} |
1454
|
|
|
|
1455
|
|
|
} |
1456
|
|
|
|
1457
|
|
|
/** |
1458
|
|
|
* Force the course, session and/or group IDs |
1459
|
|
|
* |
1460
|
|
|
* @param string $courseCode |
1461
|
|
|
* @param int $sessionId |
1462
|
|
|
* @param int $groupId |
1463
|
|
|
*/ |
1464
|
|
|
public function forceCIdReq($courseCode, $sessionId = 0, $groupId = 0) |
1465
|
|
|
{ |
1466
|
|
|
$this->courseCode = $courseCode; |
1467
|
|
|
$this->sessionId = (int) $sessionId; |
1468
|
|
|
$this->groupId = (int) $groupId; |
1469
|
|
|
} |
1470
|
|
|
|
1471
|
|
|
/** |
1472
|
|
|
* @param array $meetingInfo |
1473
|
|
|
* @param array $recordInfo |
1474
|
|
|
* @param bool $isGlobal |
1475
|
|
|
* @param bool $isAdminReport |
1476
|
|
|
* |
1477
|
|
|
* @return array |
1478
|
|
|
*/ |
1479
|
|
|
private function getActionLinks( |
1480
|
|
|
$meetingInfo, |
1481
|
|
|
$recordInfo, |
1482
|
|
|
$isGlobal = false, |
1483
|
|
|
$isAdminReport = false |
1484
|
|
|
) { |
1485
|
|
|
$isVisible = $meetingInfo['visibility'] != 0; |
1486
|
|
|
$linkVisibility = $isVisible |
1487
|
|
|
? Display::url( |
1488
|
|
|
Display::return_icon('visible.png', get_lang('MakeInvisible')), |
1489
|
|
|
$this->unPublishUrl($meetingInfo) |
1490
|
|
|
) |
1491
|
|
|
: Display::url( |
1492
|
|
|
Display::return_icon('invisible.png', get_lang('MakeVisible')), |
1493
|
|
|
$this->publishUrl($meetingInfo) |
1494
|
|
|
); |
1495
|
|
|
|
1496
|
|
|
$links = []; |
1497
|
|
|
if ($this->plugin->get('allow_regenerate_recording') === 'true' && $meetingInfo['record'] == 1) { |
1498
|
|
|
if (!empty($recordInfo)) { |
1499
|
|
|
$links[] = Display::url( |
1500
|
|
|
Display::return_icon('reload.png', get_lang('RegenerateRecord')), |
1501
|
|
|
$this->regenerateRecordUrl($meetingInfo, $recordInfo) |
1502
|
|
|
); |
1503
|
|
|
} else { |
1504
|
|
|
$links[] = Display::url( |
1505
|
|
|
Display::return_icon('reload.png', get_lang('RegenerateRecord')), |
1506
|
|
|
$this->regenerateRecordUrlFromMeeting($meetingInfo) |
1507
|
|
|
); |
1508
|
|
|
} |
1509
|
|
|
} |
1510
|
|
|
|
1511
|
|
|
if (empty($recordInfo)) { |
1512
|
|
|
if (!$isAdminReport) { |
1513
|
|
|
if ($meetingInfo['status'] == 0) { |
1514
|
|
|
$links[] = Display::url( |
1515
|
|
|
Display::return_icon('delete.png', get_lang('Delete')), |
1516
|
|
|
$this->deleteRecordUrl($meetingInfo) |
1517
|
|
|
); |
1518
|
|
|
$links[] = $linkVisibility; |
1519
|
|
|
} |
1520
|
|
|
|
1521
|
|
|
return $links; |
1522
|
|
|
} else { |
1523
|
|
|
$links[] = Display::url( |
1524
|
|
|
Display::return_icon('course_home.png', get_lang('GoToCourse')), |
1525
|
|
|
$this->getListingUrl($meetingInfo['c_id'], $meetingInfo['session_id'], $meetingInfo['group_id']) |
1526
|
|
|
); |
1527
|
|
|
|
1528
|
|
|
return $links; |
1529
|
|
|
} |
1530
|
|
|
} |
1531
|
|
|
|
1532
|
|
|
if (!$isGlobal) { |
1533
|
|
|
$links[] = Display::url( |
1534
|
|
|
Display::return_icon('link.gif', get_lang('UrlMeetingToShare')), |
1535
|
|
|
$this->copyToRecordToLinkTool($meetingInfo) |
1536
|
|
|
); |
1537
|
|
|
$links[] = Display::url( |
1538
|
|
|
Display::return_icon('agenda.png', get_lang('AddToCalendar')), |
1539
|
|
|
$this->addToCalendarUrl($meetingInfo, $recordInfo) |
1540
|
|
|
); |
1541
|
|
|
} |
1542
|
|
|
|
1543
|
|
|
$hide = $this->plugin->get('disable_download_conference_link') === 'true' ? true : false; |
1544
|
|
|
|
1545
|
|
|
if ($hide == false) { |
|
|
|
|
1546
|
|
|
if ($meetingInfo['has_video_m4v']) { |
1547
|
|
|
$links[] = Display::url( |
1548
|
|
|
Display::return_icon('save.png', get_lang('DownloadFile')), |
1549
|
|
|
$recordInfo['playbackFormatUrl'].'/capture.m4v', |
1550
|
|
|
['target' => '_blank'] |
1551
|
|
|
); |
1552
|
|
|
} else { |
1553
|
|
|
$links[] = Display::url( |
1554
|
|
|
Display::return_icon('save.png', get_lang('DownloadFile')), |
1555
|
|
|
'#', |
1556
|
|
|
[ |
1557
|
|
|
'id' => "btn-check-meeting-video-{$meetingInfo['id']}", |
1558
|
|
|
'class' => 'check-meeting-video', |
1559
|
|
|
'data-id' => $meetingInfo['id'], |
1560
|
|
|
] |
1561
|
|
|
); |
1562
|
|
|
} |
1563
|
|
|
} |
1564
|
|
|
|
1565
|
|
|
|
1566
|
|
|
if (!$isAdminReport) { |
1567
|
|
|
$links[] = Display::url( |
1568
|
|
|
Display::return_icon('delete.png', get_lang('Delete')), |
1569
|
|
|
$this->deleteRecordUrl($meetingInfo) |
1570
|
|
|
); |
1571
|
|
|
$links[] = $linkVisibility; |
1572
|
|
|
} else { |
1573
|
|
|
$links[] = Display::url( |
1574
|
|
|
Display::return_icon('course_home.png', get_lang('GoToCourse')), |
1575
|
|
|
$this->getListingUrl($meetingInfo['c_id'], $meetingInfo['session_id'], $meetingInfo['group_id']) |
1576
|
|
|
); |
1577
|
|
|
} |
1578
|
|
|
|
1579
|
|
|
|
1580
|
|
|
return $links; |
1581
|
|
|
} |
1582
|
|
|
|
1583
|
|
|
/** |
1584
|
|
|
* @param array $meeting |
1585
|
|
|
* |
1586
|
|
|
* @return string |
1587
|
|
|
*/ |
1588
|
|
|
public function unPublishUrl($meeting) |
1589
|
|
|
{ |
1590
|
|
|
if (!isset($meeting['id'])) { |
1591
|
|
|
return null; |
1592
|
|
|
} |
1593
|
|
|
|
1594
|
|
|
return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams( |
1595
|
|
|
).'&action=unpublish&id='.$meeting['id']; |
1596
|
|
|
} |
1597
|
|
|
|
1598
|
|
|
/** |
1599
|
|
|
* @param array $meeting |
1600
|
|
|
* |
1601
|
|
|
* @return string |
1602
|
|
|
*/ |
1603
|
|
|
public function publishUrl($meeting) |
1604
|
|
|
{ |
1605
|
|
|
if (!isset($meeting['id'])) { |
1606
|
|
|
return ''; |
1607
|
|
|
} |
1608
|
|
|
|
1609
|
|
|
return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams( |
1610
|
|
|
).'&action=publish&id='.$meeting['id']; |
1611
|
|
|
} |
1612
|
|
|
|
1613
|
|
|
/** |
1614
|
|
|
* @param array $meeting |
1615
|
|
|
* @param array $recordInfo |
1616
|
|
|
* |
1617
|
|
|
* @return string |
1618
|
|
|
*/ |
1619
|
|
|
public function regenerateRecordUrl($meeting, $recordInfo) |
1620
|
|
|
{ |
1621
|
|
|
if ($this->plugin->get('allow_regenerate_recording') !== 'true') { |
1622
|
|
|
return ''; |
1623
|
|
|
} |
1624
|
|
|
|
1625
|
|
|
if (!isset($meeting['id'])) { |
1626
|
|
|
return ''; |
1627
|
|
|
} |
1628
|
|
|
|
1629
|
|
|
if (empty($recordInfo) || (!empty($recordInfo['recordId']) && !isset($recordInfo['recordId']))) { |
1630
|
|
|
return ''; |
1631
|
|
|
} |
1632
|
|
|
|
1633
|
|
|
return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams(). |
1634
|
|
|
'&action=regenerate_record&id='.$meeting['id'].'&record_id='.$recordInfo['recordId']; |
1635
|
|
|
} |
1636
|
|
|
|
1637
|
|
|
/** |
1638
|
|
|
* @param array $meeting |
1639
|
|
|
* |
1640
|
|
|
* @return string |
1641
|
|
|
*/ |
1642
|
|
|
public function regenerateRecordUrlFromMeeting($meeting) |
1643
|
|
|
{ |
1644
|
|
|
if ($this->plugin->get('allow_regenerate_recording') !== 'true') { |
1645
|
|
|
return ''; |
1646
|
|
|
} |
1647
|
|
|
|
1648
|
|
|
if (!isset($meeting['id'])) { |
1649
|
|
|
return ''; |
1650
|
|
|
} |
1651
|
|
|
|
1652
|
|
|
return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams(). |
1653
|
|
|
'&action=regenerate_record&id='.$meeting['id']; |
1654
|
|
|
} |
1655
|
|
|
|
1656
|
|
|
/** |
1657
|
|
|
* @param array $meeting |
1658
|
|
|
* |
1659
|
|
|
* @return string |
1660
|
|
|
*/ |
1661
|
|
|
public function deleteRecordUrl($meeting) |
1662
|
|
|
{ |
1663
|
|
|
if (!isset($meeting['id'])) { |
1664
|
|
|
return ''; |
1665
|
|
|
} |
1666
|
|
|
|
1667
|
|
|
return api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.$this->getUrlParams( |
1668
|
|
|
).'&action=delete_record&id='.$meeting['id']; |
1669
|
|
|
} |
1670
|
|
|
|
1671
|
|
|
/** |
1672
|
|
|
* @param array $meeting |
1673
|
|
|
* |
1674
|
|
|
* @return string |
1675
|
|
|
*/ |
1676
|
|
|
public function copyToRecordToLinkTool($meeting) |
1677
|
|
|
{ |
1678
|
|
|
if (!isset($meeting['id'])) { |
1679
|
|
|
return ''; |
1680
|
|
|
} |
1681
|
|
|
|
1682
|
|
|
return api_get_path(WEB_PLUGIN_PATH). |
1683
|
|
|
'bbb/listing.php?'.$this->getUrlParams().'&action=copy_record_to_link_tool&id='.$meeting['id']; |
1684
|
|
|
} |
1685
|
|
|
|
1686
|
|
|
/** |
1687
|
|
|
* Function disabled |
1688
|
|
|
*/ |
1689
|
|
|
public function publishMeeting($id) |
1690
|
|
|
{ |
1691
|
|
|
//return BigBlueButtonBN::setPublishRecordings($id, 'true', $this->url, $this->salt); |
1692
|
|
|
if (empty($id)) { |
1693
|
|
|
return false; |
1694
|
|
|
} |
1695
|
|
|
$id = intval($id); |
1696
|
|
|
Database::update($this->table, array('visibility' => 1), array('id = ? ' => $id)); |
1697
|
|
|
|
1698
|
|
|
return true; |
1699
|
|
|
} |
1700
|
|
|
|
1701
|
|
|
/** |
1702
|
|
|
* Function disabled |
1703
|
|
|
*/ |
1704
|
|
|
public function unpublishMeeting($id) |
1705
|
|
|
{ |
1706
|
|
|
//return BigBlueButtonBN::setPublishRecordings($id, 'false', $this->url, $this->salt); |
1707
|
|
|
if (empty($id)) { |
1708
|
|
|
return false; |
1709
|
|
|
} |
1710
|
|
|
$id = intval($id); |
1711
|
|
|
Database::update($this->table, array('visibility' => 0), array('id = ?' => $id)); |
1712
|
|
|
|
1713
|
|
|
return true; |
1714
|
|
|
} |
1715
|
|
|
|
1716
|
|
|
/** |
1717
|
|
|
* Get users online in the current course room. |
1718
|
|
|
* |
1719
|
|
|
* @return int The number of users currently connected to the videoconference |
1720
|
|
|
* @assert () > -1 |
1721
|
|
|
*/ |
1722
|
|
|
public function getUsersOnlineInCurrentRoom() |
1723
|
|
|
{ |
1724
|
|
|
$courseId = api_get_course_int_id(); |
1725
|
|
|
$sessionId = api_get_session_id(); |
1726
|
|
|
|
1727
|
|
|
$conditions = array( |
1728
|
|
|
'where' => array( |
1729
|
|
|
'c_id = ? AND session_id = ? AND status = 1 AND access_url = ?' => array( |
1730
|
|
|
$courseId, |
1731
|
|
|
$sessionId, |
1732
|
|
|
$this->accessUrl, |
1733
|
|
|
), |
1734
|
|
|
), |
1735
|
|
|
); |
1736
|
|
|
|
1737
|
|
|
if ($this->hasGroupSupport()) { |
1738
|
|
|
$groupId = api_get_group_id(); |
1739
|
|
|
$conditions = array( |
1740
|
|
|
'where' => array( |
1741
|
|
|
'c_id = ? AND session_id = ? AND group_id = ? AND status = 1 AND access_url = ?' => array( |
1742
|
|
|
$courseId, |
1743
|
|
|
$sessionId, |
1744
|
|
|
$groupId, |
1745
|
|
|
$this->accessUrl, |
1746
|
|
|
), |
1747
|
|
|
), |
1748
|
|
|
); |
1749
|
|
|
} |
1750
|
|
|
|
1751
|
|
|
if ($this->isGlobalConferencePerUserEnabled()) { |
1752
|
|
|
$conditions = array( |
1753
|
|
|
'where' => array( |
1754
|
|
|
'user_id = ? AND status = 1 AND access_url = ?' => array( |
1755
|
|
|
$this->userId, |
1756
|
|
|
$this->accessUrl, |
1757
|
|
|
), |
1758
|
|
|
), |
1759
|
|
|
); |
1760
|
|
|
} |
1761
|
|
|
|
1762
|
|
|
$meetingData = Database::select( |
1763
|
|
|
'*', |
1764
|
|
|
$this->table, |
1765
|
|
|
$conditions, |
1766
|
|
|
'first' |
1767
|
|
|
); |
1768
|
|
|
|
1769
|
|
|
if (empty($meetingData)) { |
1770
|
|
|
return 0; |
1771
|
|
|
} |
1772
|
|
|
$pass = $meetingData['moderator_pw']; |
1773
|
|
|
$info = $this->getMeetingInfo(array('meetingId' => $meetingData['remote_id'], 'password' => $pass)); |
1774
|
|
|
if ($info === false) { |
1775
|
|
|
//checking with the remote_id didn't work, so just in case and |
1776
|
|
|
// to provide backwards support, check with the id |
1777
|
|
|
$params = array( |
1778
|
|
|
'meetingId' => $meetingData['id'], |
1779
|
|
|
// -- REQUIRED - The unique id for the meeting |
1780
|
|
|
'password' => $pass |
1781
|
|
|
// -- REQUIRED - The moderator password for the meeting |
1782
|
|
|
); |
1783
|
|
|
$info = $this->getMeetingInfo($params); |
1784
|
|
|
} |
1785
|
|
|
|
1786
|
|
|
if (!empty($info) && isset($info['participantCount'])) { |
1787
|
|
|
return $info['participantCount']; |
1788
|
|
|
} |
1789
|
|
|
|
1790
|
|
|
return 0; |
1791
|
|
|
} |
1792
|
|
|
|
1793
|
|
|
/** |
1794
|
|
|
* @param int $id |
1795
|
|
|
* @param string $recordId |
1796
|
|
|
* |
1797
|
|
|
* @return bool |
1798
|
|
|
*/ |
1799
|
|
|
public function regenerateRecording($id, $recordId = '') |
1800
|
|
|
{ |
1801
|
|
|
if ($this->plugin->get('allow_regenerate_recording') !== 'true') { |
1802
|
|
|
return false; |
1803
|
|
|
} |
1804
|
|
|
|
1805
|
|
|
if (empty($id)) { |
1806
|
|
|
return false; |
1807
|
|
|
} |
1808
|
|
|
|
1809
|
|
|
$meetingData = Database::select( |
1810
|
|
|
'*', |
1811
|
|
|
$this->table, |
1812
|
|
|
array('where' => array('id = ?' => array($id))), |
1813
|
|
|
'first' |
1814
|
|
|
); |
1815
|
|
|
|
1816
|
|
|
Event::addEvent( |
1817
|
|
|
'bbb_regenerate_record', |
1818
|
|
|
'record_id', |
1819
|
|
|
(int) $recordId, |
1820
|
|
|
null, |
1821
|
|
|
api_get_user_id(), |
1822
|
|
|
api_get_course_int_id(), |
1823
|
|
|
api_get_session_id() |
1824
|
|
|
); |
1825
|
|
|
|
1826
|
|
|
// Check if there are recordings for this meeting |
1827
|
|
|
$recordings = $this->api->getRecordings(['meetingId' => $meetingData['remote_id']]); |
1828
|
|
|
if (!empty($recordings) && isset($recordings['messageKey']) && $recordings['messageKey'] === 'noRecordings') { |
1829
|
|
|
// Regenerate the meeting id |
1830
|
|
|
if (!empty($meetingData['internal_meeting_id'])) { |
1831
|
|
|
return $this->api->generateRecording(['recordId' => $meetingData['internal_meeting_id']]); |
1832
|
|
|
} |
1833
|
|
|
|
1834
|
|
|
/*$pass = $this->getModMeetingPassword(); |
1835
|
|
|
$info = $this->getMeetingInfo(['meetingId' => $meetingData['remote_id'], 'password' => $pass]); |
1836
|
|
|
if (!empty($info) && isset($info['internalMeetingID'])) { |
1837
|
|
|
return $this->api->generateRecording(['recordId' => $meetingData['internal_meeting_id']]); |
1838
|
|
|
}*/ |
1839
|
|
|
|
1840
|
|
|
return false; |
1841
|
|
|
} else { |
1842
|
|
|
if (!empty($recordings['records'])) { |
1843
|
|
|
$recordExists = false; |
1844
|
|
|
foreach ($recordings['records'] as $record) { |
1845
|
|
|
if ($recordId == $record['recordId']) { |
1846
|
|
|
$recordExists = true; |
1847
|
|
|
break; |
1848
|
|
|
} |
1849
|
|
|
} |
1850
|
|
|
|
1851
|
|
|
if ($recordExists) { |
1852
|
|
|
return $this->api->generateRecording(['recordId' => $recordId]); |
1853
|
|
|
} |
1854
|
|
|
} |
1855
|
|
|
} |
1856
|
|
|
|
1857
|
|
|
return false; |
1858
|
|
|
} |
1859
|
|
|
|
1860
|
|
|
/** |
1861
|
|
|
* Deletes a recording of a meeting |
1862
|
|
|
* |
1863
|
|
|
* @param int $id ID of the recording |
1864
|
|
|
* |
1865
|
|
|
* @return bool |
1866
|
|
|
* |
1867
|
|
|
* @assert () === false |
1868
|
|
|
* @todo Also delete links and agenda items created from this recording |
1869
|
|
|
*/ |
1870
|
|
|
public function deleteRecording($id) |
1871
|
|
|
{ |
1872
|
|
|
if (empty($id)) { |
1873
|
|
|
return false; |
1874
|
|
|
} |
1875
|
|
|
|
1876
|
|
|
$meetingData = Database::select( |
1877
|
|
|
'*', |
1878
|
|
|
$this->table, |
1879
|
|
|
array('where' => array('id = ?' => array($id))), |
1880
|
|
|
'first' |
1881
|
|
|
); |
1882
|
|
|
|
1883
|
|
|
Event::addEvent( |
1884
|
|
|
'bbb_delete_record', |
1885
|
|
|
'meeting_id', |
1886
|
|
|
$id, |
1887
|
|
|
null, |
1888
|
|
|
api_get_user_id(), |
1889
|
|
|
api_get_course_int_id(), |
1890
|
|
|
api_get_session_id() |
1891
|
|
|
); |
1892
|
|
|
|
1893
|
|
|
$delete = false; |
1894
|
|
|
$recordings = []; |
1895
|
|
|
// Check if there are recordings for this meeting |
1896
|
|
|
if (!empty($meetingData['remote_id'])) { |
1897
|
|
|
Event::addEvent( |
1898
|
|
|
'bbb_delete_record', |
1899
|
|
|
'remote_id', |
1900
|
|
|
$meetingData['remote_id'], |
1901
|
|
|
null, |
1902
|
|
|
api_get_user_id(), |
1903
|
|
|
api_get_course_int_id(), |
1904
|
|
|
api_get_session_id() |
1905
|
|
|
); |
1906
|
|
|
$recordings = $this->api->getRecordings(['meetingId' => $meetingData['remote_id']]); |
1907
|
|
|
} |
1908
|
|
|
if (!empty($recordings) && isset($recordings['messageKey']) && $recordings['messageKey'] == 'noRecordings') { |
1909
|
|
|
$delete = true; |
1910
|
|
|
} else { |
1911
|
|
|
if (!empty($recordings['records'])) { |
1912
|
|
|
$recordsToDelete = []; |
1913
|
|
|
foreach ($recordings['records'] as $record) { |
1914
|
|
|
$recordsToDelete[] = $record['recordId']; |
1915
|
|
|
} |
1916
|
|
|
$delete = true; |
1917
|
|
|
if (!empty($recordsToDelete)) { |
1918
|
|
|
$recordingParams = ['recordId' => implode(',', $recordsToDelete)]; |
1919
|
|
|
Event::addEvent( |
1920
|
|
|
'bbb_delete_record', |
1921
|
|
|
'record_id_list', |
1922
|
|
|
implode(',', $recordsToDelete), |
1923
|
|
|
null, |
1924
|
|
|
api_get_user_id(), |
1925
|
|
|
api_get_course_int_id(), |
1926
|
|
|
api_get_session_id() |
1927
|
|
|
); |
1928
|
|
|
$result = $this->api->deleteRecordingsWithXmlResponseArray($recordingParams); |
1929
|
|
|
if (!empty($result) && isset($result['deleted']) && $result['deleted'] === 'true') { |
1930
|
|
|
$delete = true; |
1931
|
|
|
} |
1932
|
|
|
} |
1933
|
|
|
} |
1934
|
|
|
} |
1935
|
|
|
|
1936
|
|
|
if ($delete) { |
1937
|
|
|
Database::delete( |
1938
|
|
|
'plugin_bbb_room', |
1939
|
|
|
array('meeting_id = ?' => array($id)) |
1940
|
|
|
); |
1941
|
|
|
|
1942
|
|
|
Database::delete( |
1943
|
|
|
$this->table, |
1944
|
|
|
array('id = ?' => array($id)) |
1945
|
|
|
); |
1946
|
|
|
} |
1947
|
|
|
|
1948
|
|
|
return $delete; |
1949
|
|
|
} |
1950
|
|
|
|
1951
|
|
|
/** |
1952
|
|
|
* Creates a link in the links tool from the given videoconference recording |
1953
|
|
|
* |
1954
|
|
|
* @param int $id ID of the item in the plugin_bbb_meeting table |
1955
|
|
|
* @param string Hash identifying the recording, as provided by the API |
1956
|
|
|
* |
1957
|
|
|
* @return mixed ID of the newly created link, or false on error |
1958
|
|
|
* @assert (null, null) === false |
1959
|
|
|
* @assert (1, null) === false |
1960
|
|
|
* @assert (null, 'abcdefabcdefabcdefabcdef') === false |
1961
|
|
|
*/ |
1962
|
|
|
public function copyRecordingToLinkTool($id) |
1963
|
|
|
{ |
1964
|
|
|
if (empty($id)) { |
1965
|
|
|
return false; |
1966
|
|
|
} |
1967
|
|
|
//$records = BigBlueButtonBN::getRecordingsUrl($id); |
1968
|
|
|
$meetingData = Database::select( |
1969
|
|
|
'*', |
1970
|
|
|
$this->table, |
1971
|
|
|
array('where' => array('id = ?' => array($id))), |
1972
|
|
|
'first' |
1973
|
|
|
); |
1974
|
|
|
|
1975
|
|
|
$records = $this->api->getRecordingsWithXmlResponseArray( |
1976
|
|
|
array('meetingId' => $meetingData['remote_id']) |
1977
|
|
|
); |
1978
|
|
|
|
1979
|
|
|
if (!empty($records)) { |
1980
|
|
|
if (isset($records['message']) && !empty($records['message'])) { |
1981
|
|
|
if ($records['messageKey'] == 'noRecordings') { |
1982
|
|
|
$recordArray[] = $this->plugin->get_lang('NoRecording'); |
|
|
|
|
1983
|
|
|
} else { |
1984
|
|
|
//$recordArray[] = $records['message']; |
1985
|
|
|
} |
1986
|
|
|
|
1987
|
|
|
return false; |
1988
|
|
|
} else { |
1989
|
|
|
$record = $records[0]; |
1990
|
|
|
if (is_array($record) && isset($record['recordId'])) { |
1991
|
|
|
$url = $record['playbackFormatUrl']; |
1992
|
|
|
$link = new Link(); |
1993
|
|
|
$params['url'] = $url; |
|
|
|
|
1994
|
|
|
$params['title'] = $meetingData['meeting_name']; |
1995
|
|
|
$id = $link->save($params); |
1996
|
|
|
|
1997
|
|
|
return $id; |
1998
|
|
|
} |
1999
|
|
|
} |
2000
|
|
|
} |
2001
|
|
|
|
2002
|
|
|
return false; |
2003
|
|
|
} |
2004
|
|
|
|
2005
|
|
|
/** |
2006
|
|
|
* Checks if the video conference server is running. |
2007
|
|
|
* Function currently disabled (always returns 1) |
2008
|
|
|
* @return bool True if server is running, false otherwise |
2009
|
|
|
* @assert () === false |
2010
|
|
|
*/ |
2011
|
|
|
public function isServerRunning() |
2012
|
|
|
{ |
2013
|
|
|
return true; |
2014
|
|
|
//return BigBlueButtonBN::isServerRunning($this->protocol.$this->url); |
2015
|
|
|
} |
2016
|
|
|
|
2017
|
|
|
/** |
2018
|
|
|
* Checks if the video conference plugin is properly configured |
2019
|
|
|
* @return bool True if plugin has a host and a salt, false otherwise |
2020
|
|
|
* @assert () === false |
2021
|
|
|
*/ |
2022
|
|
|
public function isServerConfigured() |
2023
|
|
|
{ |
2024
|
|
|
$host = $this->plugin->get('host'); |
2025
|
|
|
|
2026
|
|
|
if (empty($host)) { |
2027
|
|
|
return false; |
2028
|
|
|
} |
2029
|
|
|
|
2030
|
|
|
$salt = $this->plugin->get('salt'); |
2031
|
|
|
|
2032
|
|
|
if (empty($salt)) { |
2033
|
|
|
return false; |
2034
|
|
|
} |
2035
|
|
|
|
2036
|
|
|
return true; |
2037
|
|
|
//return BigBlueButtonBN::isServerRunning($this->protocol.$this->url); |
2038
|
|
|
} |
2039
|
|
|
|
2040
|
|
|
/** |
2041
|
|
|
* Get active session in the all platform |
2042
|
|
|
*/ |
2043
|
|
|
public function getActiveSessionsCount() |
2044
|
|
|
{ |
2045
|
|
|
$meetingList = Database::select( |
2046
|
|
|
'count(id) as count', |
2047
|
|
|
$this->table, |
2048
|
|
|
array('where' => array('status = ? AND access_url = ?' => array(1, $this->accessUrl))), |
2049
|
|
|
'first' |
2050
|
|
|
); |
2051
|
|
|
|
2052
|
|
|
return $meetingList['count']; |
2053
|
|
|
} |
2054
|
|
|
|
2055
|
|
|
/** |
2056
|
|
|
* Get active session in the all platform |
2057
|
|
|
* |
2058
|
|
|
* @param boolean $allSites Parameter to indicate whether to get the result from all sites |
2059
|
|
|
* |
2060
|
|
|
* @return array |
2061
|
|
|
*/ |
2062
|
|
|
public function getActiveSessions(bool $allSites = false): array |
2063
|
|
|
{ |
2064
|
|
|
$where = ['where' => ['status = ?' => 1]]; |
2065
|
|
|
|
2066
|
|
|
if (!$allSites) { |
2067
|
|
|
$where['where'][' AND access_url = ?'] = $this->accessUrl; |
2068
|
|
|
} |
2069
|
|
|
|
2070
|
|
|
return Database::select( |
2071
|
|
|
'*', |
2072
|
|
|
$this->table, |
2073
|
|
|
$where |
2074
|
|
|
); |
2075
|
|
|
} |
2076
|
|
|
|
2077
|
|
|
/** |
2078
|
|
|
* @param string $url |
2079
|
|
|
*/ |
2080
|
|
|
public function redirectToBBB($url) |
2081
|
|
|
{ |
2082
|
|
|
if (file_exists(__DIR__.'/../config.vm.php')) { |
2083
|
|
|
// Using VM |
2084
|
|
|
echo Display::url($this->plugin->get_lang('ClickToContinue'), $url); |
2085
|
|
|
exit; |
|
|
|
|
2086
|
|
|
} else { |
2087
|
|
|
// Classic |
2088
|
|
|
header("Location: $url"); |
2089
|
|
|
exit; |
2090
|
|
|
} |
2091
|
|
|
} |
2092
|
|
|
|
2093
|
|
|
/** |
2094
|
|
|
* @return string |
2095
|
|
|
*/ |
2096
|
|
|
public function getConferenceUrl() |
2097
|
|
|
{ |
2098
|
|
|
return api_get_path(WEB_PLUGIN_PATH).'bbb/start.php?launch=1&'.$this->getUrlParams(); |
2099
|
|
|
} |
2100
|
|
|
|
2101
|
|
|
/** |
2102
|
|
|
* Get the meeting info from DB by its name |
2103
|
|
|
* |
2104
|
|
|
* @param string $name |
2105
|
|
|
* |
2106
|
|
|
* @return array |
2107
|
|
|
*/ |
2108
|
|
|
public function findMeetingByName($name) |
2109
|
|
|
{ |
2110
|
|
|
$meetingData = Database::select( |
2111
|
|
|
'*', |
2112
|
|
|
'plugin_bbb_meeting', |
2113
|
|
|
array('where' => array('meeting_name = ? AND status = 1 ' => $name)), |
2114
|
|
|
'first' |
2115
|
|
|
); |
2116
|
|
|
|
2117
|
|
|
return $meetingData; |
2118
|
|
|
} |
2119
|
|
|
|
2120
|
|
|
/** |
2121
|
|
|
* Get the meeting info from DB by its name |
2122
|
|
|
* |
2123
|
|
|
* @param int $id |
2124
|
|
|
* |
2125
|
|
|
* @return array |
2126
|
|
|
*/ |
2127
|
|
|
public function getMeeting($id) |
2128
|
|
|
{ |
2129
|
|
|
$meetingData = Database::select( |
2130
|
|
|
'*', |
2131
|
|
|
'plugin_bbb_meeting', |
2132
|
|
|
array('where' => array('id = ?' => $id)), |
2133
|
|
|
'first' |
2134
|
|
|
); |
2135
|
|
|
|
2136
|
|
|
return $meetingData; |
2137
|
|
|
} |
2138
|
|
|
|
2139
|
|
|
/** |
2140
|
|
|
* Get the meeting info. |
2141
|
|
|
* |
2142
|
|
|
* @param int $id |
2143
|
|
|
* |
2144
|
|
|
* @return array |
2145
|
|
|
*/ |
2146
|
|
|
public function getMeetingByRemoteId($id) |
2147
|
|
|
{ |
2148
|
|
|
$meetingData = Database::select( |
2149
|
|
|
'*', |
2150
|
|
|
'plugin_bbb_meeting', |
2151
|
|
|
array('where' => array('remote_id = ?' => $id)), |
2152
|
|
|
'first' |
2153
|
|
|
); |
2154
|
|
|
|
2155
|
|
|
return $meetingData; |
2156
|
|
|
} |
2157
|
|
|
|
2158
|
|
|
/** |
2159
|
|
|
* @param int $meetingId |
2160
|
|
|
* |
2161
|
|
|
* @return array |
2162
|
|
|
*/ |
2163
|
|
|
public function findConnectedMeetingParticipants($meetingId) |
2164
|
|
|
{ |
2165
|
|
|
$meetingData = Database::select( |
2166
|
|
|
'*', |
2167
|
|
|
'plugin_bbb_room', |
2168
|
|
|
array('where' => array('meeting_id = ? AND in_at IS NOT NULL' => $meetingId)) |
2169
|
|
|
); |
2170
|
|
|
$participantIds = []; |
2171
|
|
|
$return = []; |
2172
|
|
|
|
2173
|
|
|
foreach ($meetingData as $participantInfo) { |
2174
|
|
|
if (in_array($participantInfo['participant_id'], $participantIds)) { |
2175
|
|
|
continue; |
2176
|
|
|
} |
2177
|
|
|
|
2178
|
|
|
$participantIds[] = $participantInfo['participant_id']; |
2179
|
|
|
|
2180
|
|
|
$return[] = [ |
2181
|
|
|
'id' => $participantInfo['id'], |
2182
|
|
|
'meeting_id' => $participantInfo['meeting_id'], |
2183
|
|
|
'participant' => api_get_user_entity($participantInfo['participant_id']), |
2184
|
|
|
'in_at' => $participantInfo['in_at'], |
2185
|
|
|
'out_at' => $participantInfo['out_at'], |
2186
|
|
|
]; |
2187
|
|
|
} |
2188
|
|
|
|
2189
|
|
|
return $return; |
2190
|
|
|
} |
2191
|
|
|
|
2192
|
|
|
/** |
2193
|
|
|
* Check if the meeting has a capture.m4v video file. If exists then the has_video_m4v field is updated |
2194
|
|
|
* |
2195
|
|
|
* @param int $meetingId |
2196
|
|
|
* |
2197
|
|
|
* @return bool |
2198
|
|
|
*/ |
2199
|
|
|
public function checkDirectMeetingVideoUrl($meetingId) |
2200
|
|
|
{ |
2201
|
|
|
$meetingInfo = Database::select( |
2202
|
|
|
'*', |
2203
|
|
|
'plugin_bbb_meeting', |
2204
|
|
|
[ |
2205
|
|
|
'where' => ['id = ?' => intval($meetingId)], |
2206
|
|
|
], |
2207
|
|
|
'first' |
2208
|
|
|
); |
2209
|
|
|
|
2210
|
|
|
if (!isset($meetingInfo['video_url'])) { |
2211
|
|
|
return false; |
2212
|
|
|
} |
2213
|
|
|
|
2214
|
|
|
$hasCapture = SocialManager::verifyUrl($meetingInfo['video_url'].'/capture.m4v'); |
2215
|
|
|
|
2216
|
|
|
if ($hasCapture) { |
2217
|
|
|
return Database::update( |
|
|
|
|
2218
|
|
|
'plugin_bbb_meeting', |
2219
|
|
|
['has_video_m4v' => true], |
2220
|
|
|
['id = ?' => intval($meetingId)] |
2221
|
|
|
); |
2222
|
|
|
} |
2223
|
|
|
|
2224
|
|
|
return $hasCapture; |
2225
|
|
|
} |
2226
|
|
|
} |
2227
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.