Skip to content

Commit 5602817

Browse files
committed
Add filename parameter to file pre-uplaod.
1 parent b1b0842 commit 5602817

File tree

6 files changed

+68
-4
lines changed

6 files changed

+68
-4
lines changed

src/Parameters/CreateMeetingParameters.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,13 @@ public function getPresentations()
525525
*
526526
* @return CreateMeetingParameters
527527
*/
528-
public function addPresentation($nameOrUrl, $content = null)
528+
public function addPresentation($nameOrUrl, $content = null, $filname = null)
529529
{
530-
$this->presentations[$nameOrUrl] = !$content ?: base64_encode($content);
530+
if (!$filname) {
531+
$this->presentations[$nameOrUrl] = !$content ?: base64_encode($content);
532+
} else {
533+
$this->presentations[$nameOrUrl] = $filname;
534+
}
531535

532536
return $this;
533537
}
@@ -542,8 +546,12 @@ public function getPresentationsAsXML()
542546
$module->addAttribute('name', 'presentation');
543547

544548
foreach ($this->presentations as $nameOrUrl => $content) {
545-
if ($this->presentations[$nameOrUrl] === true) {
546-
$module->addChild('document')->addAttribute('url', $nameOrUrl);
549+
if (strpos($nameOrUrl, 'http') === 0) {
550+
$presentation = $module->addChild('document');
551+
$presentation->addAttribute('url', $nameOrUrl);
552+
if (is_string($content)) {
553+
$presentation->addAttribute('filename', $content);
554+
}
547555
} else {
548556
$document = $module->addChild('document');
549557
$document->addAttribute('name', $nameOrUrl);

tests/BigBlueButtonTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ public function testCreateMeetingWithDocumentUrl()
107107
$this->assertEquals('SUCCESS', $result->getReturnCode());
108108
}
109109

110+
/**
111+
* Test create meeting with a document URL and filename
112+
*/
113+
public function testCreateMeetingWithDocumentUrlAndFileName()
114+
{
115+
$params = $this->getCreateMock($this->generateCreateParams());
116+
$params->addPresentation('https://placeholdit.imgix.net/~text?txtsize=96&bg=30406B&txtclr=ffffff&txt=BigBlueButton&w=800&h=600', null, 'placeholder.png');
117+
118+
$result = $this->bbb->createMeeting($params);
119+
120+
$this->assertCount(1, $params->getPresentations());
121+
$this->assertEquals('SUCCESS', $result->getReturnCode());
122+
}
123+
110124
/**
111125
* Test create meeting with a document URL
112126
*/

tests/Parameters/CreateMeetingParametersTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,28 @@ public function testCreateMeetingParameters()
5858
$this->assertEquals($newName, $createMeetingParams->getMeetingName());
5959
$this->assertEquals($newId, $createMeetingParams->getMeetingId());
6060
}
61+
62+
public function testGetPresentationsAsXMLWithUrl()
63+
{
64+
$params = $this->generateCreateParams();
65+
$createMeetingParams = $this->getCreateMock($params);
66+
$createMeetingParams->addPresentation('http://test-install.blindsidenetworks.com/default.pdf');
67+
$this->assertXmlStringEqualsXmlFile(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'presentation_with_url.xml', $createMeetingParams->getPresentationsAsXML());
68+
}
69+
70+
public function testGetPresentationsAsXMLWithUrlAndFilename()
71+
{
72+
$params = $this->generateCreateParams();
73+
$createMeetingParams = $this->getCreateMock($params);
74+
$createMeetingParams->addPresentation('http://test-install.blindsidenetworks.com/default.pdf', null, 'presentation.pdf');
75+
$this->assertXmlStringEqualsXmlFile(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'presentation_with_filename.xml', $createMeetingParams->getPresentationsAsXML());
76+
}
77+
78+
public function testGetPresentationsAsXMLWithFile()
79+
{
80+
$params = $this->generateCreateParams();
81+
$createMeetingParams = $this->getCreateMock($params);
82+
$createMeetingParams->addPresentation('bbb_logo.png', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'bbb_logo.png'));
83+
$this->assertXmlStringEqualsXmlFile(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'presentation_with_embedded_file.xml', $createMeetingParams->getPresentationsAsXML());
84+
}
6185
}

tests/fixtures/presentation_with_embedded_file.xml

Lines changed: 6 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<modules>
3+
<module name="presentation">
4+
<document url="http://test-install.blindsidenetworks.com/default.pdf" filename="presentation.pdf"/>
5+
</module>
6+
</modules>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<modules>
3+
<module name="presentation">
4+
<document url="http://test-install.blindsidenetworks.com/default.pdf"/>
5+
</module>
6+
</modules>

0 commit comments

Comments
 (0)