Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
core_tag_tag Class Reference

Public Member Functions

 __get ($name)
 Magic getter. More...
 
 __isset ($name)
 Magic isset method. More...
 
 add_related_tags ($tagnames)
 Adds to the list of related tags without removing existing. More...
 
 combine_tags ($tags)
 Combines several other tags into this one. More...
 
 count_tagged_items ($component, $itemtype, $subquery='', $params=array())
 Count how many items are tagged with a specific tag. More...
 
 flag ()
 Flag a tag as inappropriate.
 
 get_correlated_tags ($keepduplicates=false)
 Returns the correlated tags of a tag, retrieved from the tag_correlation table. More...
 
 get_display_name ($ashtml=true)
 Returns tag name ready to be displayed. More...
 
 get_formatted_description ($options=array())
 Returns formatted description of the tag. More...
 
 get_links ()
 Returns the list of tag links available for the current user (edit, flag, etc.) More...
 
 get_manual_related_tags ()
 Returns tags that this tag was manually set as related to. More...
 
 get_related_tags ()
 Returns tags related to a tag. More...
 
 get_tag_index ($tagarea, $exclusivemode, $fromctx, $ctx, $rec, $page=0)
 Retrieves contents of tag area for the tag/index.php page. More...
 
 get_tagged_items ($component, $itemtype, $limitfrom='', $limitnum='', $subquery='', $params=array())
 Find all items tagged with a tag of a given type ('post', 'user', etc.) More...
 
 get_view_url ($exclusivemode=0, $fromctx=0, $ctx=0, $rec=1)
 Returns URL to view the tag. More...
 
 reset_flag ()
 Remove the inappropriate flag on a tag.
 
 set_related_tags ($tagnames)
 Sets the list of tags related to this one. More...
 
 to_object ()
 Converts to object. More...
 
 update ($data)
 Updates the information about the tag. More...
 

Static Public Member Functions

static add_item_tag ($component, $itemtype, $itemid, context $context, $tagname, $tiuserid=0)
 Adds a tag to an item, without overwriting the current tags. More...
 
static change_instances_context (array $taginstanceids, context $newcontext)
 Moves all of the specified tag instances into a new context. More...
 
static change_items_context ($component, $itemtype, $itemids, $newcontext)
 Moves all tags of the specified items to the new context. More...
 
static create_if_missing ($tagcollid, $tags, $isstandard=false)
 Retrieves tags and/or creates them if do not exist yet. More...
 
static delete_instances ($component, $itemtype=null, $contextid=null)
 Bulk delete all tag instances for a component or tag area. More...
 
static delete_instances_as_record (array $taginstances)
 Bulk delete all tag instances. More...
 
static delete_instances_by_id (array $taginstanceids)
 Bulk delete all tag instances by tag id. More...
 
static delete_tags ($tagids)
 Delete one or more tag, and all their instances if there are any left. More...
 
static get ($id, $returnfields='id, name, rawname, tagcollid', $strictness=IGNORE_MISSING)
 Simple function to just return a single tag object by its id. More...
 
static get_bulk ($ids, $returnfields='id, name, rawname, tagcollid')
 Simple function to just return an array of tag objects by their ids. More...
 
static get_by_name ($tagcollid, $name, $returnfields='id, name, rawname, tagcollid', $strictness=IGNORE_MISSING)
 Simple function to just return a single tag object by tagcollid and name. More...
 
static get_by_name_bulk ($tagcollid, $tags, $returnfields='id, name, rawname, tagcollid')
 Returns the list of tag objects by tag collection id and the list of tag names. More...
 
static get_item_tags ($component, $itemtype, $itemid, $standardonly=self::BOTH_STANDARD_AND_NOT, $tiuserid=0)
 Get the array of core_tag_tag objects associated with an item (instances). More...
 
static get_item_tags_array ($component, $itemtype, $itemid, $standardonly=self::BOTH_STANDARD_AND_NOT, $tiuserid=0, $ashtml=true)
 Returns the list of display names of the tags that are associated with an item. More...
 
