aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorskjnldsv <skjnldsv@protonmail.com>2024-11-15 11:06:35 +0100
committerskjnldsv <skjnldsv@protonmail.com>2024-12-06 10:19:42 +0100
commitadf8a454dd934b076bc907ff7202cd9e85b67525 (patch)
tree82712f103de2ae748355193c45b9b97d3065a947 /lib
parent3328cea2ea756bd91b445a5aaf988e60d86f64ed (diff)
downloadnextcloud-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')
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
-rw-r--r--lib/composer/composer/installed.php4
-rw-r--r--lib/private/SystemTag/SystemTag.php23
-rw-r--r--lib/private/SystemTag/SystemTagManager.php42
-rw-r--r--lib/public/SystemTag/ISystemTag.php7
-rw-r--r--lib/public/SystemTag/ISystemTagManager.php4
7 files changed, 26 insertions, 56 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 94e6e1f1e41..746e43248d8 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -1416,7 +1416,6 @@ return array(
'OC\\Core\\Migrations\\Version30000Date20240906095113' => $baseDir . '/core/Migrations/Version30000Date20240906095113.php',
'OC\\Core\\Migrations\\Version31000Date20240101084401' => $baseDir . '/core/Migrations/Version31000Date20240101084401.php',
'OC\\Core\\Migrations\\Version31000Date20240814184402' => $baseDir . '/core/Migrations/Version31000Date20240814184402.php',
- 'OC\\Core\\Migrations\\Version31000Date20241018063111' => $baseDir . '/core/Migrations/Version31000Date20241018063111.php',
'OC\\Core\\Notification\\CoreNotifier' => $baseDir . '/core/Notification/CoreNotifier.php',
'OC\\Core\\ResponseDefinitions' => $baseDir . '/core/ResponseDefinitions.php',
'OC\\Core\\Service\\LoginFlowV2Service' => $baseDir . '/core/Service/LoginFlowV2Service.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 246934b4848..62124d74496 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -1457,7 +1457,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Core\\Migrations\\Version30000Date20240906095113' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240906095113.php',
'OC\\Core\\Migrations\\Version31000Date20240101084401' => __DIR__ . '/../../..' . '/core/Migrations/Version31000Date20240101084401.php',
'OC\\Core\\Migrations\\Version31000Date20240814184402' => __DIR__ . '/../../..' . '/core/Migrations/Version31000Date20240814184402.php',
- 'OC\\Core\\Migrations\\Version31000Date20241018063111' => __DIR__ . '/../../..' . '/core/Migrations/Version31000Date20241018063111.php',
'OC\\Core\\Notification\\CoreNotifier' => __DIR__ . '/../../..' . '/core/Notification/CoreNotifier.php',
'OC\\Core\\ResponseDefinitions' => __DIR__ . '/../../..' . '/core/ResponseDefinitions.php',
'OC\\Core\\Service\\LoginFlowV2Service' => __DIR__ . '/../../..' . '/core/Service/LoginFlowV2Service.php',
diff --git a/lib/composer/composer/installed.php b/lib/composer/composer/installed.php
index 3d7c94e736c..bd6f4140a96 100644
--- a/lib/composer/composer/installed.php
+++ b/lib/composer/composer/installed.php
@@ -3,7 +3,7 @@
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
- 'reference' => 'd481e4c575c189d6ddb128740892dd54a7c7ed48',
+ 'reference' => 'ee76fe192de8656d216b4079a6c50dda3fc9cdb1',
'type' => 'library',
'install_path' => __DIR__ . '/../../../',
'aliases' => array(),
@@ -13,7 +13,7 @@
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
- 'reference' => 'd481e4c575c189d6ddb128740892dd54a7c7ed48',
+ 'reference' => 'ee76fe192de8656d216b4079a6c50dda3fc9cdb1',
'type' => 'library',
'install_path' => __DIR__ . '/../../../',
'aliases' => array(),
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;
}
+
}
diff --git a/lib/public/SystemTag/ISystemTag.php b/lib/public/SystemTag/ISystemTag.php
index 593c127ba63..4fd93831955 100644
--- a/lib/public/SystemTag/ISystemTag.php
+++ b/lib/public/SystemTag/ISystemTag.php
@@ -89,4 +89,11 @@ interface ISystemTag {
* @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 1c08d3b22e1..04804798114 100644
--- a/lib/public/SystemTag/ISystemTagManager.php
+++ b/lib/public/SystemTag/ISystemTagManager.php
@@ -81,14 +81,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
*
* @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.