Completed
Push — master ( 9d9aa3...aeab87 )
by Ghazi
04:57
created

CreateMeetingParameters::getMeta()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
4
 *
5
 * Copyright (c) 2016 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 BaseParameters
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 array
103
     */
104
    private $meta = [];
105
106
    /**
107
     * @var array
108
     */
109
    private $presentations = [];
110
111
    /**
112
     * CreateMeetingParameters constructor.
113
     *
114
     * @param $meetingId
115
     * @param $meetingName
116
     */
117
    public function __construct($meetingId, $meetingName)
118
    {
119
        $this->meetingId   = $meetingId;
120
        $this->meetingName = $meetingName;
121
    }
122
123
    /**
124
     * @return string
125
     */
126
    public function getMeetingId()
127
    {
128
        return $this->meetingId;
129
    }
130
131
    /**
132
     * @param string $meetingId
133
     *
134
     * @return CreateMeetingParameters
135
     */
136
    public function setMeetingId($meetingId)
137
    {
138
        $this->meetingId = $meetingId;
139
140
        return $this;
141
    }
142
143
    /**
144
     * @return string
145
     */
146
    public function getMeetingName()
147
    {
148
        return $this->meetingName;
149
    }
150
151
    /**
152
     * @param string $meetingName
153
     *
154
     * @return CreateMeetingParameters
155
     */
156
    public function setMeetingName($meetingName)
157
    {
158
        $this->meetingName = $meetingName;
159
160
        return $this;
161
    }
162
163
    /**
164
     * @return string
165
     */
166
    public function getAttendeePassword()
167
    {
168
        return $this->attendeePassword;
169
    }
170
171
    /**
172
     * @param string $attendeePassword
173
     *
174
     * @return CreateMeetingParameters
175
     */
176
    public function setAttendeePassword($attendeePassword)
177
    {
178
        $this->attendeePassword = $attendeePassword;
179
180
        return $this;
181
    }
182
183
    /**
184
     * @return string
185
     */
186
    public function getModeratorPassword()
187
    {
188
        return $this->moderatorPassword;
189
    }
190
191
    /**
192
     * @param string $moderatorPassword
193
     *
194
     * @return CreateMeetingParameters
195
     */
196
    public function setModeratorPassword($moderatorPassword)
197
    {
198
        $this->moderatorPassword = $moderatorPassword;
199
200
        return $this;
201
    }
202
203
    /**
204
     * @return string
205
     */
206
    public function getDialNumber()
207
    {
208
        return $this->dialNumber;
209
    }
210
211
    /**
212
     * @param string $dialNumber
213
     *
214
     * @return CreateMeetingParameters
215
     */
216
    public function setDialNumber($dialNumber)
217
    {
218
        $this->dialNumber = $dialNumber;
219
220
        return $this;
221
    }
222
223
    /**
224
     * @return int
225
     */
226
    public function getVoiceBridge()
227
    {
228
        return $this->voiceBridge;
229
    }
230
231
    /**
232
     * @param int $voiceBridge
233
     *
234
     * @return CreateMeetingParameters
235
     */
236
    public function setVoiceBridge($voiceBridge)
237
    {
238
        $this->voiceBridge = $voiceBridge;
239
240
        return $this;
241
    }
242
243
    /**
244
     * @return string
245
     */
246
    public function getWebVoice()
247
    {
248
        return $this->webVoice;
249
    }
250
251
    /**
252
     * @param string $webVoice
253
     *
254
     * @return CreateMeetingParameters
255
     */
256
    public function setWebVoice($webVoice)
257
    {
258
        $this->webVoice = $webVoice;
259
260
        return $this;
261
    }
262
263
    /**
264
     * @return string
265
     */
266
    public function getLogoutUrl()
267
    {
268
        return $this->logoutUrl;
269
    }
270
271
    /**
272
     * @param string $logoutUrl
273
     *
274
     * @return CreateMeetingParameters
275
     */
276
    public function setLogoutUrl($logoutUrl)
277
    {
278
        $this->logoutUrl = $logoutUrl;
279
280
        return $this;
281
    }
282
283
    /**
284
     * @return int
285
     */
286
    public function getMaxParticipants()
287
    {
288
        return $this->maxParticipants;
289
    }
290
291
    /**
292
     * @param int $maxParticipants
293
     *
294
     * @return CreateMeetingParameters
295
     */
296
    public function setMaxParticipants($maxParticipants)
297
    {
298
        $this->maxParticipants = $maxParticipants;
299
300
        return $this;
301
    }
302
303
    /**
304
     * @return bool
305
     */
306
    public function isRecorded()
307
    {
308
        return $this->record;
309
    }
310
311
    /**
312
     * @param bool $record
313
     *
314
     * @return CreateMeetingParameters
315
     */
316
    public function setRecord($record)
317
    {
318
        $this->record = $record;
319
320
        return $this;
321
    }
322
323
    /**
324
     * @return bool
325
     */
326
    public function isAutoStartRecording()
327
    {
328
        return $this->autoStartRecording;
329
    }