static get_items_tags ($component, $itemtype, $itemids, $standardonly=self::BOTH_STANDARD_AND_NOT, $tiuserid=0)
 Get the array of core_tag_tag objects associated with a list of items. More...
 
static get_tags_by_area_in_contexts ($component, $itemtype, array $contexts)
 Retrieve a list of tags that have been used to tag the given $component and $itemtype in the provided $contexts. More...
 
static guess_by_name ($name, $returnfields='id, name, rawname, tagcollid')
 Looking in all tag collections for the tag with the given name. More...
 
static is_enabled ($component, $itemtype)
 Returns whether the tag area is enabled. More...
 
static is_item_tagged_with ($component, $itemtype, $itemid, $tagname)
 Determine if an item is tagged with a specific tag. More...
 
static make_display_name ($tag, $ashtml=true)
 Prepares tag name ready to be displayed. More...
 
static make_url ($tagcollid, $name, $exclusivemode=0, $fromctx=0, $ctx=0, $rec=1)
 Creates a URL to view a tag. More...
 
static move_context ($component, $itemtype, $oldcontext, $newcontext)
 Allows to move all tag instances from one context to another. More...
 
static normalize ($rawtags, $tolowercase=true)
 Function that normalizes a list of tag names. More...
 
static remove_all_item_tags ($component, $itemtype, $itemid, $tiuserid=0)
 Removes all tags from an item. More...
 
static remove_item_tag ($component, $itemtype, $itemid, $tagname, $tiuserid=0)
 Removes the tag from an item without changing the other tags. More...
 
static set_item_tags ($component, $itemtype, $itemid, context $context, $tagnames, $tiuserid=0)
 Sets the list of tag instances for one item (table record). More...
 

Public Attributes

int const BOTH_STANDARD_AND_NOT = 0
 indicates that both standard and not standard tags can be used (or should be returned)
 
int const HIDE_STANDARD = 2
 option to hide standard tags when editing item tags
 
int const NOT_STANDARD_ONLY = -1
 indicates that only non-standard tags should be returned - this does not really have use cases, left for BC

 
int const STANDARD_ONLY = 1
 indicates that only standard tags can be used (or must be returned)
 

Protected Member Functions

 __construct ($record)
 Constructor. More...
 
 add_instance ($component, $itemtype, $itemid, context $context, $ordering, $tiuserid=0)
 Adds a tag instance. More...
 
 combine_correlated_tags ($tags)
 Combine together correlated tags of several tags. More...
 
 delete_instance ($component, $itemtype, $itemid, $tiuserid=0)
 Delete one instance of a tag. More...
 
 delete_instance_as_record ($taginstance, $fullobject=false)
 Deletes the tag instance given the record from tag_instance DB table. More...
 
 ensure_fields_exist ($list, $caller)
 Validates that the required fields were retrieved and retrieves them if missing. More...
 
 update_instance_ordering ($instanceid, $ordering)
 Updates the ordering on tag instance. More...
 

Static Protected Member Functions

static add ($tagcollid, $tags, $isstandard=false)
 Adds one or more tag in the database. More...
 

Protected Attributes

stdClass $record = null
 data about the tag
 

Constructor & Destructor Documentation

◆ __construct()

core_tag_tag::__construct (   $record)
protected

Constructor.

Use functions get(), get_by_name(), etc.

Parameters
stdClass$record

Member Function Documentation

◆ __get()

core_tag_tag::__get (   $name)

Magic getter.

Parameters
string$name
Return values
mixed

◆ __isset()

core_tag_tag::__isset (   $name)

Magic isset method.

Parameters
string$name
Return values
bool

◆ add()

static core_tag_tag::add (   $tagcollid,
  $tags,
  $isstandard = false 
)
staticprotected

Adds one or more tag in the database.

This function should not be called directly : you should use tag_set.

