ITags

interface OCP\ITags
Class for easily tagging objects by their id
A tag can be e.g. ‘Family’, ‘Work’, ‘Chore’, ‘Special Occation’ or
anything else that is either parsed from a vobject or that the user chooses
to add.
Tag names are not case-sensitive, but will be saved with the case they
are entered in. If a user already has a tag ‘family’ for a type, and
tries to add a tag named ‘Family’ it will be silently ignored.
Implemented by:OC\Tags
Source:lib/public/ITags.php#57

Constants

TAG_FAVORITE = _$!<Favorite>!$_
Source:lib/public/ITags.php#61
Since:19.0.0

Methods

public OCP\ITags::isEmpty()
Check if any tags are saved for this type and user.
Source:lib/public/ITags.php#69
Returns:bool
Since:6.0.0
public OCP\ITags::getTag($id)
Returns an array mapping a given tag’s properties to its values:
[‘id’ => 0, ‘name’ = ‘Tag’, ‘owner’ = ‘User’, ‘type’ => ‘tagtype’]
Source:

lib/public/ITags.php#79

Parameters:
  • $id (string) The ID of the tag that is going to be mapped
Returns:

array | bool

Since:

8.0.0

public OCP\ITags::getTags()
Get the tags for a specific user.
This returns an array with id/name maps:
[
[‘id’ => 0, ‘name’ = ‘First tag’],
[‘id’ => 1, ‘name’ = ‘Second tag’],
]
Source:lib/public/ITags.php#93
Returns:array
Since:6.0.0
public OCP\ITags::getTagsForObjects($objIds)
Get a list of tags for the given item ids.
This returns an array with object id / tag names:
[
1 => array(‘First tag’, ‘Second tag’),
2 => array(‘Second tag’),
3 => array(‘Second tag’, ‘Third tag’),
]
Source:

lib/public/ITags.php#110

Parameters:
  • $objIds (array) item ids
Returns:

array | bool with object id as key and an array of tag names as value or false if an error occurred

Since:

8.0.0

public OCP\ITags::getIdsForTag($tag)
Get a list of items tagged with $tag.
Throws an exception if the tag could not be found.
Source:

lib/public/ITags.php#121

Parameters:
  • $tag (string | int) Tag id or name.
Returns:

array | bool An array of object ids or false on error.

Since:

6.0.0

public OCP\ITags::hasTag($name)
Checks whether a tag is already saved.
Source:

lib/public/ITags.php#130

Parameters:
  • $name (string) The name to check for.
Returns:

bool

Since:

6.0.0

public OCP\ITags::userHasTag($name, $user)
Checks whether a tag is saved for the given user,
disregarding the ones shared with him or her.
Source:

lib/public/ITags.php#141

Parameters:
  • $name (string) The tag name to check for.
  • $user (string) The user whose tags are to be checked.
Returns:

bool

Since:

8.0.0

public OCP\ITags::add($name)
Add a new tag.
Source:

lib/public/ITags.php#150

Parameters:
  • $name (string) A string with a name of the tag
Returns:

int | bool the id of the added tag or false if it already exists.

Since:

6.0.0

public OCP\ITags::rename($from, $to)
Rename tag.
Source:

lib/public/ITags.php#160

Parameters:
  • $from (string | int) The name or ID of the existing tag
  • $to (string) The new name of the tag.
Returns:

bool

Since:

6.0.0

public OCP\ITags::addMultiple($names, $sync=false, $id=null)
Add a list of new tags.
Source:

lib/public/ITags.php#172

Parameters:
  • $names (string[]) A string with a name or an array of strings containing

the name(s) of the to add. * $sync (bool) When true, save the tags * $id (int | null) int Optional object id to add to this|these tag(s)

Returns:

bool Returns false on error.

Since:

6.0.0

public OCP\ITags::purgeObjects($ids)
Delete tag/object relations from the db
Source:

lib/public/ITags.php#181

Parameters:
  • $ids (array) The ids of the objects
Returns:

bool Returns false on error.

Since:

6.0.0

public OCP\ITags::getFavorites()
Get favorites for an object type
Source:lib/public/ITags.php#189
Returns:array | bool An array of object ids.
Since:6.0.0
public OCP\ITags::addToFavorites($objid)
Add an object to favorites
Source:

lib/public/ITags.php#198

Parameters:
  • $objid (int) The id of the object
Returns:

bool

Since:

6.0.0

public OCP\ITags::removeFromFavorites($objid)
Remove an object from favorites
Source:

lib/public/ITags.php#207

Parameters:
  • $objid (int) The id of the object
Returns:

bool

Since:

6.0.0

public OCP\ITags::tagAs($objid, $tag)
Creates a tag/object relation.
Source:

lib/public/ITags.php#217

Parameters:
  • $objid (int) The id of the object
  • $tag (string) The id or name of the tag
Returns:

bool Returns false on database error.

Since:

6.0.0

public OCP\ITags::unTag($objid, $tag)
Delete single tag/object relation from the db
Source:

lib/public/ITags.php#227

Parameters:
  • $objid (int) The id of the object
  • $tag (string) The id or name of the tag
Returns:

bool

Since:

6.0.0

public OCP\ITags::delete($names)
Delete tags from the database
Source:

lib/public/ITags.php#236

Parameters:
  • $names (string[] | int[]) An array of tags (names or IDs) to delete
Returns:

bool Returns false on error

Since:

6.0.0