Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 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

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

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.

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

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.

param: \context $context
return: array

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

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

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.

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

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.

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.
return: int[]

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

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