Tags¶
-
class
OC\
Tags
¶ Source: lib/private/Tags.php#52 Implements: OCP\ITags
Constants¶
-
TAG_TABLE = *PREFIX*vcategory
Source: lib/private/Tags.php#112
-
RELATION_TABLE = *PREFIX*vcategory_to_object
Source: lib/private/Tags.php#113
Properties¶
Methods¶
-
public
OC\Tags::
__construct
($mapper, $user, $type, $defaultTags=[])¶ - Constructor.
Source: Parameters: - $mapper (
OC\Tagging\TagMapper
) Instance of the TagMapper abstraction layer. - $user (string) The user whose data the object will operate on.
- $type (string) The type of items for which tags will be loaded.
- $defaultTags (array) Tags that should be created at construction.
since 20.0.0 $includeShared isn’t used anymore
- $mapper (
-
public
OC\Tags::
isEmpty
()¶ - Check if any tags are saved for this type and user.
Source: lib/private/Tags.php#142 Returns: bool
-
public
OC\Tags::
getTag
($id)¶ - Returns an array mapping a given tag’s properties to its values:[‘id’ => 0, ‘name’ = ‘Tag’, ‘owner’ = ‘User’, ‘type’ => ‘tagtype’]
Source: Parameters: - $id (string) The ID of the tag that is going to be mapped
Returns: array | bool
-
public
OC\Tags::
getTags
()¶ - Get the tags for a specific user.This returns an array with maps containing each tag’s properties:[[‘id’ => 0, ‘name’ = ‘First tag’, ‘owner’ = ‘User’, ‘type’ => ‘tagtype’],[‘id’ => 1, ‘name’ = ‘Shared tag’, ‘owner’ = ‘Other user’, ‘type’ => ‘tagtype’],]
Source: lib/private/Tags.php#172 Returns: array
-
public
OC\Tags::
getTagsForUser
($user)¶ - Return only the tags owned by the given user, omitting any tags sharedby other users.
Source: Parameters: - $user (string) The user whose tags are to be checked.
Returns: array An array of Tag objects.
-
public
OC\Tags::
getTagsForObjects
($objIds)¶ - Get the list of tags for the given ids.
Source: Parameters: - $objIds (array) array of object ids
Returns: array | bool of tags id as key to array of tag names or false if an error occurred
-
public
OC\Tags::
getIdsForTag
($tag)¶ - Get the a list if items tagged with $tag.Throws an exception if the tag could not be found.
Source: Parameters: - $tag (string) Tag id or name.
Returns: array | bool An array of object ids or false on error.
Throws: \Exception
-
public
OC\Tags::
userHasTag
($name, $user)¶ - Checks whether a tag is saved for the given user,disregarding the ones shared with him or her.
Source: Parameters: - $name (string) The tag name to check for.
- $user (string) The user whose tags are to be checked.
Returns: bool
-
public
OC\Tags::
hasTag
($name)¶ - Checks whether a tag is saved for or shared with the current user.
Source: Parameters: - $name (string) The tag name to check for.
Returns: bool
-
public
OC\Tags::
add
($name)¶ - Add a new tag.
Source: Parameters: - $name (string) A string with a name of the tag
Returns: bool | int the id of the added tag or false on error.
-
public
OC\Tags::
rename
($from, $to)¶ - Rename tag.
Source: Parameters: - $from (string | int) The name or ID of the existing tag
- $to (string) The new name of the tag.
Returns: bool
-
public
OC\Tags::
addMultiple
($names, $sync=false, $id=null)¶ - Add a list of new tags.
Source: Parameters: - $names (string[]) A string with a name or an array of strings containing
the name(s) of the tag(s) 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.
-
protected
OC\Tags::
save
()¶ - Save the list of tags and their object relations
Source: lib/private/Tags.php#446
-
public static
OC\Tags::
post_deleteUser
($arguments)¶ - Delete tags and tag/object relations for a user.For hooking up on post_deleteUser
Source: Parameters: - $arguments (array)
-
public
OC\Tags::
purgeObjects
($ids)¶ - Delete tag/object relations from the db
Source: Parameters: - $ids (array) The ids of the objects
Returns: bool Returns false on error.
-
public
OC\Tags::
getFavorites
()¶ - Get favorites for an object type
Source: lib/private/Tags.php#603 Returns: array | bool An array of object ids.
-
public
OC\Tags::
addToFavorites
($objid)¶ - Add an object to favorites
Source: Parameters: - $objid (int) The id of the object
Returns: bool
-
public
OC\Tags::
removeFromFavorites
($objid)¶ - Remove an object from favorites
Source: Parameters: - $objid (int) The id of the object
Returns: bool
-
public
OC\Tags::
tagAs
($objid, $tag)¶ - Creates a tag/object relation.
Source: Parameters: - $objid (int) The id of the object
- $tag (string) The id or name of the tag
Returns: bool Returns false on error.
-
public
OC\Tags::
unTag
($objid, $tag)¶ - Delete single tag/object relation from the db
Source: Parameters: - $objid (int) The id of the object
- $tag (string) The id or name of the tag
Returns: bool
-
public
OC\Tags::
delete
($names)¶ - Delete tags from the database.
Source: Parameters: - $names (string[] | int[]) An array of tags (names or IDs) to delete
Returns: bool Returns false on error
-
protected
OC\Tags::
array_searchi
($needle, $haystack, $mem=getName)¶ Source: lib/private/Tags.php#776