Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
|
Class containing helper methods for processing data requests. More...
Static Public Member Functions | |
static | add_request_contexts_with_status (contextlist_collection $clcollection, int $requestid, int $status) |
Adds the contexts from the contextlist_collection to the request with the status provided. | |
static | approve_contexts_belonging_to_request (int $requestid, array $coursecontextids=[]) |
Only approve the contexts which are children of the provided course contexts. | |
static | approve_data_request ($requestid, $filtercoursecontexts=[]) |
Approves a data request based on the request ID. | |
static | can_contact_dpo () |
Determines whether the user can contact the site's Data Protection Officer via Moodle. | |
static | can_create_data_deletion_request_for_children (int $userid, int $requesterid=null) |
Check if parent can create data deletion request for their children. | |
static | can_create_data_deletion_request_for_other (int $userid=null) |
Check if user has permission to create data deletion request for another user. | |
static | can_create_data_deletion_request_for_self (int $userid=null) |
Check if user has permisson to create data deletion request for themselves. | |
static | can_create_data_download_request_for_self (int $userid=null) |
Check if user has permission to create data download request for themselves. | |
static | can_create_data_request_for_user ($user, $requester=null) |
Checks whether a non-DPO user can make a data request for another user. | |
static | can_download_data_request_for_user ($userid, $requesterid, $downloaderid=null) |
Checks whether a user can download a data request. | |
static | can_manage_data_requests ($userid) |
Checks whether the current user has the capability to manage data requests. | |
static | check_can_manage_data_registry ($contextid=false) |
Checks if the current user can manage the data registry at the provided id. | |
static | create_category (stdClass $record) |
Creates a new data category. | |
static | create_data_request ($foruser, $type, $comments='', $creationmethod=data_request::DATAREQUEST_CREATION_MANUAL, $notify=null) |
Lodges a data request and sends the request details to the site Data Protection Officer(s). | |
static | create_expired_context ($contextid) |
Creates an expired context record for the provided context id. | |
static | create_purpose (stdClass $record) |
Creates a new data purpose. | |
static | delete_category ($id) |
Deletes a data category. | |
static | delete_expired_context ($id) |
Deletes an expired context record. | |
static | delete_purpose ($id) |
Deletes a data purpose. | |
static | deny_data_request ($requestid) |
Rejects a data request based on the request ID. | |
static | find_ongoing_request_types_for_users (array $userids) |
Find whether any ongoing requests exist for a set of users. | |
static | format_retention_period (\DateInterval $interval) |
Format the supplied date interval as a retention period. | |
static | get_approved_contextlist_collection_for_collection (contextlist_collection $collection, stdClass $foruser, int $type) |
Finds all contextlists having at least one approved context, and returns them as in a contextlist_collection. | |
static | get_approved_contextlist_collection_for_request (data_request $request) |
Finds all request contextlists having at least on approved context, and returns them as in a contextlist_collection. | |
static | get_assigned_privacy_officer_roles () |
Fetches the list of configured privacy officer roles. | |
static | get_categories () |
Get all system data categories. | |
static | get_course_contexts_for_view_filter (int $requestid) |
Get list of course context for user to filter. | |
static | get_data_requests ($userid=0, $statuses=[], $types=[], $creationmethods=[], $sort='', $offset=0, $limit=0) |
Fetches the list of the data requests. | |
static | get_data_requests_count ($userid=0, $statuses=[], $types=[], $creationmethods=[]) |
Fetches the count of data request records based on the given parameters. | |
static | get_download_link (\context_user $usercontext, $requestid) |
Gets an action menu link to download a data request. | |
static | get_dpo_role_names () |
Fetches the role shortnames of Data Protection Officer roles. | |
static | get_effective_context_category (\context $context, $forcedvalue=false) |
Returns the effective category given a context instance. | |
static | get_effective_context_purpose (\context $context, $forcedvalue=false) |
Returns the effective purpose given a context instance. | |
static | get_effective_contextlevel_category ($contextlevel) |
Returns the effective category given a context level. | |
static | get_effective_contextlevel_purpose ($contextlevel, $forcedvalue=false) |
Returns the effective purpose given a context level. | |
static | get_purposes () |
Get all system data purposes. | |
static | get_request ($requestid) |
Fetches a request based on the request ID. | |
static | get_site_dpos () |
Fetches the list of users with the Privacy Officer role. | |
static | has_ongoing_request ($userid, $type) |
Checks whether there is already an existing pending/in-progress data request for a user for a given request type. | |
static | is_active ($status) |
Determines whether a request is active or not based on its status. | |
static | is_automatic_request_approval_on (int $type) |
Whether automatic data request approval is turned on or not for the given request type. | |
static | is_site_dpo ($userid) |
Checks whether a given user is a site Privacy Officer. | |
static | notify_dpo ($dpo, data_request $request) |
Sends a message to the site's Data Protection Officer about a request. | |
static | queue_data_request_task (int $requestid, int $userid=null) |
Creates an ad-hoc task for the data request. | |
static | require_can_create_data_request_for_user ($user, $requester=null) |
Require that the current user can make a data request for the specified other user. | |
static | set_context_defaults ($contextlevel, $categoryid, $purposeid, $activity=null, $override=false) |
Updates the default category and purpose for a given context level (and optionally, a plugin). | |
static | set_context_instance ($record) |
Sets the context instance purpose and category. | |
static | set_contextlevel ($record) |
Sets the context level purpose and category. | |
static | set_expired_context_status (expired_context $expiredctx, $status) |
Updates the status of an expired context. | |
static | unset_context_instance (context_instance $instance) |
Unsets the context instance record. | |
static | update_category (stdClass $record) |
Updates an existing data category. | |
static | update_purpose (stdClass $record) |
Updates an existing data purpose. | |
static | update_request_contexts_with_status (int $requestid, int $status) |
Sets the status of all contexts associated with the request. | |
static | update_request_status ($requestid, $status, $dpoid=0, $comment='') |
Cancels the data request for a given request ID. | |
Public Attributes | |
const | DATAREQUEST_ACTION_APPROVE = 1 |
Approve data request. | |
const | DATAREQUEST_ACTION_REJECT = 2 |
Reject data request. | |
const | DATAREQUEST_STATUS_APPROVED = 3 |
Request approved and will be processed soon. | |
const | DATAREQUEST_STATUS_AWAITING_APPROVAL = 2 |
Metadata ready and awaiting review and approval by the Data Protection officer. | |
const | DATAREQUEST_STATUS_CANCELLED = 6 |
Data request cancelled by the user. | |
const | DATAREQUEST_STATUS_COMPLETE = 5 |
Information/other request completed. | |
const | DATAREQUEST_STATUS_DELETED = 10 |
Data delete request completed, account is removed. | |
const | DATAREQUEST_STATUS_DOWNLOAD_READY = 8 |
Data request download ready. | |
const | DATAREQUEST_STATUS_EXPIRED = 9 |
Data request expired. | |
const | DATAREQUEST_STATUS_PENDING = 0 |
Newly submitted and we haven't yet started finding out where they have data. | |
const | DATAREQUEST_STATUS_PREPROCESSING = 1 |
Newly submitted and we have started to find the location of data. | |
const | DATAREQUEST_STATUS_PROCESSING = 4 |
The request is now being processed. | |
const | DATAREQUEST_STATUS_REJECTED = 7 |
Data request rejected by the DPO. | |
const | DATAREQUEST_TYPE_DELETE = 2 |
Data deletion request type. | |
const | DATAREQUEST_TYPE_EXPORT = 1 |
Data export request type. | |
const | DATAREQUEST_TYPE_OTHERS = 3 |
Other request type. | |
Class containing helper methods for processing data requests.
|
static |
Adds the contexts from the contextlist_collection to the request with the status provided.
contextlist_collection | $clcollection | a collection of contextlists for all components. |
int | $requestid | the id of the request. |
int | $status | the status to set the contexts to. |
|
static |
Only approve the contexts which are children of the provided course contexts.
int | $requestid | Request identifier |
array | $coursecontextids | List of course context identifier. |
|
static |
Approves a data request based on the request ID.
int | $requestid | The request identifier |
array | $filtercoursecontexts | Apply to export request, only approve contexts belong to these courses. |
bool |
coding_exception | |
dml_exception | |
invalid_persistent_exception | |
required_capability_exception | |
moodle_exception |
|
static |
Determines whether the user can contact the site's Data Protection Officer via Moodle.
boolean | True when tool_dataprivacy|contactdataprotectionofficer is enabled. |
dml_exception |
|
static |
Check if parent can create data deletion request for their children.
int | $userid | ID of a user being requested. |
int | null | $requesterid | ID of a user making request. |
bool |
coding_exception |
|
static |
Check if user has permission to create data deletion request for another user.
int | null | $userid | ID of the user. |
bool |
coding_exception | |
dml_exception |
|
static |
Check if user has permisson to create data deletion request for themselves.
int | null | $userid | ID of the user. |
bool |
coding_exception |
|
static |
Check if user has permission to create data download request for themselves.
int | null | $userid |
bool |
|
static |
Checks whether a non-DPO user can make a data request for another user.
int | $user | The user ID of the target user. |
int | $requester | The user ID of the user making the request. |
bool |
|
static |
Checks whether a user can download a data request.
int | $userid | Target user id (subject of data request) |
int | $requesterid | Requester user id (person who requsted it) |
int | null | $downloaderid | Person who wants to download user id (default current) |
bool |
coding_exception |
|
static |
Checks whether the current user has the capability to manage data requests.
int | $userid | The user ID. |
bool |
|
static |
Checks if the current user can manage the data registry at the provided id.
int | $contextid | Fallback to system context id. |
required_capability_exception |
null |
|
static |
Creates a new data category.
stdClass | $record |
tool_dataprivacy\category. |
|
static |
Lodges a data request and sends the request details to the site Data Protection Officer(s).
int | $foruser | The user whom the request is being made for. |
int | $type | The request type. |
string | $comments | Request comments. |
int | $creationmethod | The creation method of the data request. |
bool | $notify | Notify DPOs of this pending request. |
data_request |
invalid_persistent_exception | |
coding_exception |
|
static |
Creates an expired context record for the provided context id.
int | $contextid |
tool_dataprivacy\expired_context |
|
static |
Creates a new data purpose.
stdClass | $record |
tool_dataprivacy\purpose. |
|
static |
Deletes a data category.
int | $id |
bool |
|
static |
Deletes an expired context record.
int | $id | The tool_dataprivacy_ctxexpire id. |
bool | True on success. |
|
static |
Deletes a data purpose.
int | $id |
bool |
|
static |
Rejects a data request based on the request ID.
int | $requestid | The request identifier |
bool |
coding_exception | |
dml_exception | |
invalid_persistent_exception | |
required_capability_exception | |
moodle_exception |
|
static |
Find whether any ongoing requests exist for a set of users.
array | $userids |
array |
|
static |
Format the supplied date interval as a retention period.
DateInterval | $interval |
string |
|
static |
Finds all contextlists having at least one approved context, and returns them as in a contextlist_collection.
contextlist_collection | $collection | The collection of unapproved contextlist objects. |
stdClass | $foruser | The target user |
int | $type | The purpose of the collection |
contextlist_collection | The collection of approved_contextlist objects. |
|
static |
Finds all request contextlists having at least on approved context, and returns them as in a contextlist_collection.
data_request | $request | the data request with which the contextlists are associated. |
contextlist_collection | the collection of approved_contextlist objects. |
coding_exception | |
dml_exception | |
moodle_exception |
|
static |
Fetches the list of configured privacy officer roles.
Every time this function is called, it checks each role if they have the 'managedatarequests' capability and removes any role that doesn't have the required capability anymore.
int[] |
dml_exception |
|
static |
Get all system data categories.
tool_dataprivacy\category[] |
|
static |
Get list of course context for user to filter.
int | $requestid | Request identifier. |
array |
dml_exception | |
coding_exception |
|
static |
Fetches the list of the data requests.
If user ID is provided, it fetches the data requests for the user. Otherwise, it fetches all of the data requests, provided that the user has the capability to manage data requests. (e.g. Users with the Data Protection Officer roles)
int | $userid | The User ID. |
int[] | $statuses | The status filters. |
int[] | $types | The request type filters. |
int[] | $creationmethods | The request creation method filters. |
string | $sort | The order by clause. |
int | $offset | Amount of records to skip. |
int | $limit | Amount of records to fetch. |
data_request[] |
coding_exception | |
dml_exception |
|
static |
Fetches the count of data request records based on the given parameters.
int | $userid | The User ID. |
int[] | $statuses | The status filters. |
int[] | $types | The request type filters. |
int[] | $creationmethods | The request creation method filters. |
int |
coding_exception | |
dml_exception |
|
static |
Gets an action menu link to download a data request.
context_user | $usercontext | User context (of user who the data is for) |
int | $requestid | Request id |
action_menu_link_secondary | Action menu link |
coding_exception |
|
static |
Fetches the role shortnames of Data Protection Officer roles.
array | An array of the DPO role shortnames |
|
static |
Returns the effective category given a context instance.
context | $context | |
int | $forcedvalue | Use this categoryid value as if this was this context instance category. |
category|false |
|
static |
Returns the effective purpose given a context instance.
context | $context | |
int | $forcedvalue | Use this purposeid value as if this was this context instance purpose. |
purpose|false |
|
static |
Returns the effective category given a context level.
int | $contextlevel |
category|false |
|
static |
Returns the effective purpose given a context level.
int | $contextlevel | |
int | $forcedvalue | Use this purposeid value as if this was this context level purpose. |
purpose|false |
|
static |
Get all system data purposes.
tool_dataprivacy\purpose[] |
|
static |
Fetches a request based on the request ID.
int | $requestid | The request identifier |
data_request |
|
static |
Checks whether there is already an existing pending/in-progress data request for a user for a given request type.
int | $userid | The user ID. |
int | $type | The request type. |
bool |
coding_exception | |
dml_exception |
|
static |
Determines whether a request is active or not based on its status.
int | $status | The request status. |
bool |
|
static |
Whether automatic data request approval is turned on or not for the given request type.
int | $type | The request type. |
bool |
|
static |
Checks whether a given user is a site Privacy Officer.
int | $userid | The user ID. |
bool |
|
static |
Sends a message to the site's Data Protection Officer about a request.
stdClass | $dpo | The DPO user record |
data_request | $request | The data request |
int|false |
coding_exception | |
moodle_exception |
|
static |
Creates an ad-hoc task for the data request.
int | $requestid | The data request ID. |
int | $userid | Optional. The user ID to run the task as, if necessary. |
|
static |
Require that the current user can make a data request for the specified other user.
int | $user | The user ID of the target user. |
int | $requester | The user ID of the user making the request. |
bool |
|
static |
Updates the default category and purpose for a given context level (and optionally, a plugin).
int | $contextlevel | The context level. |
int | $categoryid | The ID matching the category. |
int | $purposeid | The ID matching the purpose record. |
int | $activity | The name of the activity that we're making a defaults configuration for. |
bool | $override | Whether to override the purpose/categories of existing instances to these defaults. |
boolean | True if set/unset config succeeds. Otherwise, it throws an exception. |
|
static |
Sets the context instance purpose and category.
stdClass | $record |
tool_dataprivacy\context_instance |
|
static |
Sets the context level purpose and category.
coding_exception |
stdClass | $record |
contextlevel |
|
static |
Updates the status of an expired context.
tool_dataprivacy\expired_context | $expiredctx | |
int | $status |
null |
|
static |
Unsets the context instance record.
tool_dataprivacy\context_instance | $instance |
null |
|
static |
Updates an existing data category.
stdClass | $record |
tool_dataprivacy\category. |
|
static |
Updates an existing data purpose.
stdClass | $record |
tool_dataprivacy\purpose. |
|
static |
Sets the status of all contexts associated with the request.
int | $requestid | the requestid to which the contexts belong. |
int | $status | the status to set to. |
dml_exception | if the requestid is invalid. |
coding_exception | if the status is invalid. |
|
static |
Cancels the data request for a given request ID.
int | $requestid | The request identifier. |
int | $status | The request status. |
int | $dpoid | The user ID of the Data Protection Officer |
string | $comment | The comment about the status update. |
bool |
invalid_persistent_exception | |
coding_exception |
const tool_dataprivacy\api::DATAREQUEST_TYPE_OTHERS = 3 |
Other request type.
Usually of enquiries to the DPO.