Completed
Push — master ( 8a8c3f...f64ce8 )
by Ghazi
02:29
created

CreateMeetingParameters::setParentMeetingId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
4
 *
5
 * Copyright (c) 2016-2018 BigBlueButton Inc. and by respective authors (see below).
6
 *
7
 * This program is free software; you can redistribute it and/or modify it under the
8
 * terms of the GNU Lesser General Public License as published by the Free Software
9
 * Foundation; either version 3.0 of the License, or (at your option) any later
10
 * version.
11
 *
12
 * BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
13
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public License along
17
 * with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
18
 */
19
namespace BigBlueButton\Parameters;
20
21
/**
22
 * Class CreateMeetingParameters.
23
 */
24
class CreateMeetingParameters extends MetaParameters
25
{
26
    /**
27
     * @var string
28
     */
29
    private $meetingId;
30
31
    /**
32
     * @var string
33
     */
34
    private $meetingName;
35
36
    /**
37
     * @var string
38
     */
39
    private $attendeePassword;
40
41
    /**
42
     * @var string
43
     */
44
    private $moderatorPassword;
45
46
    /**
47
     * @var string
48
     */
49
    private $dialNumber;
50
51
    /**
52
     * @var int
53
     */
54
    private $voiceBridge;
55
56
    /**
57
     * @var string
58
     */
59
    private $webVoice;
60
61
    /**
62
     * @var string
63
     */
64
    private $logoutUrl;
65
66
    /**
67
     * @var int
68
     */
69
    private $maxParticipants;
70
71
    /**
72
     * @var bool
73
     */
74
    private $record;
75
76
    /**
77
     * @var bool
78
     */
79
    private $autoStartRecording;
80
81
    /**
82
     * @var bool
83
     */
84
    private $allowStartStopRecording;
85
86
    /**
87
     * @var int
88
     */
89
    private $duration;
90
91
    /**
92
     * @var string
93
     */
94
    private $welcomeMessage;
95
96
    /**
97
     * @var string
98
     */
99
    private $moderatorOnlyMessage;
100
101
    /**
102
     * @var bool
103
     */
104
    private $webcamsOnlyForModerator;
105
106
    /**
107
     * @var string
108
     */
109
    private $logo;
110
111
    /**
112
     * @var string
113
     */
114
    private $copyright;
115
116
    /**
117
     * @var bool
118
     */
119
    private $muteOnStart;
120
121
    /**
122
     * @var array
123
     */
124
    private $presentations = [];
125
126
    /**
127
     * @var boolean
128
     */
129
    private $isBreakout;
130
131
    /**
132
     * @var string
133
     */
134
    private $parentMeetingId;
135
136
    /**
137
     * @var int
138
     */
139
    private $sequence;
140
141
    /**
142
     * @var boolean
143
     */
144
    private $freeJoin;
145
146
    /**
147
     * CreateMeetingParameters constructor.
148
     *
149
     * @param $meetingId
150
     * @param $meetingName
151
     */
152
    public function __construct($meetingId, $meetingName)
153
    {
154
        $this->meetingId   = $meetingId;
155
        $this->meetingName = $meetingName;
156
    }
157
158
    /**
159
     * @return string
160
     */
161
    public function getMeetingId()
162
    {
163
        return $this->meetingId;
164
    }
165
166
    /**
167
     * @param string $meetingId
168
     *
169
     * @return CreateMeetingParameters
170
     */
171
    public function setMeetingId($meetingId)
172
    {
173
        $this->meetingId = $meetingId;
174
175
        return $this;
176
    }
177
178
    /**
179
     * @return string
180
     */
181
    public function getMeetingName()
182
    {
183
        return $this->meetingName;
184
    }
185
186
    /**
187
     * @param string $meetingName
188
     *
189
     * @return CreateMeetingParameters
190
     */
191
    public function setMeetingName($meetingName)
192
    {
193
        $this->meetingName = $meetingName;
194
195
        return $this;
196
    }
197
198
    /**
199
     * @return string
200
     */
201
    public function getAttendeePassword()
202
    {
203
        return $this->attendeePassword;
204
    }
205
206
    /**
207
     * @param string $attendeePassword
208
     *
209
     * @return CreateMeetingParameters
210
     */
211
    public function setAttendeePassword($attendeePassword)
212
    {
213
        $this->attendeePassword = $attendeePassword;
214
215
        return $this;
216
    }
217
218
    /**
219
     * @return string
220
     */
221
    public function getModeratorPassword()
222
    {
223
        return $this->moderatorPassword;
224
    }
225
226
    /**
227
     * @param string $moderatorPassword
228
     *
229
     * @return CreateMeetingParameters
230
     */
231
    public function setModeratorPassword($moderatorPassword)
232
    {
233
        $this->moderatorPassword = $moderatorPassword;
234
235
        return $this;
236
    }
237
238
    /**
239
     * @return string
240
     */
241
    public function getDialNumber()
242
    {
243
        return $this->dialNumber;
244
    }
245
246
    /**
247
     * @param string $dialNumber
248
     *
249
     * @return CreateMeetingParameters
250
     */
251
    public function setDialNumber($dialNumber)
252
    {
253
        $this->dialNumber = $dialNumber;
254
255
        return $this;
256
    }
257
258
    /**
259
     * @return int
260
     */
261
    public function getVoiceBridge()
262
    {
263
        return $this->voiceBridge;
264
    }
265
266
    /**
267
     * @param int $voiceBridge
268
     *
269
     * @return CreateMeetingParameters
270
     */
271
    public function setVoiceBridge($voiceBridge)
272
    {
273
        $this->voiceBridge = $voiceBridge;
274
275
        return $this;
276
    }
277
278
    /**
279
     * @return string
280
     */
281
    public function getWebVoice()
282
    {
283
        return $this->webVoice;
284
    }
285
286
    /**
287
     * @param string $webVoice
288
     *
289
     * @return CreateMeetingParameters
290
     */
291
    public function setWebVoice($webVoice)
292
    {
293
        $this->webVoice = $webVoice;
294
295
        return $this;
296
    }
297
298
    /**
299
     * @return string
300
     */
301
    public function getLogoutUrl()
302
    {
303
        return $this->logoutUrl;
304
    }
305
306
    /**
307
     * @param string $logoutUrl
308
     *
309
     * @return CreateMeetingParameters
310
     */
311
    public function setLogoutUrl($logoutUrl)
312
    {
313
        $this->logoutUrl = $logoutUrl;
314
315
        return $this;
316
    }
317
318
    /**
319
     * @return int
320
     */
321
    public function getMaxParticipants()
322
    {
323
        return $this->maxParticipants;
324
    }
325
326
    /**
327
     * @param int $maxParticipants
328
     *
329
     * @return CreateMeetingParameters
330
     */
331
    public function setMaxParticipants($maxParticipants)
332
    {
333
        $this->maxParticipants = $maxParticipants;
334
335
        return $this;
336
    }
337
338
    /**
339
     * @return bool
340
     */
341
    public function isRecorded()
342
    {
343
        return $this->record;
344
    }
345
346
    /**
347
     * @param bool $record
348
     *
349
     * @return CreateMeetingParameters
350
     */
351
    public function setRecord($record)
352
    {
353
        $this->record = $record;
354
355
        return $this;
356
    }
357
358
    /**
359
     * @return bool
360
     */
361
    public function isAutoStartRecording()
362
    {
363
        return $this->autoStartRecording;
364
    }
365
366
    /**
367
     * @param bool $autoStartRecording
368
     *
369
     * @return CreateMeetingParameters
370
     */
371
    public function setAutoStartRecording($autoStartRecording)
372
    {
373
        $this->autoStartRecording = $autoStartRecording;
374
375
        return $this;
376
    }
377
378
    /**
379
     * @return bool
380
     */
381
    public function isAllowStartStopRecording()
382
    {
383
        return $this->allowStartStopRecording;
384
    }
385
386
    /**
387
     * @param bool $allowStartStopRecording
388
     *
389
     * @return CreateMeetingParameters
390
     */
391
    public function setAllowStartStopRecording($allowStartStopRecording)
392
    {
393
        $this->allowStartStopRecording = $allowStartStopRecording;
394
395
        return $this;
396
    }
397
398
    /**
399
     * @return int
400
     */
401
    public function getDuration()
402
    {
403
        return $this->duration;
404
    }
405
406
    /**
407
     * @param int $duration
408
     *
409
     * @return CreateMeetingParameters
410
     */
411
    public function setDuration($duration)
412
    {
413
        $this->duration = $duration;
414
415
        return $this;
416
    }
417
418
    /**
419
     * @return string
420
     */
421
    public function getWelcomeMessage()
422
    {
423
        return $this->welcomeMessage;
424
    }
425
426
    /**
427
     * @param string $welcomeMessage
428
     *
429
     * @return CreateMeetingParameters
430
     */
431
    public function setWelcomeMessage($welcomeMessage)
432
    {
433
        $this->welcomeMessage = $welcomeMessage;
434
435
        return $this;
436
    }
437
438
    /**
439
     * @return string
440
     */
441
    public function getModeratorOnlyMessage()
442
    {
443
        return $this->moderatorOnlyMessage;
444
    }
445
446
    /**
447
     * @param string $message
448
     *
449
     * @return CreateMeetingParameters
450
     */
451
    public function setModeratorOnlyMessage($message)
452
    {
453
        $this->moderatorOnlyMessage = $message;
454
455
        return $this;
456
    }
457
458
    /**
459
     * @return bool
460
     */
461
    public function isWebcamsOnlyForModerator()
462
    {
463
        return $this->webcamsOnlyForModerator;
464
    }
465
466
    /**
467
     * @param  bool                    $webcamsOnlyForModerator
468
     * @return CreateMeetingParameters
469
     */
470
    public function setWebcamsOnlyForModerator($webcamsOnlyForModerator)
471
    {
472
        $this->webcamsOnlyForModerator = $webcamsOnlyForModerator;
473
474
        return $this;
475
    }
476
477
    /**
478
     * @return string
479
     */
480
    public function getLogo()
481
    {
482
        return $this->logo;
483
    }
484
485
    /**
486
     * @param  string                  $logo
487
     * @return CreateMeetingParameters
488
     */
489
    public function setLogo($logo)
490
    {
491
        $this->logo = $logo;
492
493
        return $this;
494
    }
495
496
    /**
497
     * @return string
498
     */
499
    public function getCopyright()
500
    {
501
        return $this->copyright;
502
    }
503
504
    /**
505
     * @param  string                  $copyright
506
     * @return CreateMeetingParameters
507
     */
508
    public function setCopyright($copyright)
509
    {
510
        $this->copyright = $copyright;
511
512
        return $this;
513
    }
514
515
    /**
516
     * @return bool
517
     */
518
    public function isMuteOnStart()
519
    {
520
        return $this->muteOnStart;
521
    }
522
523
    /**
524
     * @param  bool                    $muteOnStart
525
     * @return CreateMeetingParameters
526
     */
527
    public function setMuteOnStart($muteOnStart)
528
    {
529
        $this->muteOnStart = $muteOnStart;
530
531
        return $this;
532
    }
533
534
    /**
535
     * @param $endCallbackUrl
536
     * @return CreateMeetingParameters
537
     */
538
    public function setEndCallbackUrl($endCallbackUrl)
539
    {
540
        $this->addMeta('endCallbackUrl', $endCallbackUrl);
541
542
        return $this;
543
    }
544
545
    /**
546
     * @return bool
547
     */
548
    public function isBreakout()
549
    {
550
        return $this->isBreakout;
551
    }
552
553
    /**
554
     * @param  bool                    $isBreakout
555
     * @return CreateMeetingParameters
556
     */
557
    public function setBreakout($isBreakout)
558
    {
559
        $this->isBreakout = $isBreakout;
560
561
        return $this;
562
    }
563
564
    /**
565
     * @return string
566
     */
567
    public function getParentMeetingId()
568
    {
569
        return $this->parentMeetingId;
570
    }
571
572
    /**
573
     * @param  string                  $parentMeetingId
574
     * @return CreateMeetingParameters
575
     */
576
    public function setParentMeetingId($parentMeetingId)
577
    {
578
        $this->parentMeetingId = $parentMeetingId;
579
580
        return $this;
581
    }
582
583
    /**
584
     * @return int
585
     */
586
    public function getSequence()
587
    {
588
        return $this->sequence;
589
    }
590
591
    /**
592
     * @param  int                     $sequence
593
     * @return CreateMeetingParameters
594
     */
595
    public function setSequence($sequence)
596
    {
597
        $this->sequence = $sequence;
598
599
        return $this;
600
    }
601
602
    /**
603
     * @return bool
604
     */
605
    public function isFreeJoin()
606
    {
607
        return $this->freeJoin;
608
    }
609
610
    /**
611
     * @param  bool                    $freeJoin
612
     * @return CreateMeetingParameters
613
     */
614
    public function setFreeJoin($freeJoin)
615
    {
616
        $this->freeJoin = $freeJoin;
617
618
        return $this;
619
    }
620
621
    /**
622
     * @return array
623
     */
624
    public function getPresentations()
625
    {
626
        return $this->presentations;
627
    }
628
629
    /**
630
     * @param $nameOrUrl
631
     * @param null $content
632
     * @param null $filename
633
     *
634
     * @return CreateMeetingParameters
635
     */
636
    public function addPresentation($nameOrUrl, $content = null, $filename = null)
637
    {
638
        if (!$filename) {
639
            $this->presentations[$nameOrUrl] = !$content ?: base64_encode($content);
640
        } else {
641
            $this->presentations[$nameOrUrl] = $filename;
642
        }
643
644
        return $this;
645
    }
646
647
    /**
648
     * @return mixed
649
     */
650
    public function getPresentationsAsXML()
651
    {
652
        $result = '';
653
654
        if (!empty($this->presentations)) {
655
            $xml    = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><modules/>');
656
            $module = $xml->addChild('module');
657
            $module->addAttribute('name', 'presentation');
658
659
            foreach ($this->presentations as $nameOrUrl => $content) {
660
                if (strpos($nameOrUrl, 'http') === 0) {
661
                    $presentation = $module->addChild('document');
662
                    $presentation->addAttribute('url', $nameOrUrl);
663
                    if (is_string($content)) {
664
                        $presentation->addAttribute('filename', $content);
665
                    }
666
                } else {
667
                    $document = $module->addChild('document');
668
                    $document->addAttribute('name', $nameOrUrl);
669
                    $document[0] = $content;
670
                }
671
            }
672
            $result = $xml->asXML();
673
        }
674
675
        return $result;
676
    }
677
678
    /**
679
     * @return string
680
     */
681
    public function getHTTPQuery()
682
    {
683
        $queries = [
684
            'name'                    => $this->meetingName,
685
            'meetingID'               => $this->meetingId,
686
            'attendeePW'              => $this->attendeePassword,
687
            'moderatorPW'             => $this->moderatorPassword,
688
            'dialNumber'              => $this->dialNumber,
689
            'voiceBridge'             => $this->voiceBridge,
690
            'webVoice'                => $this->webVoice,
691
            'logoutURL'               => $this->logoutUrl,
692
            'record'                  => $this->record ? 'true' : 'false',
693
            'duration'                => $this->duration,
694
            'maxParticipants'         => $this->maxParticipants,
695
            'autoStartRecording'      => $this->autoStartRecording ? 'true' : 'false',
696
            'allowStartStopRecording' => $this->allowStartStopRecording ? 'true' : 'false',
697
            'welcome'                 => trim($this->welcomeMessage),
698
            'moderatorOnlyMessage'    => trim($this->moderatorOnlyMessage),
699
            'webcamsOnlyForModerator' => $this->webcamsOnlyForModerator ? 'true' : 'false',
700
            'logo'                    => $this->logo,
701
            'copyright'               => $this->copyright,
702
            'muteOnStart'             => $this->muteOnStart,
703
        ];
704
705
        // Add breakout rooms parameters only if the meeting is a breakout room
706
        if ($this->isBreakout()) {
707
            $queries = array_merge($queries, [
708
                'isBreakout'      => $this->isBreakout ? 'true' : 'false',
709
                'parentMeetingID' => $this->parentMeetingId,
710
                'sequence'        => $this->sequence,
711
                'freeJoin'        => $this->freeJoin ? 'true' : 'false'
712
            ]);
713
        }
714
715
        $this->buildMeta($queries);
716
717
        return $this->buildHTTPQuery($queries);
718
    }
719
}
720