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