330
331
    /**
332
     * @param bool $autoStartRecording
333
     *
334
     * @return CreateMeetingParameters
335
     */
336
    public function setAutoStartRecording($autoStartRecording)
337
    {
338
        $this->autoStartRecording = $autoStartRecording;
339
340
        return $this;
341
    }
342
343
    /**
344
     * @return bool
345
     */
346
    public function isAllowStartStopRecording()
347
    {
348
        return $this->allowStartStopRecording;
349
    }
350
351
    /**
352
     * @param bool $autoStartRecording
353
     *
354
     * @return CreateMeetingParameters
355
     */
356
    public function setAllowStartStopRecording($autoStartRecording)
357
    {
358
        $this->allowStartStopRecording = $autoStartRecording;
359
360
        return $this;
361
    }
362
363
    /**
364
     * @return int
365
     */
366
    public function getDuration()
367
    {
368
        return $this->duration;
369
    }
370
371
    /**
372
     * @param int $duration
373
     *
374
     * @return CreateMeetingParameters
375
     */
376
    public function setDuration($duration)
377
    {
378
        $this->duration = $duration;
379
380
        return $this;
381
    }
382
383
    /**
384
     * @return string
385
     */
386
    public function getWelcomeMessage()
387
    {
388
        return $this->welcomeMessage;
389
    }
390
391
    /**
392
     * @param string $welcomeMessage
393
     *
394
     * @return CreateMeetingParameters
395
     */
396
    public function setWelcomeMessage($welcomeMessage)
397
    {
398
        $this->welcomeMessage = $welcomeMessage;
399
400
        return $this;
401
    }
402
403
    /**
404
     * @return string
405
     */
406
    public function getModeratorOnlyMessage()
407
    {
408
        return $this->moderatorOnlyMessage;
409
    }
410
411
    /**
412
     * @param string $message
413
     *
414
     * @return CreateMeetingParameters
415
     */
416
    public function setModeratorOnlyMessage($message)
417
    {
418
        $this->moderatorOnlyMessage = $message;
419
420
        return $this;
421
    }
422
423
    /**
424
     * @return string
425
     */
426
    public function getMeta($key)
427
    {
428
        return $this->meta[$key];
429
    }
430
431
    /**
432
     * @param string $key
433
     * @param string $value
434
     *
435
     * @return CreateMeetingParameters
436
     */
437
    public function setMeta($key, $value)
438
    {
439
        $this->meta[$key] = $value;
440
441
        return $this;
442
    }
443
444
    /**
445
     * @return array
446
     */
447
    public function getPresentations()
448
    {
449
        return $this->presentations;
450
    }
451
452
    /**
453
     * @param $nameOrUrl
454
     * @param null $content
455
     *
456
     * @return CreateMeetingParameters
457
     */
458
    public function addPresentation($nameOrUrl, $content = null)
459
    {
460
        $this->presentations[$nameOrUrl] = !$content ?: base64_encode($content);
461
462
        return $this;
463
    }
464
465
    public function getPresentationsAsXML()
466
    {
467
        $result = '';
468
        if (!empty($this->presentations)) {
469
            $xml     = new \SimpleXMLElement('<xml/>');
470
            $modules = $xml->addChild('modules');
471
            $module  = $modules->addChild('module');
472
            foreach ($this->presentations as $nameOrUrl => $content) {
473
                if (!$this->presentations[$nameOrUrl]) {
474
                    $module->addChild('document')->addAttribute('url', $nameOrUrl);
475
                } else {
476
                    $document = $module->addChild('document');
477
                    $document->addAttribute('name', $nameOrUrl);
478
                    $document[0] = $content;
479
                }
480
            }
481
            $result = $xml->asXML();
482
        }
483
484
        return $result;
485
    }
486
487
    /**
488
     * @return string
489
     */
490
    public function getHTTPQuery()
491
    {
492
        $queries = [
493
            'name'                    => $this->meetingName,
494
            'meetingID'               => $this->meetingId,
495
            'attendeePW'              => $this->attendeePassword,
496
            'moderatorPW'             => $this->moderatorPassword,
497
            'dialNumber'              => $this->dialNumber,
498
            'voiceBridge'             => $this->voiceBridge,
499
            'webVoice'                => $this->webVoice,
500
            'logoutURL'               => $this->logoutUrl,
501
            'record'                  => $this->record,
502
            'duration'                => $this->duration,
503
            'maxParticipants'         => $this->maxParticipants,
504
            'autoStartRecording'      => $this->autoStartRecording,
505
            'allowStartStopRecording' => $this->allowStartStopRecording,
506
            'welcome'                 => trim($this->welcomeMessage),
507
            'moderatorOnlyMessage'    => trim($this->moderatorOnlyMessage),
508
        ];
509
        if (!empty($this->meta)) {
510
            foreach ($this->meta as $k => $v) {
511
                $queries['meta_' . $k] = $v;
512
            }
513
        }
514
515
        return $this->buildHTTPQuery($queries);
516
    }
517
}
518