Parameters
int$tagcollid
string | array$tagsone tag, or an array of tags, to be created
bool$isstandardtype of tag to be created. A standard tag is kept even if there are no records tagged with it.
Return values
arraytag objects indexed by their lowercase normalized names. Any boolean false in the array indicates an error while adding the tag.

◆ add_instance()

core_tag_tag::add_instance (   $component,
  $itemtype,
  $itemid,
context  $context,
  $ordering,
  $tiuserid = 0 
)
protected

Adds a tag instance.

Parameters
string$component
string$itemtype
string$itemid
context$context
int$ordering
int$tiuseridtag instance user id, only needed for tag areas with user tagging (such as core/course)
Return values
intid of tag_instance

◆ add_item_tag()

static core_tag_tag::add_item_tag (   $component,
  $itemtype,
  $itemid,
context  $context,
  $tagname,
  $tiuserid = 0 
)
static

Adds a tag to an item, without overwriting the current tags.

If the tag has already been added to the record, no changes are made.

Parameters
string$componentthe component that was tagged
string$itemtypethe type of record to tag ('post' for blogs, 'user' for users, etc.)
int$itemidthe id of the record to tag
context$contextthe context of where this tag was assigned
string$tagnamethe tag to add
int$tiuseridtag instance user id, only needed for tag areas with user tagging (such as core/course)
Return values
intid of tag_instance that was either created or already existed or null if tagging is not enabled

◆ add_related_tags()

core_tag_tag::add_related_tags (   $tagnames)

Adds to the list of related tags without removing existing.

Tag relations are recorded by two instances linking two tags to each other. For tag relations ordering is not used and may be random.

Parameters
array$tagnames

◆ change_instances_context()

static core_tag_tag::change_instances_context ( array  $taginstanceids,
context  $newcontext 
)
static

Moves all of the specified tag instances into a new context.

Parameters
array$taginstanceidsThe list of tag instance ids that should be moved
context$newcontextThe context to move the tag instances into

◆ change_items_context()

static core_tag_tag::change_items_context (   $component,
  $itemtype,
  $itemids,
  $newcontext 
)
static

Moves all tags of the specified items to the new context.

Parameters
string$componentthe component that was tagged
string$itemtypethe type of record to tag ('post' for blogs, 'user' for users, etc.)
array$itemids
context | int$newcontexttarget context to move tags to

◆ combine_correlated_tags()

core_tag_tag::combine_correlated_tags (   $tags)
protected

Combine together correlated tags of several tags.

This is a help method for method combine_tags()

Parameters
core_tag_tag[]$tags

◆ combine_tags()

core_tag_tag::combine_tags (   $tags)

Combines several other tags into this one.

Combining rules:

  • current tag becomes the "main" one, all instances pointing to other tags are changed to point to it.
  • if any of the tags is standard, the "main" tag becomes standard too
  • all tags except for the current ("main") are deleted, even when they are standard
Parameters
core_tag_tag[]$tagstags to combine into this one

◆ count_tagged_items()

core_tag_tag::count_tagged_items (   $component,
  $itemtype,
  $subquery = '',
  $params = array() 
)

Count how many items are tagged with a specific tag.

Parameters
string$componentcomponent responsible for tagging. For BC it can be empty but in this case the query will be slow because DB index will not be used.
string$itemtypetype to restrict search to
string$subqueryadditional query to be appended to WHERE clause, refer to the itemtable as 'it'
array$paramsadditional parameters for the DB query
Return values
intnumber of mathing tags.

◆ create_if_missing()

static core_tag_tag::create_if_missing (   $tagcollid,
  $tags,
  $isstandard = false 
)
static

Retrieves tags and/or creates them if do not exist yet.

Parameters
int$tagcollid
array$tagsarray of raw tag names, do not have to be normalised
bool$isstandardcreate as standard tag (default false)
Return values
core_tag_tag[]array of tag objects indexed with lowercase normalised tag name

◆ delete_instance()

core_tag_tag::delete_instance (   $component,
  $itemtype,
  $itemid,
  $tiuserid = 0 
)
protected

