Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
core_privacy\manager Class Reference

The core_privacy\manager class, providing a facade to describe, export and delete personal data across Moodle and its components. More...

Public Member Functions

 component_is_compliant (string $component)
 Checks whether the given component is compliant with the core_privacy API.
 
 delete_data_for_all_users_in_context (\context $context)
 Delete all use data which matches the specified deletion criteria.
 
 delete_data_for_user (contextlist_collection $contextlistcollection)
 Delete all user data for approved contexts lists provided in the collection.
 
 delete_data_for_users_in_context (\core_privacy\local\request\userlist_collection $collection)
 Delete all user data for all specified users in a context.
 
 export_user_data (contextlist_collection $contextlistcollection)
 Export all user data for the specified approved_contextlist items.
 
 get_contexts_for_userid (int $userid)
 Gets a collection of resultset objects for all components.
 
 get_metadata_for_components ()
 Get the privacy metadata for all components.
 
 get_null_provider_reason (string $component)
 Retrieve the reason for implementing the null provider interface.
 
 get_users_in_context (\context $context)
 Gets a collection of users for all components in the specified context.
 
 set_observer (manager_observer $observer)
 Set the failure handler.
 

Static Public Member Functions

static component_class_callback (string $component, string $interface, string $methodname, array $params)
 Call the named method with the specified params on the supplied component if it implements the relevant interface on its provider.
 
static get_provider_classname_for_component (string $component)
 Return the fully qualified provider classname for the component.
 
static is_empty_subsystem ($component)
 Return whether this is an 'empty' subsystem - that is, a subsystem without a directory.
 
static plugintype_class_callback (string $plugintype, string $interface, string $methodname, array $params)
 Call the named method with the specified params on any plugintype implementing the relevant interface.
 

Protected Member Functions

 component_class_callback_failed (\Throwable $e, string $component, string $interface, string $methodname, array $params)
 Notifies the observer of any failure.
 
 component_implements (string $component, string $interface)
 Checks whether the component's provider class implements the specified interface.
 
 get_component_list ()
 Returns a list of frankenstyle names of core components (plugins and subsystems).
 
 get_provider_classname ($component)
 Return the fully qualified provider classname for the component.
 
 handled_component_class_callback (string $component, string $interface, string $methodname, array $params)
 Call the named method with the specified params on the supplied component if it implements the relevant interface on its provider.
 

Static Protected Member Functions

static get_log_tracer ()
 Get the tracer used for logging.
 

Protected Attributes

manager_observer $observer
 Observer.
 

Detailed Description

The core_privacy\manager class, providing a facade to describe, export and delete personal data across Moodle and its components.

This class is responsible for communicating with and collating privacy data from all relevant components, where relevance is determined through implementations of specific marker interfaces. These marker interfaces describe the responsibilities (in terms of personal data storage) as well as the relationship between the component and the core_privacy subsystem.

The interface hierarchy is as follows: ├── local\metadata\null_provider ├── local\metadata\provider ├── local\request\data_provider └── local\request\core_data_provider └── local\request\core_user_data_provider └── local\request\plugin\provider └── local\request\subsystem\provider └── local\request\user_preference_provider └── local\request\shared_data_provider └── local\request\plugin\subsystem_provider └── local\request\plugin\subplugin_provider └── local\request\subsystem\plugin_provider

Describing personal data:

