Skip to content

Commit 9679f76

Browse files
committed
Add insertDocument API.
1 parent 29e8db8 commit 9679f76

File tree

7 files changed

+297
-62
lines changed

7 files changed

+297
-62
lines changed

src/BigBlueButton.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use BigBlueButton\Parameters\GetRecordingsParameters;
3030
use BigBlueButton\Parameters\HooksCreateParameters;
3131
use BigBlueButton\Parameters\HooksDestroyParameters;
32+
use BigBlueButton\Parameters\InsertDocumentParameters;
3233
use BigBlueButton\Parameters\IsMeetingRunningParameters;
3334
use BigBlueButton\Parameters\JoinMeetingParameters;
3435
use BigBlueButton\Parameters\PublishRecordingsParameters;
@@ -95,6 +96,7 @@ public function getApiVersion()
9596
-- create
9697
-- join
9798
-- end
99+
-- insertDocument
98100
*/
99101

100102
/**
@@ -169,6 +171,30 @@ public function endMeeting($endParams)
169171
return new EndMeetingResponse($xml);
170172
}
171173

174+
/**
175+
* @param CreateMeetingParameters $createMeetingParams
176+
*
177+
* @return string
178+
*/
179+
public function getInsertDocumentUrl($createMeetingParams)
180+
{
181+
return $this->urlBuilder->buildUrl(ApiMethod::INSERT_DOCUMENT, $createMeetingParams->getHTTPQuery());
182+
}
183+
184+
/**
185+
* @param InsertDocumentParameters $insertDocumentParams
186+
*
187+
* @throws \RuntimeException
188+
*
189+
* @return InsertDocumentResponse
190+
*/
191+
public function insertDocument($insertDocumentParams)
192+
{
193+
$xml = $this->processXmlResponse($this->getInsertDocumentUrl($insertDocumentParams), $insertDocumentParams->getPresentationsAsXML());
194+
195+
return new CreateMeetingResponse($xml);
196+
}
197+
172198
// __________________ BBB MONITORING METHODS _________________
173199
/* The methods in the following section support the following categories of the BBB API:
174200
-- isMeetingRunning

src/Parameters/CreateMeetingParameters.php

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*/
2626
class CreateMeetingParameters extends MetaParameters
2727
{
28+
use DocumentableTrait;
29+
2830
/**
2931
* @var string
3032
*/
@@ -189,11 +191,6 @@ class CreateMeetingParameters extends MetaParameters
189191
*/
190192
private $allowRequestsWithoutSession;
191193

192-
/**
193-
* @var array
194-
*/
195-
private $presentations = [];
196-
197194
/**
198195
* @var bool
199196
*/
@@ -1446,63 +1443,6 @@ public function addBreakoutRoomsGroup($id, $name, $roster)
14461443
return $this;
14471444
}
14481445