Delete one instance of a tag.

If the last instance was deleted, it will also delete the tag, unless it is standard.

Parameters
string$componentcomponent responsible for tagging. For BC it can be empty but in this case the query will be slow because DB index will not be used.
string$itemtypethe type of the record for which to remove the instance
int$itemidthe id of the record for which to remove the instance
int$tiuseridtag instance user id, only needed for tag areas with user tagging (such as core/course)

◆ delete_instance_as_record()

core_tag_tag::delete_instance_as_record (   $taginstance,
  $fullobject = false 
)
protected

Deletes the tag instance given the record from tag_instance DB table.

Parameters
stdClass$taginstance
bool$fullobjectwhether $taginstance contains all fields from DB table tag_instance (in this case it is safe to add a record snapshot to the event)
Return values
bool

◆ delete_instances()

static core_tag_tag::delete_instances (   $component,
  $itemtype = null,
  $contextid = null 
)
static

Bulk delete all tag instances for a component or tag area.

Parameters
string$component
string$itemtype(optional)
int$contextid(optional)

◆ delete_instances_as_record()

static core_tag_tag::delete_instances_as_record ( array  $taginstances)
static

Bulk delete all tag instances.

Parameters
stdClass[]$taginstancesA list of tag_instance records to delete. Each record must also contain the name and rawname columns from the related tag record.

◆ delete_instances_by_id()

static core_tag_tag::delete_instances_by_id ( array  $taginstanceids)
static

Bulk delete all tag instances by tag id.

Parameters
int[]$taginstanceidsList of tag instance ids to be deleted.

◆ delete_tags()

static core_tag_tag::delete_tags (   $tagids)
static

Delete one or more tag, and all their instances if there are any left.

Parameters
int | array$tagidsone tagid (int), or one array of tagids to delete
Return values
booltrue on success, false otherwise

◆ ensure_fields_exist()

core_tag_tag::ensure_fields_exist (   $list,
  $caller 
)
protected

Validates that the required fields were retrieved and retrieves them if missing.

Parameters
array$listarray of the fields that need to be validated
string$callername of the function that requested it, for the debugging message

◆ get()

static core_tag_tag::get (   $id,
  $returnfields = 'id,
name  ,
rawname  ,
tagcollid'  ,
  $strictness = IGNORE_MISSING 
)
static

Simple function to just return a single tag object by its id.

Parameters
int$id
string$returnfieldswhich fields do we want returned from table {tag}. Default value is 'id,name,rawname,tagcollid', specify '*' to include all fields.
int$strictnessIGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found; IGNORE_MULTIPLE means return first, ignore multiple records found(not recommended); MUST_EXIST means throw exception if no record or multiple records found
Return values
core_tag_tag|falsetag object

◆ get_bulk()

static core_tag_tag::get_bulk (   $ids,
  $returnfields = 'id,
name  ,
rawname  ,
tagcollid'   
)
static

Simple function to just return an array of tag objects by their ids.

Parameters
int[]$ids
string$returnfieldswhich fields do we want returned from table {tag}. Default value is 'id,name,rawname,tagcollid', specify '*' to include all fields.
Return values
core_tag_tag[]array of retrieved tags

◆ get_by_name()

static core_tag_tag::get_by_name (   $tagcollid,
  $name,
  $returnfields = 'id,
name  ,
rawname  ,
tagcollid'  ,
  $strictness = IGNORE_MISSING 
)
static

Simple function to just return a single tag object by tagcollid and name.

Parameters
int$tagcollidtag collection to use, if 0 is given we will try to guess the tag collection and return the first match
string$nametag name
string$returnfieldswhich fields do we want returned. This is a comma separated string containing any combination of 'id', 'name', 'rawname', 'tagcollid' or '*' to include all fields.
int$strictnessIGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found; IGNORE_MULTIPLE means return first, ignore multiple records found(not recommended); MUST_EXIST means throw exception if no record or multiple records found
Return values
core_tag_tag|falsetag object