All components must state whether they store personal data (and DESCRIBE it) by implementing one of the metadata providers:

  • local\metadata\null_provider (indicating they don't store personal data)
  • local\metadata\provider (indicating they do store personal data, and describing it)

The manager requests metadata for all Moodle components implementing the local\metadata\provider interface.

Export and deletion of personal data:

Those components storing personal data need to provide EXPORT and DELETION of this data by implementing a request provider. Which provider implementation depends on the nature of the component; whether it's a sub-component and which components it stores data for.

Export and deletion for sub-components (or any component storing data on behalf of another component) is managed by the parent component. If a component contains sub-components, it must ask those sub-components to provide the relevant data. Only certain 'core provider' components are called directly from the manager and these must provide the personal data stored by both themselves, and by all sub-components. Because of this hierarchical structure, the core_privacy\manager needs to know which components are to be called directly by core: these are called core data providers. The providers implemented by sub-components are called shared data providers.

The following are interfaces are not implemented directly, but are marker interfaces uses to classify components by nature:

  • local\request\data_provider: Not implemented directly. Used to classify components storing personal data of some kind. Includes both components storing personal data for themselves and on behalf of other components. Include: local\request\core_data_provider and local\request\shared_data_provider.
  • local\request\core_data_provider: Not implemented directly. Used to classify components storing personal data for themselves and which are to be called by the core_privacy subsystem directly. Includes: local\request\core_user_data_provider and local\request\user_preference_provider.
  • local\request\core_user_data_provider: Not implemented directly. Used to classify components storing personal data for themselves, which are either a plugin or subsystem and which are to be called by the core_privacy subsystem directly. Includes: local\request\plugin\provider and local\request\subsystem\provider.
  • local\request\shared_data_provider: Not implemented directly. Used to classify components storing personal data on behalf of other components and which are called by the owning component directly. Includes: local\request\plugin\subsystem_provider, local\request\plugin\subplugin_provider and local\request\subsystem\plugin_provider

The manager only requests the export or deletion of personal data for components implementing the local\request\core_data_provider interface or one of its descendants; local\request\plugin\provider, local\request\subsystem\provider or local\request\user_preference_provider. Implementing one of these signals to the core_privacy subsystem that the component must be queried directly from the manager.

Any component using another component to store personal data on its behalf, is responsible for making the relevant call to that component's relevant shared_data_provider class.

For example: The manager calls a core_data_provider component (e.g. mod_assign) which, in turn, calls relevant subplugins or subsystems (which assign uses to store personal data) to get that data. All data for assign and its sub-components is aggregated by assign and returned to the core_privacy subsystem.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ component_class_callback()

static core_privacy\manager::component_class_callback ( string $component,
string $interface,
string $methodname,
array $params )
static

Call the named method with the specified params on the supplied component if it implements the relevant interface on its provider.

Parameters
string$componentThe component to call
string$interfaceThe interface to implement
string$methodnameThe method to call
array$paramsThe params to call
Return values
mixed

◆ component_class_callback_failed()

core_privacy\manager::component_class_callback_failed ( \Throwable $e,
string $component,
string $interface,
string $methodname,
array $params )
protected

Notifies the observer of any failure.

Parameters
Throwable$e
string$component
string$interface
string$methodname
array$params

◆ component_implements()

core_privacy\manager::component_implements ( string $component,
string $interface )
protected

Checks whether the component's provider class implements the specified interface.

This can either be implemented directly, or by implementing a descendant (extension) of the specified interface.

Parameters
string$componentthe frankenstyle component name.
string$interfacethe name of the interface we want to check.
Return values
boolTrue if an implementation was found, false otherwise.

◆ component_is_compliant()

core_privacy\manager::component_is_compliant ( string $component)

Checks whether the given component is compliant with the core_privacy API.

To be considered compliant, a component must declare whether (and where) it stores personal data.

Components which do store personal data must:

Components which do not store personal data must:

Parameters
string$componentfrankenstyle component name, e.g. 'mod_assign'
Return values
booltrue if the component is compliant, false otherwise.

◆ delete_data_for_all_users_in_context()

core_privacy\manager::delete_data_for_all_users_in_context ( \context $context)

Delete all use data which matches the specified deletion criteria.

Parameters
context$contextThe specific context to delete data for.

◆ delete_data_for_user()

core_privacy\manager::delete_data_for_user ( contextlist_collection $contextlistcollection)

Delete all user data for approved contexts lists provided in the collection.

This call relates to the forgetting of an entire user.

Note: userid and component are stored in each respective approved_contextlist.

Parameters
contextlist_collection$contextlistcollectionthe collections of approved_contextlist items on which to call deletion.
Exceptions
moodle_exceptionif the contextlist_collection doesn't contain all approved_contextlist items, or if the component for an approved_contextlist isn't a core provider.

◆ delete_data_for_users_in_context()

core_privacy\manager::delete_data_for_users_in_context ( \core_privacy\local\request\userlist_collection $collection)

Delete all user data for all specified users in a context.

Parameters
core_privacy\local\request\userlist_collection$collection

◆ export_user_data()

core_privacy\manager::export_user_data ( contextlist_collection $contextlistcollection)

Export all user data for the specified approved_contextlist items.

Note: userid and component are stored in each respective approved_contextlist.

Parameters
contextlist_collection$contextlistcollectionthe collection of contextlists for all components.
Return values
stringthe location of the exported data.
Exceptions
moodle_exceptionif the contextlist_collection does not contain all approved_contextlist items or if one of the approved_contextlists' components is not a core_data_provider.

◆ get_component_list()

core_privacy\manager::get_component_list ( )
protected

Returns a list of frankenstyle names of core components (plugins and subsystems).

Return values
arraythe array of frankenstyle component names.

◆ get_contexts_for_userid()

core_privacy\manager::get_contexts_for_userid ( int $userid)

Gets a collection of resultset objects for all components.

Parameters
int$useridthe id of the user we're fetching contexts for.
Return values
contextlist_collectionthe collection of contextlist items for the respective components.

◆ get_log_tracer()

static core_privacy\manager::get_log_tracer ( )
staticprotected

Get the tracer used for logging.

The text tracer is used except for unit tests.

Return values
progress_trace

◆ get_metadata_for_components()

core_privacy\manager::get_metadata_for_components ( )

Get the privacy metadata for all components.

Return values
collection[]The array of collection objects, indexed by frankenstyle component name.

◆ get_null_provider_reason()

core_privacy\manager::get_null_provider_reason ( string $component)

Retrieve the reason for implementing the null provider interface.

Parameters
string$componentFrankenstyle component name.
Return values
stringThe key to retrieve the language string for the null provider reason.

◆ get_provider_classname()

core_privacy\manager::get_provider_classname ( $component)
protected

Return the fully qualified provider classname for the component.

Parameters
string$componentthe frankenstyle component name.
Return values
stringthe fully qualified provider classname.

◆ get_provider_classname_for_component()

static core_privacy\manager::get_provider_classname_for_component ( string $component)
static

Return the fully qualified provider classname for the component.

Parameters
string$componentthe frankenstyle component name.
Return values
stringthe fully qualified provider classname.

◆ get_users_in_context()

core_privacy\manager::get_users_in_context ( \context $context)

Gets a collection of users for all components in the specified context.

Parameters
context$contextThe context to search
Return values
userlist_collectionthe collection of userlist items for the respective components.

◆ handled_component_class_callback()

core_privacy\manager::handled_component_class_callback ( string $component,
string $interface,
string $methodname,
array $params )
protected

Call the named method with the specified params on the supplied component if it implements the relevant interface on its provider.

Parameters
string$componentThe component to call
string$interfaceThe interface to implement
string$methodnameThe method to call
array$paramsThe params to call
Return values
mixed

◆ is_empty_subsystem()

static core_privacy\manager::is_empty_subsystem ( $component)
static

Return whether this is an 'empty' subsystem - that is, a subsystem without a directory.

Parameters
string$componentFrankenstyle component name.
Return values
stringThe key to retrieve the language string for the null provider reason.

◆ plugintype_class_callback()

static core_privacy\manager::plugintype_class_callback ( string $plugintype,
string $interface,
string $methodname,
array $params )
static

Call the named method with the specified params on any plugintype implementing the relevant interface.

Parameters
string$plugintypeThe plugingtype to check
string$interfaceThe interface to implement
string$methodnameThe method to call
array$paramsThe params to call

◆ set_observer()

core_privacy\manager::set_observer ( manager_observer $observer)

Set the failure handler.

Parameters
manager_observer$observer

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