1449-
/**
1450-
* @return array
1451-
*/
1452-
public function getPresentations()
1453-
{
1454-
return $this->presentations;
1455-
}
1456-
1457-
/**
1458-
* @param $nameOrUrl
1459-
* @param null $content
1460-
* @param null $filename
1461-
*
1462-
* @return CreateMeetingParameters
1463-
*/
1464-
public function addPresentation($nameOrUrl, $content = null, $filename = null)
1465-
{
1466-
if (!$filename) {
1467-
$this->presentations[$nameOrUrl] = !$content ?: base64_encode($content);
1468-
} else {
1469-
$this->presentations[$nameOrUrl] = $filename;
1470-
}
1471-
1472-
return $this;
1473-
}
1474-
1475-
/**
1476-
* @return mixed
1477-
*/
1478-
public function getPresentationsAsXML()
1479-
{
1480-
$result = '';
1481-
1482-
if (!empty($this->presentations)) {
1483-
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><modules/>');
1484-
$module = $xml->addChild('module');
1485-
$module->addAttribute('name', 'presentation');
1486-
1487-
foreach ($this->presentations as $nameOrUrl => $content) {
1488-
if (0 === mb_strpos($nameOrUrl, 'http')) {
1489-
$presentation = $module->addChild('document');
1490-
$presentation->addAttribute('url', $nameOrUrl);
1491-
if (is_string($content)) {
1492-
$presentation->addAttribute('filename', $content);
1493-
}
1494-
} else {
1495-
$document = $module->addChild('document');
1496-
$document->addAttribute('name', $nameOrUrl);
1497-
$document[0] = $content;
1498-
}
1499-
}
1500-
$result = $xml->asXML();
1501-
}
1502-
1503-
return $result;
1504-
}
1505-
15061446
/**
15071447
* @return string
15081448
*/
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
3+
/*
4+
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
5+
*
6+
* Copyright (c) 2016-2022 BigBlueButton Inc. and by respective authors (see below).
7+
*
8+
* This program is free software; you can redistribute it and/or modify it under the
9+
* terms of the GNU Lesser General Public License as published by the Free Software
10+
* Foundation; either version 3.0 of the License, or (at your option) any later
11+
* version.
12+
*
13+
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
14+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15+
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public License along
18+
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
namespace BigBlueButton\Parameters;
22+
23+
trait DocumentableTrait
24+
{
25+
/**
26+
* @var array
27+
*/
28+
protected $presentations = [];
29+
30+
/**
31+
* @return array
32+
*/
33+
public function getPresentations()
34+
{
35+
return $this->presentations;
36+
}
37+
38+
/**
39+
* @param $nameOrUrl
40+
* @param null $content
41+
* @param null $filename
42+
*
43+
* @return $this
44+
*/
45+
public function addPresentation($nameOrUrl, $content = null, $filename = null)
46+
{
47+
if (!$filename) {
48+
$this->presentations[$nameOrUrl] = !$content ?: base64_encode($content);
49+
} else {
50+
$this->presentations[$nameOrUrl] = $filename;
51+
}
52+
53+
return $this;
54+
}
55+
56+
/**
57+
* @return mixed
58+
*/
59+
public function getPresentationsAsXML()
60+
{
61+
$result = '';
62+
63+
if (!empty($this->presentations)) {
64+
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><modules/>');
65+
$module = $xml->addChild('module');
66+
$module->addAttribute('name', 'presentation');
67+
68+
foreach ($this->presentations as $nameOrUrl => $content) {
69+
if (0 === mb_strpos($nameOrUrl, 'http')) {
70+
$presentation = $module->addChild('document');
71+
$presentation->addAttribute('url', $nameOrUrl);
72+
if (is_string($content)) {
73+
$presentation->addAttribute('filename', $content);
74+
}
75+
} else {
76+
$document = $module->addChild('document');
77+
$document->addAttribute('name', $nameOrUrl);
78+
$document[0] = $content;
79+
}
80+
}
81+
$result = $xml->asXML();
82+
}
83+
84+
return $result;
85+
}
86+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
3+
/*
4+
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
5+
*
6+
* Copyright (c) 2016-2022 BigBlueButton Inc. and by respective authors (see below).
7+
*
8+
* This program is free software; you can redistribute it and/or modify it under the
9+
* terms of the GNU Lesser General Public License as published by the Free Software
10+
* Foundation; either version 3.0 of the License, or (at your option) any later
11+
* version.
12+
*
13+
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
14+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15+
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public License along
18+
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
namespace BigBlueButton\Parameters;
22+
23+
/**
24+
* Class EndMeetingParameters.
25+
*/
26+
class InsertDocumentParameters extends BaseParameters
27+
{
28+
use DocumentableTrait;
29+
30+
/**
31+
* EndMeetingParameters constructor.
32+
*
33+
* @param string $meetingId
34+
* @param string $password
35+
*/
36+
public function __construct($meetingId, $password = '')
37+
{
38+
$this->password = $password;
39+
$this->meetingId = $meetingId;
40+
}
41+
42+
/**
43+
* @return string
44+
*/
45+
public function getMeetingId()
46+
{
47+
return $this->meetingId;
48+
}
49+
50+
/**
51+
* @param string $meetingId
52+
*
53+
* @return EndMeetingParameters
54+
*/
55+
public function setMeetingId($meetingId)
56+
{
57+
$this->meetingId = $meetingId;
58+
59+
return $this;
60+
}
61+
62+
/**
63+
* @deprecated
64+
*
65+
* @return string
66+
*/
67+
public function getPassword()
68+
{
69+
return $this->password;
70+
}
71+
72+
/**
73+
* @param string $password
74+
*
75+
* @deprecated
76+
*
77+
* @return EndMeetingParameters
78+
*/
79+
public function setPassword($password)
80+
{
81+
$this->password = $password;
82+
83+
return $this;
84+
}
85+
86+
/**
87+
* @return string
88+
*/
89+
public function getHTTPQuery()
90+
{
91+
return $this->buildHTTPQuery(
92+
[
93+
'meetingID' => $this->meetingId,
94+
'password' => $this->password,
95+
]
96+
);
97+
}
98+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/*
4+
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
5+
*
6+
* Copyright (c) 2016-2022 BigBlueButton Inc. and by respective authors (see below).
7+
*
8+
* This program is free software; you can redistribute it and/or modify it under the
9+
* terms of the GNU Lesser General Public License as published by the Free Software
10+
* Foundation; either version 3.0 of the License, or (at your option) any later
11+
* version.
12+
*
13+
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
14+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15+
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public License along
18+
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
namespace BigBlueButton\Responses;
22+
23+
class InsertDocumentResponse extends BaseResponse
24+
{
25+
}

0 commit comments

Comments
 (0)