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.

Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

Data registry business logic methods. Mostly internal stuff. All methods should be considered part of the internal tool_dataprivacy API unless something different is specified.

Copyright: 2018 David Monllao
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 355 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: data_registry  - X-Ref

Data registry business logic methods. Mostly internal stuff.

var_names_from_context($classname, $pluginname = '')   X-Ref
Returns purpose and category var names from a context class name

return: string[]
param: string $classname The context level's class.
param: string $pluginname The name of the plugin associated with the context level.

get_defaults($contextlevel, $pluginname = '')   X-Ref
Returns the default purpose id and category id for the provided context level.

The caller code is responsible of checking that $contextlevel is an integer.

return: int[]|false[]
param: int $contextlevel The context level.
param: string $pluginname The name of the plugin associated with the context level.

defaults_set()   X-Ref
Are data registry defaults set?

At least the system defaults need to be set.

return: bool

get_site_categories()   X-Ref
Returns all site categories that are visible to the current user.

return: \core_course_category[]

get_subject_scope(\context $context)   X-Ref
Returns the roles assigned to the provided level.

Important to note that it returns course-level assigned roles
if the provided context level is below course.

return: array
param: \context $context

get_effective_context_value(\context $context, $element, $forcedvalue = false)   X-Ref
Returns the effective value given a context instance

return: persistent|false It return a 'purpose' instance or a 'category' instance, depending on $element
param: \context $context
param: string $element 'category' or 'purpose'
param: int|false $forcedvalue Use this value as if this was this context instance value.

get_effective_contextlevel_value($contextlevel, $element)   X-Ref
Returns the effective value for a context level.

Note that this is different from the effective default context level
(see get_effective_default_contextlevel_purpose_and_category) as this is returning
the value set in the data registry, not in the defaults page.

return: \tool_dataprivacy\purpose|false
param: int $contextlevel
param: string $element 'category' or 'purpose'

get_effective_default_contextlevel_purpose_and_category($contextlevel, $forcedpurposevalue = false,$forcedcategoryvalue = false, $component = '')   X-Ref
Returns the effective default purpose and category for a context level.

return: int[]
param: int $contextlevel
param: int|bool $forcedpurposevalue Use this value as if this was this context level purpose.
param: int|bool $forcedcategoryvalue Use this value as if this was this context level category.
param: string $component The name of the component to check.

get_element_instance($element, $id)   X-Ref
Returns an instance of the provided element.

return: \core\persistent
param: string $element The element name 'purpose' or 'category'
param: int $id The element id