Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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

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

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

return: stdClass
param: int $tagareaid

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

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

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

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

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.

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

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

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

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

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

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

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

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