Nextcloud PHP API (master)

ISystemTagManager

Public interface to access and manage system-wide tags.

Tags
since
9.0.0

Table of Contents

Methods

canUserAssignTag()  : bool
Checks whether the given user is allowed to assign/unassign the tag with the given id.
canUserSeeTag()  : bool
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()  : array<string|int, ISystemTag>
Returns all known tags, optionally filtered by visibility.
getTag()  : ISystemTag
Returns the tag object matching the given attributes.
getTagGroups()  : array<string|int, string>
Get groups that can assign a given tag.
getTagsByIds()  : array<string|int, 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) : bool
Parameters
$tag : ISystemTag

tag to check permission for

$user : IUser

user to check permission for

Tags
since
9.1.0
Return values
bool

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) : bool
Parameters
$tag : ISystemTag

tag to check permission for

$user : IUser

user to check permission for

Tags
since
9.1.0
Return values
bool

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<string|int, mixed> $tagIds) : mixed
Parameters
$tagIds : string|array<string|int, mixed>

array of tag ids

Tags
throws
TagNotFoundException

if at least one tag did not exist

since
9.0.0

getAllTags()

Returns all known tags, optionally filtered by visibility.

public getAllTags([bool|null $visibilityFilter = null ][, string $nameSearchPattern = null ]) : array<string|int, 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
array<string|int, 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) : array<string|int, string>
Parameters
$tag : ISystemTag

tag for group assignment

Tags
since
9.1.0
Return values
array<string|int, 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|int, mixed>|string $tagIds[, IUser|null $user = null ]) : array<string|int, ISystemTag>
Parameters
$tagIds : array<string|int, mixed>|string

id or array of unique ids of the tag to retrieve

$user : IUser|null = null

optional user to run a visibility check against for each tag

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,

optional parameter $user added in 28.0.0

Return values
array<string|int, ISystemTag>

array of system tags with tag id as key

setTagGroups()

Set groups that can assign a given tag.

public setTagGroups(ISystemTag $tag, array<string|int, string> $groupIds) : mixed
Parameters
$tag : ISystemTag

tag for group assignment

$groupIds : array<string|int, string>

group ids of groups that can assign/unassign the tag

Tags
since
9.1.0

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

        
On this page

Search results