◆ get_by_name_bulk()

static core_tag_tag::get_by_name_bulk (   $tagcollid,
  $tags,
  $returnfields = 'id,
name  ,
rawname  ,
tagcollid'   
)
static

Returns the list of tag objects by tag collection id and the list of tag names.

Parameters
int$tagcollid
array$tagsarray of tags to look for
string$returnfieldslist of DB fields to return, must contain 'id', 'name' and 'rawname'
Return values
arraytag-indexed array of objects. No value for a key means the tag wasn't found.

◆ get_correlated_tags()

core_tag_tag::get_correlated_tags (   $keepduplicates = false)

Returns the correlated tags of a tag, retrieved from the tag_correlation table.

Correlated tags are calculated in cron based on existing tag instances.

Parameters
bool$keepduplicatesif true, will return one record for each existing tag instance which may result in duplicates of the actual tags
Return values
core_tag_tag[]an array of tag objects

◆ get_display_name()

core_tag_tag::get_display_name (   $ashtml = true)

Returns tag name ready to be displayed.

Parameters
bool$ashtml(default true) if true will return htmlspecialchars encoded string
Return values
string

◆ get_formatted_description()

core_tag_tag::get_formatted_description (   $options = array())

Returns formatted description of the tag.

Parameters
array$options
Return values
string

◆ get_item_tags()

static core_tag_tag::get_item_tags (   $component,
  $itemtype,
  $itemid,
  $standardonly = self::BOTH_STANDARD_AND_NOT,
  $tiuserid = 0 
)
static

Get the array of core_tag_tag objects associated with an item (instances).

Use core_tag_tag::get_item_tags_array() if you wish to get the same data as simple array.

Parameters
string$componentcomponent responsible for tagging. For BC it can be empty but in this case the query will be slow because DB index will not be used.
string$itemtypetype of the tagged item
int$itemid
int$standardonlywether to return only standard tags or any
int$tiuseridtag instance user id, only needed for tag areas with user tagging
Return values
core_tag_tag[]each object contains additional fields taginstanceid, taginstancecontextid and ordering

◆ get_item_tags_array()

static core_tag_tag::get_item_tags_array (   $component,
  $itemtype,
  $itemid,
  $standardonly = self::BOTH_STANDARD_AND_NOT,
  $tiuserid = 0,
  $ashtml = true 
)
static

Returns the list of display names of the tags that are associated with an item.

This method is usually used to prefill the form data for the 'tags' form element

Parameters
string$componentcomponent responsible for tagging. For BC it can be empty but in this case the query will be slow because DB index will not be used.
string$itemtypetype of the tagged item
int$itemid
int$standardonlywether to return only standard tags or any
int$tiuseridtag instance user id, only needed for tag areas with user tagging
bool$ashtml(default true) if true will return htmlspecialchars encoded tag names
Return values
string[]array of tags display names

◆ get_items_tags()

static core_tag_tag::get_items_tags (   $component,
  $itemtype,
  $itemids,
  $standardonly = self::BOTH_STANDARD_AND_NOT,
  $tiuserid = 0 
)
static

Get the array of core_tag_tag objects associated with a list of items.

Use core_tag_tag::get_item_tags_array() if you wish to get the same data as simple array.

Parameters
string$componentcomponent responsible for tagging. For BC it can be empty but in this case the query will be slow because DB index will not be used.
string$itemtypetype of the tagged item
int[]$itemids
int$standardonlywether to return only standard tags or any
int$tiuseridtag instance user id, only needed for tag areas with user tagging
Return values
core_tag_tag[][]first array key is itemid. For each itemid, an array tagid => tag object with additional fields taginstanceid, taginstancecontextid and ordering

◆ get_links()

core_tag_tag::get_links ( )

Returns the list of tag links available for the current user (edit, flag, etc.)

Return values
array

◆ get_manual_related_tags()

core_tag_tag::get_manual_related_tags ( )

