Completed
Push — master ( f5f512...82bae7 )
by Ghazi
02:28
created

CreateMeetingParameters::getPresentationsAsXML()   B

Complexity

Conditions 4
Paths 2

Size

Total Lines 22
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

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