-
Notifications
You must be signed in to change notification settings - Fork 204
Introduce document classes #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
GhaziTriki
merged 9 commits into
bigbluebutton:develop
from
DigitalTimK:feature/DocumentClass
Apr 3, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d2e1be6
WIP
DigitalTimK fc49071
Merge branch 'develop' into feature/DocumentClass
DigitalTimK 5111137
Introduce Document classes
DigitalTimK f3af7c8
Typos and make PHPstan happy
DigitalTimK 29de9fd
Add addProperty() to Document-class
DigitalTimK 354956e
Improvements and corrections on Document-classes
DigitalTimK 40d7cfb
Minor improvements on Document treatment
DigitalTimK 2b7b666
Merge branch 'develop' into feature/DocumentClass
DigitalTimK dd3c56f
Merge branch 'develop' into feature/DocumentClass
GhaziTriki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * BigBlueButton open source conferencing system - https://www.bigbluebutton.org/. | ||
| * | ||
| * Copyright (c) 2016-2025 BigBlueButton Inc. and by respective authors (see below). | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify it under the | ||
| * terms of the GNU Lesser General Public License as published by the Free Software | ||
| * Foundation; either version 3.0 of the License, or (at your option) any later | ||
| * version. | ||
| * | ||
| * BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY | ||
| * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
| * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public License along | ||
| * with BigBlueButton; if not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| namespace BigBlueButton\Core; | ||
|
|
||
| abstract class Document implements DocumentInterface | ||
| { | ||
| private ?string $name = null; | ||
| private ?bool $current = null; | ||
| private ?bool $downloadable = null; | ||
| private ?bool $removable = null; | ||
| private bool $validate = false; | ||
|
|
||
| /** | ||
| * @var array<string, string> | ||
| */ | ||
| private array $properties = []; | ||
|
|
||
| final public function setName(?string $name): self | ||
| { | ||
| $this->name = $name; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| final public function getName(): ?string | ||
| { | ||
| return $this->name; | ||
| } | ||
|
|
||
| final public function setCurrent(?bool $current): self | ||
| { | ||
| $this->current = $current; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| final public function isCurrent(): ?bool | ||
| { | ||
| return $this->current; | ||
| } | ||
|
|
||
| final public function setDownloadable(?bool $downloadable): Document | ||
| { | ||
| $this->downloadable = $downloadable; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| final public function isDownloadable(): ?bool | ||
| { | ||
| return $this->downloadable; | ||
| } | ||
|
|
||
| final public function setRemovable(?bool $removable): Document | ||
| { | ||
| $this->removable = $removable; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| final public function isRemovable(): ?bool | ||
| { | ||
| return $this->removable; | ||
| } | ||
|
|
||
| /** | ||
| * Add additional properties to the document. These will be passed to the BBB-Server as | ||
| * attributes at the documents' XML-node. Not needed on standard implementation of a | ||
| * BBB-Server, but might be needed on customized (adapted) BBB-Server implementations. | ||
| */ | ||
| final public function addProperty(string $name, string $value): self | ||
| { | ||
| $this->properties[$name] = $value; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * @return array<string, string> | ||
| */ | ||
| final public function getProperties(): array | ||
| { | ||
| return $this->properties; | ||
| } | ||
|
|
||
| public function setValidation(bool $validation): Document | ||
| { | ||
| $this->validate = $validation; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| public function getValidation(): bool | ||
| { | ||
| return $this->validate; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * BigBlueButton open source conferencing system - https://www.bigbluebutton.org/. | ||
| * | ||
| * Copyright (c) 2016-2025 BigBlueButton Inc. and by respective authors (see below). | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify it under the | ||
| * terms of the GNU Lesser General Public License as published by the Free Software | ||
| * Foundation; either version 3.0 of the License, or (at your option) any later | ||
| * version. | ||
| * | ||
| * BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY | ||
| * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
| * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public License along | ||
| * with BigBlueButton; if not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| namespace BigBlueButton\Core; | ||
|
|
||
| class DocumentFile extends Document | ||
| { | ||
| private string $filepath; | ||
|
|
||
| /** @deprecated only needed until DocumentTrait::addPresentation() has not been removed */ | ||
| private ?string $fileContent = null; | ||
|
|
||
| public function __construct(string $filepath, string $name) | ||
| { | ||
| $this->setFilepath($filepath); | ||
| $this->setName($name); | ||
| } | ||
|
|
||
| public function setFilepath(string $filepath): self | ||
| { | ||
| $this->filepath = $filepath; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| public function getFilepath(): string | ||
| { | ||
| return $this->filepath; | ||
| } | ||
|
|
||
| /** | ||
| * @deprecated only needed until DocumentTrait::addPresentation() has not been removed | ||
| */ | ||
| public function setFileContent(string $fileContent): self | ||
| { | ||
| $this->fileContent = $fileContent; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * @throws \Exception | ||
| */ | ||
| public function getFileContent(): string | ||
| { | ||
| if ($this->fileContent) { | ||
| return $this->fileContent; | ||
| } | ||
|
|
||
| $fileContent = file_get_contents($this->filepath); | ||
|
|
||
| if (!$fileContent) { | ||
| throw new \Exception("Unable to read file at {$this->filepath}"); | ||
| } | ||
|
|
||
| return $fileContent; | ||
| } | ||
|
|
||
| public function isValid(): bool | ||
| { | ||
| return file_exists($this->getFilepath()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * BigBlueButton open source conferencing system - https://www.bigbluebutton.org/. | ||
| * | ||
| * Copyright (c) 2016-2025 BigBlueButton Inc. and by respective authors (see below). | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify it under the | ||
| * terms of the GNU Lesser General Public License as published by the Free Software | ||
| * Foundation; either version 3.0 of the License, or (at your option) any later | ||
| * version. | ||
| * | ||
| * BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY | ||
| * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
| * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public License along | ||
| * with BigBlueButton; if not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| namespace BigBlueButton\Core; | ||
|
|
||
| interface DocumentInterface | ||
| { | ||
| public function setName(?string $name): Document; | ||
|
|
||
| public function getName(): ?string; | ||
|
|
||
| public function setCurrent(?bool $current): Document; | ||
|
|
||
| public function isCurrent(): ?bool; | ||
|
|
||
| public function setDownloadable(?bool $downloadable): Document; | ||
|
|
||
| public function isDownloadable(): ?bool; | ||
|
|
||
| public function setRemovable(?bool $removable): Document; | ||
|
|
||
| public function isRemovable(): ?bool; | ||
|
|
||
| public function isValid(): bool; | ||
|
|
||
| public function setValidation(bool $validation): Document; | ||
|
|
||
| public function getValidation(): bool; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * BigBlueButton open source conferencing system - https://www.bigbluebutton.org/. | ||
| * | ||
| * Copyright (c) 2016-2025 BigBlueButton Inc. and by respective authors (see below). | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify it under the | ||
| * terms of the GNU Lesser General Public License as published by the Free Software | ||
| * Foundation; either version 3.0 of the License, or (at your option) any later | ||
| * version. | ||
| * | ||
| * BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY | ||
| * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
| * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public License along | ||
| * with BigBlueButton; if not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| namespace BigBlueButton\Core; | ||
|
|
||
| class DocumentUrl extends Document | ||
| { | ||
| private string $url; | ||
|
|
||
| private int $timeout = 5; | ||
|
|
||
| public function __construct(string $url, ?string $name = null) | ||
| { | ||
| $this->setUrl($url); | ||
| $this->setName($name); | ||
| } | ||
|
|
||
| public function setUrl(string $url): self | ||
| { | ||
| $this->url = $url; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| public function getUrl(): string | ||
| { | ||
| return $this->url; | ||
| } | ||
|
|
||
| public function setTimeout(int $timeout): self | ||
| { | ||
| $this->timeout = $timeout; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| public function getTimeout(): int | ||
| { | ||
| return $this->timeout; | ||
| } | ||
|
|
||
| /** | ||
| * Checks the validity / existence of the provided URL. Pending on file size and server-performance | ||
| * the response could be slow. | ||
| * | ||
| * @experimental | ||
| */ | ||
| public function isValid(): bool | ||
| { | ||
| return $this->urlExists($this->getUrl()); | ||
| } | ||
|
|
||
| /** | ||
| * Checks the validity / existence of the provided URL. Pending on file size and server-performance | ||
| * the response could be slow. | ||
| * | ||
| * @experimental | ||
| */ | ||
| private function urlExists(string $url): bool | ||
| { | ||
| $ch = curl_init($url); | ||
|
|
||
| if (!$ch) { | ||
| throw new \RuntimeException('Unhandled curl error!'); | ||
| } | ||
|
|
||
| curl_setopt($ch, CURLOPT_TIMEOUT, $this->getTimeout()); | ||
| curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->getTimeout()); | ||
| curl_setopt($ch, CURLOPT_NOBODY, true); | ||
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); | ||
|
|
||
| $data = curl_exec($ch); | ||
| $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); | ||
|
|
||
| curl_close($ch); | ||
|
|
||
| if ($httpCode >= 200 && $httpCode < 400) { | ||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.