Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/private/SystemTag/SystemTagManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ public function getGeneratedByAITag(): ISystemTag {
}
}

public function createTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag {
$user = $this->userSession->getUser();
public function createTag(string $tagName, bool $userVisible, bool $userAssignable, ?IUser $user = null): ISystemTag {
$user ??= $this->userSession->getUser();
if (!$this->canUserCreateTag($user)) {
throw new TagCreationForbiddenException();
}
Expand Down Expand Up @@ -219,6 +219,7 @@ public function updateTag(
bool $userVisible,
bool $userAssignable,
?string $color,
?IUser $user,
): void {
try {
$tags = $this->getTagsByIds($tagId);
Expand All @@ -228,7 +229,7 @@ public function updateTag(
);
}

$user = $this->userSession->getUser();
$user ??= $this->userSession->getUser();
if (!$this->canUserUpdateTag($user)) {
throw new TagUpdateForbiddenException();
}
Expand Down
6 changes: 4 additions & 2 deletions lib/public/SystemTag/ISystemTagManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function getGeneratedByAITag(): ISystemTag;
* @param string $tagName tag name
* @param bool $userVisible whether the tag is visible by users
* @param bool $userAssignable whether the tag is assignable by users
* @param IUser|null $user the user that wants to create a tag.
*
* @return ISystemTag system tag
*
Expand All @@ -70,7 +71,7 @@ public function getGeneratedByAITag(): ISystemTag;
* @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;
public function createTag(string $tagName, bool $userVisible, bool $userAssignable, ?IUser $user): ISystemTag;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function createTag(string $tagName, bool $userVisible, bool $userAssignable, ?IUser $user): ISystemTag;
public function createTag(string $tagName, bool $userVisible, bool $userAssignable, ?IUser $user = null): ISystemTag;


/**
* Returns all known tags, optionally filtered by visibility.
Expand All @@ -92,6 +93,7 @@ public function getAllTags($visibilityFilter = null, $nameSearchPattern = null):
* @param bool $userVisible whether the tag is visible by users
* @param bool $userAssignable whether the tag is assignable by users
* @param string $color color
* @param IUser|null $user the user that wants to update a tag.
*
* @throws TagNotFoundException if tag with the given id does not exist
* @throws TagAlreadyExistsException if there is already another tag
Expand All @@ -100,7 +102,7 @@ public function getAllTags($visibilityFilter = null, $nameSearchPattern = null):
* @since 9.0.0
* @since 31.0.0 `$color` parameter added
*/
public function updateTag(string $tagId, string $newName, bool $userVisible, bool $userAssignable, ?string $color);
public function updateTag(string $tagId, string $newName, bool $userVisible, bool $userAssignable, ?string $color, ?IUser $user): void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function updateTag(string $tagId, string $newName, bool $userVisible, bool $userAssignable, ?string $color, ?IUser $user): void;
public function updateTag(string $tagId, string $newName, bool $userVisible, bool $userAssignable, ?string $color, ?IUser $user = null): void;


/**
* Delete the given tags from the database and all their relationships.
Expand Down
Loading