Returns tags that this tag was manually set as related to.

Return values
core_tag_tag[]

◆ get_related_tags()

core_tag_tag::get_related_tags ( )

Returns tags related to a tag.

Related tags of a tag come from two sources:

  • manually added related tags, which are tag_instance entries for that tag
  • correlated tags, which are calculated
Return values
core_tag_tag[]an array of tag objects

◆ get_tag_index()

core_tag_tag::get_tag_index (   $tagarea,
  $exclusivemode,
  $fromctx,
  $ctx,
  $rec,
  $page = 0 
)

Retrieves contents of tag area for the tag/index.php page.

Parameters
stdClass$tagarea
bool$exclusivemodeif set to true it means that no other entities tagged with this tag are displayed on the page and the per-page limit may be bigger
int$fromctxcontext id where the link was displayed, may be used by callbacks to display items in the same context first
int$ctxcontext id where to search for records
bool$recsearch in subcontexts as well
int$page0-based number of page being displayed
Return values
core_tag

◆ get_tagged_items()

core_tag_tag::get_tagged_items (   $component,
  $itemtype,
  $limitfrom = '',
  $limitnum = '',
  $subquery = '',
  $params = array() 
)

Find all items tagged with a tag of a given type ('post', 'user', etc.)

Parameters
string$componentcomponent responsible for tagging. For BC it can be empty but in this case the query will be slow because DB index will not be used.
string$itemtypetype to restrict search to
int$limitfrom(optional, required if $limitnum is set) return a subset of records, starting at this point.
int$limitnum(optional, required if $limitfrom is set) return a subset comprising this many records.
string$subqueryadditional query to be appended to WHERE clause, refer to the itemtable as 'it'
array$paramsadditional parameters for the DB query
Return values
arrayof matching objects, indexed by record id, from the table containing the type requested

◆ get_tags_by_area_in_contexts()

static core_tag_tag::get_tags_by_area_in_contexts (   $component,
  $itemtype,
array  $contexts 
)
static

Retrieve a list of tags that have been used to tag the given $component and $itemtype in the provided $contexts.

Parameters
string$componentThe tag instance component
string$itemtypeThe tag instance item type
context[]$contextsThe list of contexts to look for tag instances in
Return values
core_tag_tag[]

◆ get_view_url()

core_tag_tag::get_view_url (   $exclusivemode = 0,
  $fromctx = 0,
  $ctx = 0,
  $rec = 1 
)

Returns URL to view the tag.

Parameters
int$exclusivemode
int$fromctxcontext id where this tag cloud is displayed
int$ctxcontext id for tag view link
int$recrecursive argument for tag view link
Return values
moodle_url

◆ guess_by_name()

static core_tag_tag::guess_by_name (   $name,
  $returnfields = 'id,
name  ,
rawname  ,
tagcollid'   
)
static

Looking in all tag collections for the tag with the given name.

Parameters
string$nametag name
string$returnfields
Return values
arrayarray of core_tag_tag instances

◆ is_enabled()

static core_tag_tag::is_enabled (   $component,
  $itemtype 
)
static

Returns whether the tag area is enabled.

Parameters
string$componentcomponent responsible for tagging
string$itemtypewhat is being tagged, for example, 'post', 'course', 'user', etc.
Return values
bool|null

◆ is_item_tagged_with()

static core_tag_tag::is_item_tagged_with (   $component,
  $itemtype,
  $itemid,
  $tagname 
)
static

Determine if an item is tagged with a specific tag.

Note that this is a static method and not a method of core_tag object because the tag might not exist yet, for example user searches for "php" and we offer him to add "php" to his interests.

Parameters
string$componentcomponent responsible for tagging. For BC it can be empty but in this case the query will be slow because DB index will not be used.
string$itemtypethe record type to look for
int$itemidthe record id to look for
string$tagnamea tag name
Return values
int1 if it is tagged, 0 otherwise

◆ make_display_name()

static core_tag_tag::make_display_name (   $tag,
  $ashtml = true 
)
static

