diff options
author | skjnldsv <skjnldsv@protonmail.com> | 2024-11-15 11:06:35 +0100 |
---|---|---|
committer | skjnldsv <skjnldsv@protonmail.com> | 2024-12-06 10:19:42 +0100 |
commit | adf8a454dd934b076bc907ff7202cd9e85b67525 (patch) | |
tree | 82712f103de2ae748355193c45b9b97d3065a947 /lib/private | |
parent | 3328cea2ea756bd91b445a5aaf988e60d86f64ed (diff) | |
download | nextcloud-server-adf8a454dd934b076bc907ff7202cd9e85b67525.tar.gz nextcloud-server-adf8a454dd934b076bc907ff7202cd9e85b67525.zip |
feat(systemtags): add color support backend
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/SystemTag/SystemTag.php | 23 | ||||
-rw-r--r-- | lib/private/SystemTag/SystemTagManager.php | 42 |
2 files changed, 14 insertions, 51 deletions
diff --git a/lib/private/SystemTag/SystemTag.php b/lib/private/SystemTag/SystemTag.php index 8c64f2389d0..1a573dabeaa 100644 --- a/lib/private/SystemTag/SystemTag.php +++ b/lib/private/SystemTag/SystemTag.php @@ -17,40 +17,26 @@ class SystemTag implements ISystemTag { private bool $userVisible, private bool $userAssignable, private ?string $etag = null, + private ?string $color = null, ) { } - /** - * {@inheritdoc} - */ public function getId(): string { return $this->id; } - /** - * {@inheritdoc} - */ public function getName(): string { return $this->name; } - /** - * {@inheritdoc} - */ public function isUserVisible(): bool { return $this->userVisible; } - /** - * {@inheritdoc} - */ public function isUserAssignable(): bool { return $this->userAssignable; } - /** - * {@inheritdoc} - */ public function getAccessLevel(): int { if (!$this->userVisible) { return self::ACCESS_LEVEL_INVISIBLE; @@ -63,10 +49,11 @@ class SystemTag implements ISystemTag { return self::ACCESS_LEVEL_PUBLIC; } - /** - * {@inheritdoc} - */ public function getETag(): ?string { return $this->etag; } + + public function getColor(): ?string { + return $this->color; + } } diff --git a/lib/private/SystemTag/SystemTagManager.php b/lib/private/SystemTag/SystemTagManager.php index 70bb8e6e70b..4f05d40c34c 100644 --- a/lib/private/SystemTag/SystemTagManager.php +++ b/lib/private/SystemTag/SystemTagManager.php @@ -45,9 +45,6 @@ class SystemTagManager implements ISystemTagManager { ->andWhere($query->expr()->eq('editable', $query->createParameter('editable'))); } - /** - * {@inheritdoc} - */ public function getTagsByIds($tagIds, ?IUser $user = null): array { if (!\is_array($tagIds)) { $tagIds = [$tagIds]; @@ -92,9 +89,6 @@ class SystemTagManager implements ISystemTagManager { return $tags; } - /** - * {@inheritdoc} - */ public function getAllTags($visibilityFilter = null, $nameSearchPattern = null): array { $tags = []; @@ -130,9 +124,6 @@ class SystemTagManager implements ISystemTagManager { return $tags; } - /** - * {@inheritdoc} - */ public function getTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag { // Length of name column is 64 $truncatedTagName = substr($tagName, 0, 64); @@ -153,9 +144,6 @@ class SystemTagManager implements ISystemTagManager { return $this->createSystemTagFromRow($row); } - /** - * {@inheritdoc} - */ public function createTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag { // Length of name column is 64 $truncatedTagName = substr($tagName, 0, 64); @@ -194,14 +182,12 @@ class SystemTagManager implements ISystemTagManager { return $tag; } - /** - * {@inheritdoc} - */ public function updateTag( string $tagId, string $newName, bool $userVisible, bool $userAssignable, + ?string $color, ): void { try { $tags = $this->getTagsByIds($tagId); @@ -218,7 +204,9 @@ class SystemTagManager implements ISystemTagManager { $tagId, $truncatedNewName, $userVisible, - $userAssignable + $userAssignable, + $beforeUpdate->getETag(), + $color ); $query = $this->connection->getQueryBuilder(); @@ -226,11 +214,13 @@ class SystemTagManager implements ISystemTagManager { ->set('name', $query->createParameter('name')) ->set('visibility', $query->createParameter('visibility')) ->set('editable', $query->createParameter('editable')) + ->set('color', $query->createParameter('color')) ->where($query->expr()->eq('id', $query->createParameter('tagid'))) ->setParameter('name', $truncatedNewName) ->setParameter('visibility', $userVisible ? 1 : 0) ->setParameter('editable', $userAssignable ? 1 : 0) - ->setParameter('tagid', $tagId); + ->setParameter('tagid', $tagId) + ->setParameter('color', $color); try { if ($query->execute() === 0) { @@ -251,9 +241,6 @@ class SystemTagManager implements ISystemTagManager { )); } - /** - * {@inheritdoc} - */ public function deleteTags($tagIds): void { if (!\is_array($tagIds)) { $tagIds = [$tagIds]; @@ -303,9 +290,6 @@ class SystemTagManager implements ISystemTagManager { } } - /** - * {@inheritdoc} - */ public function canUserAssignTag(ISystemTag $tag, ?IUser $user): bool { if ($user === null) { return false; @@ -335,9 +319,6 @@ class SystemTagManager implements ISystemTagManager { return false; } - /** - * {@inheritdoc} - */ public function canUserSeeTag(ISystemTag $tag, ?IUser $user): bool { // If no user, then we only show public tags if (!$user && $tag->getAccessLevel() === ISystemTag::ACCESS_LEVEL_PUBLIC) { @@ -361,12 +342,9 @@ class SystemTagManager implements ISystemTagManager { } private function createSystemTagFromRow($row): SystemTag { - return new SystemTag((string)$row['id'], $row['name'], (bool)$row['visibility'], (bool)$row['editable'], $row['etag']); + return new SystemTag((string)$row['id'], $row['name'], (bool)$row['visibility'], (bool)$row['editable'], $row['etag'], $row['color']); } - /** - * {@inheritdoc} - */ public function setTagGroups(ISystemTag $tag, array $groupIds): void { // delete relationships first $this->connection->beginTransaction(); @@ -398,9 +376,6 @@ class SystemTagManager implements ISystemTagManager { } } - /** - * {@inheritdoc} - */ public function getTagGroups(ISystemTag $tag): array { $groupIds = []; $query = $this->connection->getQueryBuilder(); @@ -418,4 +393,5 @@ class SystemTagManager implements ISystemTagManager { return $groupIds; } + } |