Nextcloud PHP API (stable18)

ISystemTagManager

Public interface to access and manage system-wide tags.

Tags
since
9.0.0

Table of Contents

canUserAssignTag()  : true
Checks whether the given user is allowed to assign/unassign the tag with the given id.
canUserSeeTag()  : true
Checks whether the given user is allowed to see the tag with the given id.
createTag()  : ISystemTag
Creates the tag object using the given attributes.
deleteTags()  : mixed
Delete the given tags from the database and all their relationships.
getAllTags()  : \OCP\SystemTag\ISystemTag[]
Returns all known tags, optionally filtered by visibility.
getTag()  : ISystemTag
Returns the tag object matching the given attributes.
getTagGroups()  : string[]
Get groups that can assign a given tag.
getTagsByIds()  : \OCP\SystemTag\ISystemTag[]
Returns the tag objects matching the given tag ids.
setTagGroups()  : mixed
Set groups that can assign a given tag.
updateTag()  : mixed
Updates the given tag

Methods

canUserAssignTag()

Checks whether the given user is allowed to assign/unassign the tag with the given id.

public canUserAssignTag(ISystemTag $tag, IUser $user) : true
Parameters
$tag : ISystemTag

tag to check permission for

$user : IUser

user to check permission for

Tags
since
9.1.0
Return values
true

if the user is allowed to assign/unassign the tag, false otherwise

canUserSeeTag()

Checks whether the given user is allowed to see the tag with the given id.

public canUserSeeTag(ISystemTag $tag, IUser $user) : true
Parameters
$tag : ISystemTag

tag to check permission for

$user : IUser

user to check permission for

Tags
since
9.1.0
Return values
true

if the user can see the tag, false otherwise

createTag()

Creates the tag object using the given attributes.

public createTag(string $tagName, bool $userVisible, bool $userAssignable) : ISystemTag
Parameters
$tagName : string

tag name

$userVisible : bool

whether the tag is visible by users

$userAssignable : bool

whether the tag is assignable by users

Tags
throws
TagAlreadyExistsException

if tag already exists

since
9.0.0
Return values
ISystemTag

system tag

deleteTags()

Delete the given tags from the database and all their relationships.

public deleteTags(string|array $tagIds) : mixed
Parameters
$tagIds : string|array

array of tag ids

Tags
throws
TagNotFoundException

if at least one tag did not exist

since
9.0.0
Return values
mixed

getAllTags()

Returns all known tags, optionally filtered by visibility.

public getAllTags([bool|null $visibilityFilter = null ][, string $nameSearchPattern = null ]) : \OCP\SystemTag\ISystemTag[]
Parameters
$visibilityFilter : bool|null = null

filter by visibility if non-null

$nameSearchPattern : string = null

optional search pattern for the tag name

Tags
since
9.0.0
Return values
\OCP\SystemTag\ISystemTag[]

array of system tags or empty array if none found

getTag()

Returns the tag object matching the given attributes.

public getTag(string $tagName, bool $userVisible, bool $userAssignable) : ISystemTag
Parameters
$tagName : string

tag name

$userVisible : bool

whether the tag is visible by users

$userAssignable : bool

whether the tag is assignable by users

Tags
throws
TagNotFoundException

if tag does not exist

since
9.0.0
Return values
ISystemTag

system tag

getTagGroups()

Get groups that can assign a given tag.

public getTagGroups(ISystemTag $tag) : string[]
Parameters
$tag : ISystemTag

tag for group assignment

Tags
since
9.1.0
Return values
string[]

group ids of groups that can assign/unassign the tag

getTagsByIds()

Returns the tag objects matching the given tag ids.

public getTagsByIds(array|string $tagIds) : \OCP\SystemTag\ISystemTag[]
Parameters
$tagIds : array|string

id or array of unique ids of the tag to retrieve

Tags
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

since
9.0.0
Return values
\OCP\SystemTag\ISystemTag[]

array of system tags with tag id as key

setTagGroups()

Set groups that can assign a given tag.

public setTagGroups(ISystemTag $tag, string[] $groupIds) : mixed
Parameters
$tag : ISystemTag

tag for group assignment

$groupIds : string[]

group ids of groups that can assign/unassign the tag

Tags
since
9.1.0
Return values
mixed

updateTag()

Updates the given tag

public updateTag(string $tagId, string $newName, bool $userVisible, bool $userAssignable) : mixed
Parameters
$tagId : string

tag id

$newName : string

the new tag name

$userVisible : bool

whether the tag is visible by users

$userAssignable : bool

whether the tag is assignable by users

Tags
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
Return values
mixed

Search results