Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions src/Parameters/CreateMeetingParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class CreateMeetingParameters extends MetaParameters
protected ?string $clientSettingsOverride = null;

/**
* @var array<string,string>
* @var array<string,array<string, string|bool|null>>
*/
private array $presentations = [];

Expand Down Expand Up @@ -351,13 +351,14 @@ public function setGuestPolicyAlwaysAccept(): self
return $this;
}

public function addPresentation(string $nameOrUrl, ?string $content = null, ?string $filename = null): self
public function addPresentation(string $nameOrUrl, ?string $content = null, ?string $filename = null, ?bool $downloadable = null, ?bool $removable = null): self
{
if (!$filename) {
$this->presentations[$nameOrUrl] = !$content ?: base64_encode($content);
} else {
$this->presentations[$nameOrUrl] = $filename;
}
$this->presentations[$nameOrUrl] = [
'filename' => $filename,
'content' => !$content ?: base64_encode($content),
'downloadable' => $downloadable,
'removable' => $removable,
];

return $this;
}
Expand Down Expand Up @@ -423,18 +424,27 @@ public function addPresentationsModule(SimpleXMLElementExtended $xml): void
$module = $xml->addChild('module');
$module->addAttribute('name', 'presentation');

foreach ($this->presentations as $nameOrUrl => $content) {
foreach ($this->presentations as $nameOrUrl => $data) {
$document = $module->addChild('document');

if (str_starts_with($nameOrUrl, 'http')) {
$presentation = $module->addChild('document');
$presentation->addAttribute('url', $nameOrUrl);
if (\is_string($content)) {
$presentation->addAttribute('filename', $content);
}
$document->addAttribute('url', $nameOrUrl);
} else {
$document = $module->addChild('document');
$document->addAttribute('name', $nameOrUrl);
/* @phpstan-ignore-next-line */
$document[0] = $content;
$document[0] = $data['content'];
}

if (isset($data['filename'])) {
$document->addAttribute('filename', $data['filename']);
}

if (\is_bool($data['downloadable'])) {
$document->addAttribute('downloadable', $data['downloadable'] ? 'true' : 'false');
}

if (\is_bool($data['removable'])) {
$document->addAttribute('removable', $data['removable'] ? 'true' : 'false');
}
}
}
Expand Down
31 changes: 21 additions & 10 deletions src/Parameters/InsertDocumentParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ public function __construct(protected string $meetingID)
{
}

public function addPresentation(string $url, string $filename, ?bool $downloadable = null, ?bool $removable = null): self
public function addPresentation(string $nameOrUrl, ?string $content = null, ?string $filename = null, ?bool $downloadable = null, ?bool $removable = null): self
{
$this->presentations[$url] = [
$this->presentations[$nameOrUrl] = [
'filename' => $filename,
'content' => !$content ?: base64_encode($content),
'downloadable' => $downloadable,
'removable' => $removable,
];
Expand All @@ -61,17 +62,27 @@ public function getPresentationsAsXML(): string|false
$module = $xml->addChild('module');
$module->addAttribute('name', 'presentation');

foreach ($this->presentations as $url => $content) {
$presentation = $module->addChild('document');
$presentation->addAttribute('url', $url);
$presentation->addAttribute('filename', $content['filename']);
foreach ($this->presentations as $nameOrUrl => $data) {
$document = $module->addChild('document');

if (\is_bool($content['downloadable'])) {
$presentation->addAttribute('downloadable', $content['downloadable'] ? 'true' : 'false');
if (str_starts_with($nameOrUrl, 'http')) {
$document->addAttribute('url', $nameOrUrl);
} else {
$document->addAttribute('name', $nameOrUrl);
/* @phpstan-ignore-next-line */
$document[0] = $data['content'];
}

if (\is_bool($content['removable'])) {
$presentation->addAttribute('removable', $content['removable'] ? 'true' : 'false');
if (isset($data['filename'])) {
$document->addAttribute('filename', $data['filename']);
}

if (\is_bool($data['downloadable'])) {
$document->addAttribute('downloadable', $data['downloadable'] ? 'true' : 'false');
}

if (\is_bool($data['removable'])) {
$document->addAttribute('removable', $data['removable'] ? 'true' : 'false');
}
}
$result = $xml->asXML();
Expand Down
Loading