1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace JoisarJignesh\Bigbluebutton\Services; |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
use BigBlueButton\Parameters\CreateMeetingParameters; |
8
|
|
|
use BigBlueButton\Parameters\DeleteRecordingsParameters; |
9
|
|
|
use BigBlueButton\Parameters\EndMeetingParameters; |
10
|
|
|
use BigBlueButton\Parameters\GetMeetingInfoParameters; |
11
|
|
|
use BigBlueButton\Parameters\GetRecordingsParameters; |
12
|
|
|
use BigBlueButton\Parameters\HooksCreateParameters; |
13
|
|
|
use BigBlueButton\Parameters\HooksDestroyParameters; |
14
|
|
|
use BigBlueButton\Parameters\IsMeetingRunningParameters; |
15
|
|
|
use BigBlueButton\Parameters\JoinMeetingParameters; |
16
|
|
|
use BigBlueButton\Parameters\PublishRecordingsParameters; |
17
|
|
|
use BigBlueButton\Parameters\SetConfigXMLParameters; |
18
|
|
|
use Illuminate\Support\Str; |
19
|
|
|
|
20
|
|
|
trait initMeeting |
21
|
|
|
{ |
22
|
|
|
|
23
|
|
|
/* |
24
|
|
|
* required fields |
25
|
|
|
* meetingID |
26
|
|
|
* meetingName |
27
|
|
|
* |
28
|
|
|
*/ |
29
|
|
|
public function initCreateMeeting(array $parameters) |
30
|
|
|
{ |
31
|
|
|
$request = Fluent($parameters); |
32
|
|
|
$meetingParams = new CreateMeetingParameters($request->meetingID, $request->meetingName); |
33
|
|
|
$meetingParams->setModeratorPassword($request->get('moderatorPW', Str::random(config('bigbluebutton.create.passwordLength', 8)))); |
34
|
|
|
$meetingParams->setAttendeePassword($request->get('attendeePW', Str::random(config('bigbluebutton.create.passwordLength', 8)))); |
35
|
|
|
$meetingParams->setDuration($request->get('duration', config('bigbluebutton.create.duration', 0))); |
36
|
|
|
$meetingParams->setRecord($request->get('record', config('bigbluebutton.create.record', false))); |
37
|
|
|
$meetingParams->setMaxParticipants($request->get('maxParticipants', config('bigbluebutton.create.maxParticipants', 0))); |
38
|
|
|
$meetingParams->setLogoutUrl($request->get('logoutUrl', config('bigbluebutton.create.logoutUrl', null))); |
39
|
|
|
$meetingParams->setWelcomeMessage( |
40
|
|
|
$request->get('welcomeMessage', config('bigbluebutton.create.welcomeMessage', null)) |
41
|
|
|
); |
42
|
|
|
$meetingParams->setDialNumber( |
43
|
|
|
$request->get('dialNumber', config('bigbluebutton.create.dialNumber', null)) |
44
|
|
|
); |
45
|
|
|
$meetingParams->setBreakout( |
46
|
|
|
$request->get('isBreakout', config('bigbluebutton.create.isBreakout', false)) |
47
|
|
|
); |
48
|
|
|
$meetingParams->setModeratorOnlyMessage( |
49
|
|
|
$request->get('moderatorOnlyMessage', config('bigbluebutton.create.moderatorOnlyMessage', null)) |
50
|
|
|
); |
51
|
|
|
$meetingParams->setAutoStartRecording( |
52
|
|
|
$request->get('autoStartRecording', config('bigbluebutton.create.autoStartRecording', false)) |
53
|
|
|
); |
54
|
|
|
$meetingParams->setAllowStartStopRecording( |
55
|
|
|
$request->get('allowStartStopRecording', config('bigbluebutton.create.allowStartStopRecording', true)) |
56
|
|
|
); |
57
|
|
|
$meetingParams->setWebcamsOnlyForModerator( |
58
|
|
|
$request->get('webcamsOnlyForModerator', config('bigbluebutton.create.webcamsOnlyForModerator', false)) |
59
|
|
|
); |
60
|
|
|
$meetingParams->setLogo( |
61
|
|
|
$request->get('logo', config('bigbluebutton.create.logo', null)) |
62
|
|
|
); |
63
|
|
|
$meetingParams->setCopyright( |
64
|
|
|
$request->get('copyright', config('bigbluebutton.create.copyright', null)) |
65
|
|
|
); |
66
|
|
|
$meetingParams->setMuteOnStart( |
67
|
|
|
$request->get('muteOnStart', config('bigbluebutton.create.muteOnStart', false)) |
68
|
|
|
); |
69
|
|
|
|
70
|
|
|
$meetingParams->setLockSettingsDisableCam( |
71
|
|
|
$request->get('lockSettingsDisableCam', config('bigbluebutton.create.lockSettingsDisableCam', false)) |
72
|
|
|
); |
73
|
|
|
$meetingParams->setLockSettingsDisableMic( |
74
|
|
|
$request->get('lockSettingsDisableMic', config('bigbluebutton.create.lockSettingsDisableMic', false)) |
75
|
|
|
); |
76
|
|
|
$meetingParams->setLockSettingsDisablePrivateChat( |
77
|
|
|
$request->get('lockSettingsDisablePrivateChat', config('bigbluebutton.create.lockSettingsDisablePrivateChat', false)) |
78
|
|
|
); |
79
|
|
|
$meetingParams->setLockSettingsDisablePublicChat( |
80
|
|
|
$request->get('lockSettingsDisablePublicChat', config('bigbluebutton.create.lockSettingsDisablePublicChat', false)) |
81
|
|
|
); |
82
|
|
|
$meetingParams->setLockSettingsDisableNote( |
83
|
|
|
$request->get('lockSettingsDisableNote', config('bigbluebutton.create.lockSettingsDisableNote', false)) |
84
|
|
|
); |
85
|
|
|
$meetingParams->setLockSettingsLockedLayout( |
86
|
|
|
$request->get('lockSettingsLockedLayout', config('bigbluebutton.create.lockSettingsLockedLayout', false)) |
87
|
|
|
); |
88
|
|
|
$meetingParams->setLockSettingsLockOnJoin( |
89
|
|
|
$request->get('lockSettingsLockOnJoin', config('bigbluebutton.create.lockSettingsLockOnJoin', false)) |
90
|
|
|
); |
91
|
|
|
$meetingParams->setLockSettingsLockOnJoinConfigurable( |
92
|
|
|
$request->get('lockSettingsLockOnJoinConfigurable', config('bigbluebutton.create.lockSettingsLockOnJoinConfigurable', false)) |
93
|
|
|
); |
94
|
|
|
|
95
|
|
|
if (!is_null($request->get('endCallbackUrl', null))) { |
96
|
|
|
$meetingParams->setEndCallbackUrl($request->get('endCallbackUrl', null)); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
if (!is_null($request->get('bbb-recording-ready-url', null))) { |
100
|
|
|
$meetingParams->setRecordingReadyCallbackUrl($request->get('bbb-recording-ready-url', null)); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
$meetingParams->setFreeJoin($request->get('freeJoin', false)); |
104
|
|
|
|
105
|
|
|
$presentation = (array)$request->get('presentation', null); |
106
|
|
|
foreach ($presentation as $item) { |
107
|
|
|
if (isset($item['fileName']) && !empty($item['fileName'])) { |
108
|
|
|
if (isset($item['link']) && !empty($item['link'])) { |
109
|
|
|
$meetingParams->addPresentation(trim($item['link']), null, trim($item['fileName'])); |
110
|
|
|
} elseif (isset($item['content']) && !empty($item['content'])) { |
111
|
|
|
$meetingParams->addPresentation(trim($item['fileName']), trim($item['content']), null); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
$meta = (array)$request->get('meta', null); |
117
|
|
|
foreach ($meta as $key => $value) { |
118
|
|
|
$meetingParams->addMeta(trim($key), trim($value)); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
return $meetingParams; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/* |
125
|
|
|
* required fields: |
126
|
|
|
* meetingID |
127
|
|
|
* moderatorPW close meeting must be there moderator password |
128
|
|
|
*/ |
129
|
|
|
public function initCloseMeeting(array $parameters) |
130
|
|
|
{ |
131
|
|
|
$request = Fluent($parameters); |
132
|
|
|
|
133
|
|
|
return (new EndMeetingParameters($request->meetingID, $request->moderatorPW)); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/* |
137
|
|
|
* required fields |
138
|
|
|
* |
139
|
|
|
* meetingID |
140
|
|
|
* userName join by name |
141
|
|
|
* password which role want to join |
142
|
|
|
*/ |
143
|
|
|
public function initJoinMeeting(array $parameters) |
144
|
|
|
{ |
145
|
|
|
$request = Fluent($parameters); |
146
|
|
|
$meetingParams = new JoinMeetingParameters($request->meetingID, $request->userName, $request->password); |
147
|
|
|
$meetingParams->setRedirect($request->get('redirect', config('bigbluebutton.join.redirect', true))); |
148
|
|
|
$meetingParams->setJoinViaHtml5($request->get('joinViaHtml5', config('bigbluebutton.join.joinViaHtml5', true))); |
149
|
|
|
$meetingParams->setUserId($request->get('userId', null)); |
150
|
|
|
if ($request->createTime) { |
151
|
|
|
$meetingParams->setCreationTime($request->createTime); |
152
|
|
|
} |
153
|
|
|
if ($request->configToken) { |
154
|
|
|
$meetingParams->setConfigToken($request->configToken); |
155
|
|
|
} |
156
|
|
|
if ($request->webVoiceConf) { |
157
|
|
|
$meetingParams->setWebVoiceConf($request->webVoiceConf); |
158
|
|
|
} |
159
|
|
|
if ($request->avatarUrl) { |
160
|
|
|
$meetingParams->setAvatarURL($request->avatarUrl); |
161
|
|
|
} |
162
|
|
|
if ($request->clientUrl) { |
163
|
|
|
$meetingParams->setClientURL($request->clientUrl); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
return $meetingParams; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/* |
170
|
|
|
* required fields |
171
|
|
|
* meetingID |
172
|
|
|
*/ |
173
|
|
|
public function initIsMeetingRunning(array $parameters) |
174
|
|
|
{ |
175
|
|
|
$meetingID = ""; |
|
|
|
|
176
|
|
|
if (!is_array($parameters)) { |
177
|
|
|
$meetingID = $parameters; |
178
|
|
|
} else { |
179
|
|
|
$meetingID = Fluent($parameters)->get('meetingID'); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
return (new IsMeetingRunningParameters($meetingID)); |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/* |
186
|
|
|
* required fields |
187
|
|
|
* meetingID |
188
|
|
|
* moderatorPW must be there moderator password |
189
|
|
|
*/ |
190
|
|
|
public function initGetMeetingInfo($parameters) |
191
|
|
|
{ |
192
|
|
|
$request = Fluent($parameters); |
193
|
|
|
|
194
|
|
|
return (new GetMeetingInfoParameters($request->meetingID, $request->moderatorPW)); |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/* |
198
|
|
|
* |
199
|
|
|
* optional fields |
200
|
|
|
* meetingID |
201
|
|
|
* recordID |
202
|
|
|
* state |
203
|
|
|
*/ |
204
|
|
|
public function initGetRecordings(array $parameters) |
205
|
|
|
{ |
206
|
|
|
$request = Fluent($parameters); |
207
|
|
|
$recordings = new GetRecordingsParameters(); |
208
|
|
|
|
209
|
|
|
$recordings->setMeetingId(implode(',', (array)$request->get('meetingID'))); |
210
|
|
|
$recordings->setRecordId(implode(',', (array)$request->get('recordID'))); |
211
|
|
|
$recordings->setState($request->get('state', config('bigbluebutton.getRecordings.state'))); |
212
|
|
|
|
213
|
|
|
return $recordings; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @param array $parameters |
218
|
|
|
* |
219
|
|
|
* @return PublishRecordingsParameters |
220
|
|
|
*/ |
221
|
|
|
public function initPublishRecordings(array $parameters) |
222
|
|
|
{ |
223
|
|
|
$request = Fluent($parameters); |
224
|
|
|
$recordings = new PublishRecordingsParameters(null, $request->get('publish', true)); |
225
|
|
|
$recordings->setRecordingId(implode(',', (array)$request->get('recordID'))); |
226
|
|
|
|
227
|
|
|
return $recordings; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/* |
231
|
|
|
* required fields |
232
|
|
|
* recordingID |
233
|
|
|
*/ |
234
|
|
|
public function initDeleteRecordings($recording) |
235
|
|
|
{ |
236
|
|
|
$request = Fluent($recording); |
237
|
|
|
|
238
|
|
|
return (new DeleteRecordingsParameters(implode(',', (array)$request->get('recordID')))); |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
private function makeJoinMeetingArray($object, $parameters) |
242
|
|
|
{ |
243
|
|
|
$pass['meetingID'] = $object->get('meetingID'); |
|
|
|
|
244
|
|
|
$pass['password'] = $object->get('moderatorPW'); |
245
|
|
|
if (isset($parameters['userName'])) { |
246
|
|
|
$pass['userName'] = $parameters['userName']; |
247
|
|
|
} |
248
|
|
|
$pass['meetingName'] = $object->get('meetingName'); |
249
|
|
|
if (isset($parameters['redirect'])) { |
250
|
|
|
$pass['redirect'] = $parameters['redirect']; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
return $pass; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/* |
257
|
|
|
* required fields |
258
|
|
|
* meetingID |
259
|
|
|
* meetingName |
260
|
|
|
* userName |
261
|
|
|
* attendeePW |
262
|
|
|
* moderatorPW |
263
|
|
|
* redirect |
264
|
|
|
*/ |
265
|
|
|
public function initStart(array $parameters) |
266
|
|
|
{ |
267
|
|
|
if ($this->getMeetingInfo($parameters)->isEmpty()) { |
|
|
|
|
268
|
|
|
$object = $this->create($parameters); |
|
|
|
|
269
|
|
|
if (method_exists($object, 'isEmpty') && !$object->isEmpty()) { |
270
|
|
|
return $this->join($this->makeJoinMeetingArray($object, $parameters)); |
|
|
|
|
271
|
|
|
} |
272
|
|
|
} else { |
273
|
|
|
if (isset($parameters['moderatorPW'])) { |
274
|
|
|
$parameters['password'] = trim($parameters['moderatorPW']); |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
return $this->join($parameters); |
|
|
|
|
278
|
|
|
} |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
/** |
282
|
|
|
* @param $parameters |
283
|
|
|
* |
284
|
|
|
* @return SetConfigXMLParameters |
285
|
|
|
*/ |
286
|
|
|
public function initSetConfigXml(array $parameters) |
287
|
|
|
{ |
288
|
|
|
$parameters = Fluent($parameters); |
289
|
|
|
$configXml = new SetConfigXMLParameters($parameters->get('meetingID')); |
290
|
|
|
$rawXml = $parameters->xml; |
291
|
|
|
if (!$parameters->xml instanceof \SimpleXMLElement) { |
292
|
|
|
$rawXml = new \SimpleXMLElement($parameters->xml); |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
$configXml->setRawXml($rawXml); |
296
|
|
|
|
297
|
|
|
return $configXml; |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
/** |
301
|
|
|
* @param array $parameters |
302
|
|
|
* |
303
|
|
|
* @return HooksCreateParameters |
304
|
|
|
*/ |
305
|
|
|
public function initHooksCreate(array $parameters) |
306
|
|
|
{ |
307
|
|
|
$parameters = Fluent($parameters); |
308
|
|
|
$hooksCreate = new HooksCreateParameters($parameters->get('callbackURL')); |
309
|
|
|
if ($parameters->meetingID) { |
310
|
|
|
$hooksCreate->setMeetingId($parameters->meetingID); |
311
|
|
|
} |
312
|
|
|
$hooksCreate->setGetRaw($parameters->get('getRaw', false)); |
313
|
|
|
|
314
|
|
|
return $hooksCreate; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
/** |
318
|
|
|
* @param array $parameters |
319
|
|
|
* |
320
|
|
|
* @return HooksDestroyParameters |
321
|
|
|
*/ |
322
|
|
|
public function initHooksDestroy(array $parameters) |
323
|
|
|
{ |
324
|
|
|
$parameters = Fluent($parameters); |
325
|
|
|
$hooksDestroy = new HooksDestroyParameters($parameters->get('hooksID')); |
326
|
|
|
|
327
|
|
|
return $hooksDestroy; |
328
|
|
|
} |
329
|
|
|
|
330
|
|
|
/** |
331
|
|
|
* Check if connection to api can be established with the end point url and secret |
332
|
|
|
* @return array connection successful |
333
|
|
|
*/ |
334
|
|
|
private function initIsConnect() |
335
|
|
|
{ |
336
|
|
|
if (!filter_var(config('bigbluebutton.BBB_SERVER_BASE_URL'), FILTER_VALIDATE_URL)) { |
337
|
|
|
return [ |
338
|
|
|
'flag' => false, |
339
|
|
|
'message' => 'invalid url' |
340
|
|
|
]; |
341
|
|
|
} |
342
|
|
|
|
343
|
|
|
try { |
344
|
|
|
$response = $this->bbb->isMeetingRunning( |
|
|
|
|
345
|
|
|
new IsMeetingRunningParameters('connection_check') |
346
|
|
|
); |
347
|
|
|
|
348
|
|
|
// url and secret working |
349
|
|
|
if ($response->success()) { |
350
|
|
|
return ['flag' => true]; |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
// Checksum error - invalid secret |
354
|
|
|
if ($response->failed() && $response->getMessageKey() == "checksumError") { |
355
|
|
|
return [ |
356
|
|
|
'flag' => false, |
357
|
|
|
'message' => 'invalid secret key' |
358
|
|
|
]; |
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
// HTTP exception or XML parse |
362
|
|
|
} catch (\Exception $e) { |
363
|
|
|
return [ |
364
|
|
|
'flag' => false, |
365
|
|
|
'message' => 'invalid url and secret key' |
366
|
|
|
]; |
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
return [ |
370
|
|
|
'flag' => false, |
371
|
|
|
'message' => 'invalid url' |
372
|
|
|
]; |
373
|
|
|
} |
374
|
|
|
} |
375
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.