Differences Between: [Versions 310 and 400] [Versions 39 and 400] [Versions 400 and 403]
Class containing helper methods for processing data requests.
Copyright: | 2018 Jun Pataleta |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 1345 lines (52 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
api:: (49 methods):
can_contact_dpo()
can_manage_data_requests()
check_can_manage_data_registry()
get_assigned_privacy_officer_roles()
get_dpo_role_names()
get_site_dpos()
is_site_dpo()
create_data_request()
get_data_requests()
get_data_requests_count()
has_ongoing_request()
find_ongoing_request_types_for_users()
is_active()
update_request_status()
get_request()
approve_data_request()
deny_data_request()
notify_dpo()
can_create_data_request_for_user()
require_can_create_data_request_for_user()
can_create_data_download_request_for_self()
can_create_data_deletion_request_for_self()
can_create_data_deletion_request_for_other()
can_create_data_deletion_request_for_children()
can_download_data_request_for_user()
get_download_link()
create_purpose()
update_purpose()
delete_purpose()
get_purposes()
create_category()
update_category()
delete_category()
get_categories()
set_context_instance()
unset_context_instance()
set_contextlevel()
get_effective_context_category()
get_effective_context_purpose()
get_effective_contextlevel_category()
get_effective_contextlevel_purpose()
create_expired_context()
delete_expired_context()
set_expired_context_status()
get_approved_contextlist_collection_for_collection()
set_context_defaults()
format_retention_period()
is_automatic_request_approval_on()
queue_data_request_task()
can_contact_dpo() X-Ref |
Determines whether the user can contact the site's Data Protection Officer via Moodle. return: boolean True when tool_dataprivacy|contactdataprotectionofficer is enabled. |
can_manage_data_requests($userid) X-Ref |
Checks whether the current user has the capability to manage data requests. return: bool param: int $userid The user ID. |
check_can_manage_data_registry($contextid = false) X-Ref |
Checks if the current user can manage the data registry at the provided id. return: null param: int $contextid Fallback to system context id. |
get_assigned_privacy_officer_roles() X-Ref |
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. return: int[] |
get_dpo_role_names() X-Ref |
Fetches the role shortnames of Data Protection Officer roles. return: array An array of the DPO role shortnames |
get_site_dpos() X-Ref |
Fetches the list of users with the Privacy Officer role. |
is_site_dpo($userid) X-Ref |
Checks whether a given user is a site Privacy Officer. return: bool param: int $userid The user ID. |
create_data_request($foruser, $type, $comments = '',$creationmethod = data_request::DATAREQUEST_CREATION_MANUAL,$notify = null) X-Ref |
Lodges a data request and sends the request details to the site Data Protection Officer(s). return: data_request param: int $foruser The user whom the request is being made for. param: int $type The request type. param: string $comments Request comments. param: int $creationmethod The creation method of the data request. param: bool $notify Notify DPOs of this pending request. |
get_data_requests($userid = 0, $statuses = [], $types = [], $creationmethods = [],$sort = '', $offset = 0, $limit = 0) X-Ref |
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) return: data_request[] param: int $userid The User ID. param: int[] $statuses The status filters. param: int[] $types The request type filters. param: int[] $creationmethods The request creation method filters. param: string $sort The order by clause. param: int $offset Amount of records to skip. param: int $limit Amount of records to fetch. |
get_data_requests_count($userid = 0, $statuses = [], $types = [], $creationmethods = []) X-Ref |
Fetches the count of data request records based on the given parameters. return: int param: int $userid The User ID. param: int[] $statuses The status filters. param: int[] $types The request type filters. param: int[] $creationmethods The request creation method filters. |
has_ongoing_request($userid, $type) X-Ref |
Checks whether there is already an existing pending/in-progress data request for a user for a given request type. return: bool param: int $userid The user ID. param: int $type The request type. |
find_ongoing_request_types_for_users(array $userids) X-Ref |
Find whether any ongoing requests exist for a set of users. return: array param: array $userids |
is_active($status) X-Ref |
Determines whether a request is active or not based on its status. return: bool param: int $status The request status. |
update_request_status($requestid, $status, $dpoid = 0, $comment = '') X-Ref |
Cancels the data request for a given request ID. return: bool param: int $requestid The request identifier. param: int $status The request status. param: int $dpoid The user ID of the Data Protection Officer param: string $comment The comment about the status update. |
get_request($requestid) X-Ref |
Fetches a request based on the request ID. return: data_request param: int $requestid The request identifier |
approve_data_request($requestid) X-Ref |
Approves a data request based on the request ID. return: bool param: int $requestid The request identifier |
deny_data_request($requestid) X-Ref |
Rejects a data request based on the request ID. return: bool param: int $requestid The request identifier |
notify_dpo($dpo, data_request $request) X-Ref |
Sends a message to the site's Data Protection Officer about a request. return: int|false param: stdClass $dpo The DPO user record param: data_request $request The data request |
can_create_data_request_for_user($user, $requester = null) X-Ref |
Checks whether a non-DPO user can make a data request for another user. return: bool param: int $user The user ID of the target user. param: int $requester The user ID of the user making the request. |
require_can_create_data_request_for_user($user, $requester = null) X-Ref |
Require that the current user can make a data request for the specified other user. return: bool param: int $user The user ID of the target user. param: int $requester The user ID of the user making the request. |
can_create_data_download_request_for_self(int $userid = null) X-Ref |
Check if user has permission to create data download request for themselves return: bool param: int|null $userid |
can_create_data_deletion_request_for_self(int $userid = null) X-Ref |
Check if user has permisson to create data deletion request for themselves. return: bool param: int|null $userid ID of the user. |
can_create_data_deletion_request_for_other(int $userid = null) X-Ref |
Check if user has permission to create data deletion request for another user. return: bool param: int|null $userid ID of the user. |
can_create_data_deletion_request_for_children(int $userid, int $requesterid = null) X-Ref |
Check if parent can create data deletion request for their children. return: bool param: int $userid ID of a user being requested. param: int|null $requesterid ID of a user making request. |
can_download_data_request_for_user($userid, $requesterid, $downloaderid = null) X-Ref |
Checks whether a user can download a data request. return: bool param: int $userid Target user id (subject of data request) param: int $requesterid Requester user id (person who requsted it) param: int|null $downloaderid Person who wants to download user id (default current) |
get_download_link(\context_user $usercontext, $requestid) X-Ref |
Gets an action menu link to download a data request. return: \action_menu_link_secondary Action menu link param: \context_user $usercontext User context (of user who the data is for) param: int $requestid Request id |
create_purpose(stdClass $record) X-Ref |
Creates a new data purpose. return: \tool_dataprivacy\purpose. param: stdClass $record |
update_purpose(stdClass $record) X-Ref |
Updates an existing data purpose. return: \tool_dataprivacy\purpose. param: stdClass $record |
delete_purpose($id) X-Ref |
Deletes a data purpose. return: bool param: int $id |
get_purposes() X-Ref |
Get all system data purposes. return: \tool_dataprivacy\purpose[] |
create_category(stdClass $record) X-Ref |
Creates a new data category. return: \tool_dataprivacy\category. param: stdClass $record |
update_category(stdClass $record) X-Ref |
Updates an existing data category. return: \tool_dataprivacy\category. param: stdClass $record |
delete_category($id) X-Ref |
Deletes a data category. return: bool param: int $id |
get_categories() X-Ref |
Get all system data categories. return: \tool_dataprivacy\category[] |
set_context_instance($record) X-Ref |
Sets the context instance purpose and category. return: \tool_dataprivacy\context_instance param: \stdClass $record |
unset_context_instance(context_instance $instance) X-Ref |
Unsets the context instance record. return: null param: \tool_dataprivacy\context_instance $instance |
set_contextlevel($record) X-Ref |
Sets the context level purpose and category. return: contextlevel param: \stdClass $record |
get_effective_context_category(\context $context, $forcedvalue = false) X-Ref |
Returns the effective category given a context instance. return: category|false param: \context $context param: int $forcedvalue Use this categoryid value as if this was this context instance category. |
get_effective_context_purpose(\context $context, $forcedvalue = false) X-Ref |
Returns the effective purpose given a context instance. return: purpose|false param: \context $context param: int $forcedvalue Use this purposeid value as if this was this context instance purpose. |
get_effective_contextlevel_category($contextlevel) X-Ref |
Returns the effective category given a context level. return: category|false param: int $contextlevel |
get_effective_contextlevel_purpose($contextlevel, $forcedvalue=false) X-Ref |
Returns the effective purpose given a context level. return: purpose|false param: int $contextlevel param: int $forcedvalue Use this purposeid value as if this was this context level purpose. |
create_expired_context($contextid) X-Ref |
Creates an expired context record for the provided context id. return: \tool_dataprivacy\expired_context param: int $contextid |
delete_expired_context($id) X-Ref |
Deletes an expired context record. return: bool True on success. param: int $id The tool_dataprivacy_ctxexpire id. |
set_expired_context_status(expired_context $expiredctx, $status) X-Ref |
Updates the status of an expired context. return: null param: \tool_dataprivacy\expired_context $expiredctx param: int $status |
get_approved_contextlist_collection_for_collection(contextlist_collection $collection,\stdClass $foruser, int $type) X-Ref |
Finds all contextlists having at least one approved context, and returns them as in a contextlist_collection. return: contextlist_collection The collection of approved_contextlist objects. param: contextlist_collection $collection The collection of unapproved contextlist objects. param: \stdClass $foruser The target user param: int $type The purpose of the collection |
set_context_defaults($contextlevel, $categoryid, $purposeid, $activity = null, $override = false) X-Ref |
Updates the default category and purpose for a given context level (and optionally, a plugin). return: boolean True if set/unset config succeeds. Otherwise, it throws an exception. param: int $contextlevel The context level. param: int $categoryid The ID matching the category. param: int $purposeid The ID matching the purpose record. param: int $activity The name of the activity that we're making a defaults configuration for. param: bool $override Whether to override the purpose/categories of existing instances to these defaults. |
format_retention_period(\DateInterval $interval) X-Ref |
Format the supplied date interval as a retention period. return: string param: \DateInterval $interval |
is_automatic_request_approval_on(int $type) X-Ref |
Whether automatic data request approval is turned on or not for the given request type. return: bool param: int $type The request type. |
queue_data_request_task(int $requestid, int $userid = null) X-Ref |
Creates an ad-hoc task for the data request. param: int $requestid The data request ID. param: int $userid Optional. The user ID to run the task as, if necessary. |