Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Class core_tag_area for managing tag areas

Copyright: 2015 Marina Glancy
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 512 lines (22 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: core_tag_area  - X-Ref

Class to manage tag areas

get_areas($tagcollid = null, $enabledonly = false)   X-Ref
Returns the list of areas indexed by itemtype and component

param: int $tagcollid return only areas in this tag collection
param: bool $enabledonly return only enabled tag areas
return: array itemtype=>component=>tagarea object

get_by_id($tagareaid)   X-Ref
Retrieves info about one tag area

param: int $tagareaid
return: stdClass

display_name($component, $itemtype)   X-Ref
Returns the display name for this area

param: string $component
param: string $itemtype
return: lang_string

is_enabled($component, $itemtype)   X-Ref
Returns whether the tag area is enabled

param: string $component component responsible for tagging
param: string $itemtype what is being tagged, for example, 'post', 'course', 'user', etc.
return: bool|null

allows_tagging_in_multiple_contexts($component, $itemtype)   X-Ref
Checks if the tag area allows items to be tagged in multiple different contexts.

If true then it indicates that not all tag instance contexts must match the
context of the item they are tagging. If false then all tag instance should
match the context of the item they are tagging.

Example use case for multi-context tagging:
A question that exists in a course category context may be used by multiple
child courses. The question tag area can allow tag instances to be created in
multiple contexts which allows the tag API to tag the question at the course
category context and then seperately in each of the child course contexts.

param: string $component component responsible for tagging
param: string $itemtype what is being tagged, for example, 'post', 'course', 'user', etc.
return: bool

get_collection($component, $itemtype)   X-Ref
Returns the id of the tag collection that should be used for storing tags of this itemtype

param: string $component component responsible for tagging
param: string $itemtype what is being tagged, for example, 'post', 'course', 'user', etc.
return: int

get_showstandard($component, $itemtype)   X-Ref
Returns wether this tag area should display or not standard tags when user edits it.

param: string $component component responsible for tagging
param: string $itemtype what is being tagged, for example, 'post', 'course', 'user', etc.
return: int

get_definitions_for_component($componentname)   X-Ref
Returns all tag areas and collections that are currently cached in DB for this component

param: string $componentname
return: array first element is the list of areas and the second list of collections

delete($record)   X-Ref
Completely delete a tag area and all instances inside it

param: stdClass $record

create($record)   X-Ref
Create a new tag area

param: stdClass $record

update($existing, $data)   X-Ref
Update the tag area

param: stdClass $existing current record from DB table tag_area
param: array|stdClass $data fields that need updating

reset_definitions_for_component($componentname)   X-Ref
Update the database to contain a list of tagged areas for a component.
The list of tagged areas is read from [plugindir]/db/tag.php

param: string $componentname - The frankenstyle component name.

uninstall($pluginname)   X-Ref
Deletes all tag areas, collections and instances associated with the plugin.

param: string $pluginname

move_tags($component, $itemtype, $tagcollid)   X-Ref
Moves existing tags associated with an item type to another tag collection

param: string $component
param: string $itemtype
param: int $tagcollid