diff options
Diffstat (limited to 'lib/public/SystemTag')
-rw-r--r-- | lib/public/SystemTag/ISystemTag.php | 16 | ||||
-rw-r--r-- | lib/public/SystemTag/ISystemTagManager.php | 40 | ||||
-rw-r--r-- | lib/public/SystemTag/ISystemTagObjectMapper.php | 37 | ||||
-rw-r--r-- | lib/public/SystemTag/MapperEvent.php | 16 | ||||
-rw-r--r-- | lib/public/SystemTag/SystemTagsEntityEvent.php | 6 | ||||
-rw-r--r-- | lib/public/SystemTag/TagCreationForbiddenException.php | 18 | ||||
-rw-r--r-- | lib/public/SystemTag/TagUpdateForbiddenException.php | 18 |
7 files changed, 133 insertions, 18 deletions
diff --git a/lib/public/SystemTag/ISystemTag.php b/lib/public/SystemTag/ISystemTag.php index 8a01779f783..4fd93831955 100644 --- a/lib/public/SystemTag/ISystemTag.php +++ b/lib/public/SystemTag/ISystemTag.php @@ -80,4 +80,20 @@ interface ISystemTag { * @since 22.0.0 */ public function getAccessLevel(): int; + + /** + * Returns the ETag of the tag + * The ETag is a unique identifier for the tag and should change whenever the tag changes + * or whenever elements gets added or removed from the tag. + * + * @since 31.0.0 + */ + public function getETag(): ?string; + + /** + * Returns the color of the tag + * + * @since 31.0.0 + */ + public function getColor(): ?string; } diff --git a/lib/public/SystemTag/ISystemTagManager.php b/lib/public/SystemTag/ISystemTagManager.php index 99d806155dc..96e775d6401 100644 --- a/lib/public/SystemTag/ISystemTagManager.php +++ b/lib/public/SystemTag/ISystemTagManager.php @@ -26,7 +26,7 @@ interface ISystemTagManager { * * @throws \InvalidArgumentException if at least one given tag ids is invalid (string instead of integer, etc.) * @throws TagNotFoundException if at least one given tag ids did no exist - * The message contains a json_encoded array of the ids that could not be found + * The message contains a json_encoded array of the ids that could not be found * * @since 9.0.0, optional parameter $user added in 28.0.0 */ @@ -57,8 +57,10 @@ interface ISystemTagManager { * @return ISystemTag system tag * * @throws TagAlreadyExistsException if tag already exists + * @throws TagCreationForbiddenException if user doesn't have the right to create a new tag * * @since 9.0.0 + * @since 31.0.0 Can throw TagCreationForbiddenExceptionif user doesn't have the right to create a new tag */ public function createTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag; @@ -81,14 +83,16 @@ interface ISystemTagManager { * @param string $newName the new tag name * @param bool $userVisible whether the tag is visible by users * @param bool $userAssignable whether the tag is assignable by users + * @param string $color color * * @throws TagNotFoundException if tag with the given id does not exist * @throws TagAlreadyExistsException if there is already another tag - * with the same attributes + * with the same attributes * * @since 9.0.0 + * @since 31.0.0 `$color` parameter added */ - public function updateTag(string $tagId, string $newName, bool $userVisible, bool $userAssignable); + public function updateTag(string $tagId, string $newName, bool $userVisible, bool $userAssignable, ?string $color); /** * Delete the given tags from the database and all their relationships. @@ -106,25 +110,47 @@ interface ISystemTagManager { * given id. * * @param ISystemTag $tag tag to check permission for - * @param IUser $user user to check permission for + * @param IUser|null $user user to check permission for * * @return bool true if the user is allowed to assign/unassign the tag, false otherwise * * @since 9.1.0 + * @since 31.0.0 `$user` can be null to check anonymous permissions */ - public function canUserAssignTag(ISystemTag $tag, IUser $user): bool; + public function canUserAssignTag(ISystemTag $tag, ?IUser $user): bool; + + /** + * Checks whether the given user is allowed to create new tags + * + * @param IUser|null $user user to check permission for + * @return bool true if the user is allowed to create a new tag, false otherwise + * + * @since 31.0.0 + */ + public function canUserCreateTag(?IUser $user): bool; + + /** + * Checks whether the given user is allowed to update tags + * + * @param IUser|null $user user to check permission for + * @return bool true if the user is allowed to update a tag, false otherwise + * + * @since 31.0.0 + */ + public function canUserUpdateTag(?IUser $user): bool; /** * Checks whether the given user is allowed to see the tag with the given id. * * @param ISystemTag $tag tag to check permission for - * @param IUser $user user to check permission for + * @param IUser|null $user user to check permission for * * @return bool true if the user can see the tag, false otherwise * * @since 9.1.0 + * @since 31.0.0 `$user` can be null to check anonymous permissions */ - public function canUserSeeTag(ISystemTag $tag, IUser $user): bool; + public function canUserSeeTag(ISystemTag $tag, ?IUser $user): bool; /** * Set groups that can assign a given tag. diff --git a/lib/public/SystemTag/ISystemTagObjectMapper.php b/lib/public/SystemTag/ISystemTagObjectMapper.php index b3eb0201ce6..c604fa93c58 100644 --- a/lib/public/SystemTag/ISystemTagObjectMapper.php +++ b/lib/public/SystemTag/ISystemTagObjectMapper.php @@ -31,7 +31,7 @@ interface ISystemTagObjectMapper { * @param string $objectType object type * * @return array with object id as key and an array - * of tag ids as value + * of tag ids as value * * @since 9.0.0 */ @@ -48,9 +48,9 @@ interface ISystemTagObjectMapper { * @return string[] array of object ids or empty array if none found * * @throws TagNotFoundException if at least one of the - * given tags does not exist + * given tags does not exist * @throws \InvalidArgumentException When a limit is specified together with - * multiple tag ids + * multiple tag ids * * @since 9.0.0 */ @@ -69,7 +69,7 @@ interface ISystemTagObjectMapper { * @param string|array $tagIds tag id or array of tag ids to assign * * @throws TagNotFoundException if at least one of the - * given tags does not exist + * given tags does not exist * * @since 9.0.0 */ @@ -88,7 +88,7 @@ interface ISystemTagObjectMapper { * @param string|array $tagIds tag id or array of tag ids to unassign * * @throws TagNotFoundException if at least one of the - * given tags does not exist + * given tags does not exist * * @since 9.0.0 */ @@ -101,14 +101,37 @@ interface ISystemTagObjectMapper { * @param string $objectType object type * @param string $tagId tag id to check * @param bool $all true to check that ALL objects have the tag assigned, - * false to check that at least ONE object has the tag. + * false to check that at least ONE object has the tag. * * @return bool true if the condition set by $all is matched, false - * otherwise + * otherwise * * @throws TagNotFoundException if the tag does not exist * * @since 9.0.0 */ public function haveTag($objIds, string $objectType, string $tagId, bool $all = true): bool; + + + /** + * Get the list of object types that have objects assigned to them. + * + * @return string[] list of object types + * + * @since 31.0.0 + */ + public function getAvailableObjectTypes(): array; + + /** + * Set the list of object ids for the given tag. + * This will replace the current list of object ids. + * + * @param string $tagId tag id + * @param string $objectType object type + * @param string[] $objectIds list of object ids + * + * @throws TagNotFoundException if the tag does not exist + * @since 31.0.0 + */ + public function setObjectIdsForTag(string $tagId, string $objectType, array $objectIds): void; } diff --git a/lib/public/SystemTag/MapperEvent.php b/lib/public/SystemTag/MapperEvent.php index f8f130d6473..821d1b5dc5e 100644 --- a/lib/public/SystemTag/MapperEvent.php +++ b/lib/public/SystemTag/MapperEvent.php @@ -9,13 +9,14 @@ declare(strict_types=1); namespace OCP\SystemTag; use OCP\EventDispatcher\Event; +use OCP\EventDispatcher\IWebhookCompatibleEvent; /** * Class MapperEvent * * @since 9.0.0 */ -class MapperEvent extends Event { +class MapperEvent extends Event implements IWebhookCompatibleEvent { /** * @since 9.0.0 * @deprecated 22.0.0 @@ -84,4 +85,17 @@ class MapperEvent extends Event { public function getTags(): array { return $this->tags; } + + /** + * @return array + * @since 32.0.0 + */ + public function getWebhookSerializable(): array { + return [ + 'eventType' => $this->getEvent(), + 'objectType' => $this->getObjectType(), + 'objectId' => $this->getObjectId(), + 'tagIds' => $this->getTags(), + ]; + } } diff --git a/lib/public/SystemTag/SystemTagsEntityEvent.php b/lib/public/SystemTag/SystemTagsEntityEvent.php index bccff9eda84..d8f391d0dba 100644 --- a/lib/public/SystemTag/SystemTagsEntityEvent.php +++ b/lib/public/SystemTag/SystemTagsEntityEvent.php @@ -37,9 +37,9 @@ class SystemTagsEntityEvent extends Event { /** * @param string $name * @param \Closure $entityExistsFunction The closure should take one - * argument, which is the id of the entity, that tags - * should be handled for. The return should then be bool, - * depending on whether tags are allowed (true) or not. + * argument, which is the id of the entity, that tags + * should be handled for. The return should then be bool, + * depending on whether tags are allowed (true) or not. * @throws \OutOfBoundsException when the entity name is already taken * @since 9.1.0 */ diff --git a/lib/public/SystemTag/TagCreationForbiddenException.php b/lib/public/SystemTag/TagCreationForbiddenException.php new file mode 100644 index 00000000000..eeae38e31f7 --- /dev/null +++ b/lib/public/SystemTag/TagCreationForbiddenException.php @@ -0,0 +1,18 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +namespace OCP\SystemTag; + +/** + * Exception when a user doesn't have the right to create a tag + * + * @since 31.0.0 + */ +class TagCreationForbiddenException extends \RuntimeException { +} diff --git a/lib/public/SystemTag/TagUpdateForbiddenException.php b/lib/public/SystemTag/TagUpdateForbiddenException.php new file mode 100644 index 00000000000..e5c1e76f6fe --- /dev/null +++ b/lib/public/SystemTag/TagUpdateForbiddenException.php @@ -0,0 +1,18 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +namespace OCP\SystemTag; + +/** + * Exception when a user doesn't have the right to create a tag + * + * @since 31.0.1 + */ +class TagUpdateForbiddenException extends \RuntimeException { +} |