Prepares tag name ready to be displayed.

Parameters
stdClass | core_tag_tag$tagrecord from db table tag, must contain properties name and rawname
bool$ashtml(default true) if true will return htmlspecialchars encoded string
Return values
string

◆ make_url()

static core_tag_tag::make_url (   $tagcollid,
  $name,
  $exclusivemode = 0,
  $fromctx = 0,
  $ctx = 0,
  $rec = 1 
)
static

Creates a URL to view a tag.

Parameters
int$tagcollid
string$name
int$exclusivemode
int$fromctxcontext id where this tag cloud is displayed
int$ctxcontext id for tag view link
int$recrecursive argument for tag view link
Return values
moodle_url

◆ move_context()

static core_tag_tag::move_context (   $component,
  $itemtype,
  $oldcontext,
  $newcontext 
)
static

Allows to move all tag instances from one context to another.

Parameters
string$componentthe component that was tagged
string$itemtypethe type of record to tag ('post' for blogs, 'user' for users, etc.)
context$oldcontext
context$newcontext

◆ normalize()

static core_tag_tag::normalize (   $rawtags,
  $tolowercase = true 
)
static

Function that normalizes a list of tag names.

Parameters
array$rawtagsarray of tags
bool$tolowercaseconvert to lower case?
Return values
arraylowercased normalized tags, indexed by the normalized tag, in the same order as the original array. (Eg: 'Banana' => 'banana').

◆ remove_all_item_tags()

static core_tag_tag::remove_all_item_tags (   $component,
  $itemtype,
  $itemid,
  $tiuserid = 0 
)
static

Removes all tags from an item.

All tags will be removed even if tagging is disabled in this area. This is usually called when the item itself has been deleted.

Parameters
string$componentcomponent responsible for tagging
string$itemtypetype of the tagged item
int$itemid
int$tiuseridtag instance user id, only needed for tag areas with user tagging (such as core/course)

◆ remove_item_tag()

static core_tag_tag::remove_item_tag (   $component,
  $itemtype,
  $itemid,
  $tagname,
  $tiuserid = 0 
)
static

Removes the tag from an item without changing the other tags.

Parameters
string$componentthe component that was tagged
string$itemtypethe type of record to tag ('post' for blogs, 'user' for users, etc.)
int$itemidthe id of the record to tag
string$tagnamethe tag to remove
int$tiuseridtag instance user id, only needed for tag areas with user tagging (such as core/course)

◆ set_item_tags()

static core_tag_tag::set_item_tags (   $component,
  $itemtype,
  $itemid,
context  $context,
  $tagnames,
  $tiuserid = 0 
)
static

Sets the list of tag instances for one item (table record).

Extra exsisting instances are removed, new ones are added. New tags are created if needed.

This method can not be used for setting tags relations, please use set_related_tags()

Parameters
string$componentcomponent responsible for tagging
string$itemtypetype of the tagged item
int$itemid
context$context
array$tagnames
int$tiuseridtag instance user id, only needed for tag areas with user tagging (such as core/course)

◆ set_related_tags()

core_tag_tag::set_related_tags (   $tagnames)

Sets the list of tags related to this one.

Tag relations are recorded by two instances linking two tags to each other. For tag relations ordering is not used and may be random.

Parameters
array$tagnames

◆ to_object()

core_tag_tag::to_object ( )

Converts to object.

Return values
stdClass

◆ update()

core_tag_tag::update (   $data)

Updates the information about the tag.

Parameters
array | stdClass$datadata to update, may contain: isstandard, description, descriptionformat, rawname
Return values
boolwhether the tag was updated. False may be returned if: all new values match the existing, or it was attempted to rename the tag to the name that is already used.

◆ update_instance_ordering()

core_tag_tag::update_instance_ordering (   $instanceid,
  $ordering 
)
protected

Updates the ordering on tag instance.

Parameters
int$instanceid
int$ordering

The documentation for this class was generated from the following file: