aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2023-05-04 11:57:07 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2023-05-16 12:46:50 +0200
commitc0dbde5fba48be3b93e52087c4b7e5b59e6377ed (patch)
treea99bdf37303cf7fa6614cddca4af10a1e563306f /apps/dav/lib
parent2ea872d1562e77f486eb21323a2905b0585ea2f4 (diff)
downloadnextcloud-server-c0dbde5fba48be3b93e52087c4b7e5b59e6377ed.tar.gz
nextcloud-server-c0dbde5fba48be3b93e52087c4b7e5b59e6377ed.zip
feat: specify media type via url path: systemtags-current/$mediaType
- only the media part of the mime type can be search, but not the full mime type. It can be added, should it become necessary. - thus fixes previously hardcoded selector for image/ types - also fixes a return type hint - adds a return type hint Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/SystemTag/SystemTagsInUseCollection.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/apps/dav/lib/SystemTag/SystemTagsInUseCollection.php b/apps/dav/lib/SystemTag/SystemTagsInUseCollection.php
index 938b14e1f65..94a86352a96 100644
--- a/apps/dav/lib/SystemTag/SystemTagsInUseCollection.php
+++ b/apps/dav/lib/SystemTag/SystemTagsInUseCollection.php
@@ -31,21 +31,34 @@ use OCP\Files\IRootFolder;
use OCP\IUserSession;
use OCP\SystemTag\ISystemTagManager;
use Sabre\DAV\Exception\Forbidden;
+use Sabre\DAV\Exception\NotFound;
class SystemTagsInUseCollection extends \Sabre\DAV\SimpleCollection {
protected IUserSession $userSession;
protected IRootFolder $rootFolder;
+ protected string $mediaType;
- public function __construct(IUserSession $userSession, IRootFolder $rootFolder) {
+ public function __construct(IUserSession $userSession, IRootFolder $rootFolder, string $mediaType = '') {
$this->userSession = $userSession;
$this->rootFolder = $rootFolder;
+ $this->mediaType = $mediaType;
$this->name = 'systemtags-current';
+ if ($this->mediaType != '') {
+ $this->name .= '/' . $this->mediaType;
+ }
}
public function setName($name): void {
throw new Forbidden('Permission denied to rename this collection');
}
+ public function getChild($name) {
+ if ($this->mediaType !== '') {
+ throw new NotFound('Invalid media type');
+ }
+ return new self($this->userSession, $this->rootFolder, $name);
+ }
+
public function getChildren() {
$user = $this->userSession->getUser();
if ($user === null) {
@@ -53,7 +66,7 @@ class SystemTagsInUseCollection extends \Sabre\DAV\SimpleCollection {
}
$userFolder = $this->rootFolder->getUserFolder($user->getUID());
- $result = $userFolder->getSystemTags('image');
+ $result = $userFolder->getSystemTags($this->mediaType);
$children = [];
foreach ($result as $tagData) {
$tag = new SystemTag((string)$tagData['id'], $tagData['name'], (bool)$tagData['visibility'], (bool)$tagData['editable']);