MDL-61868 tool_policy: Implement privacy API
[moodle.git] / admin / tool / policy / classes / privacy / provider.php
CommitLineData
24966a26
SA
1<?php
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Privacy Subsystem implementation for tool_policy.
19 *
20 * @package tool_policy
21 * @copyright 2018 Sara Arjona <sara@moodle.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25namespace tool_policy\privacy;
26
27use core_privacy\local\metadata\collection;
28use core_privacy\local\request\approved_contextlist;
29use core_privacy\local\request\contextlist;
30
31defined('MOODLE_INTERNAL') || die();
32
33/**
34 * Implementation of the privacy subsystem plugin provider for the policy tool.
35 *
36 * @copyright 2018 Sara Arjona <sara@moodle.com>
37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38 */
39class provider implements
40 // This tool stores user data.
41 \core_privacy\local\metadata\provider,
42
43 // This tool may provide access to and deletion of user data.
44 \core_privacy\local\request\plugin\provider {
45
46 /**
47 * Return the fields which contain personal data.
48 *
49 * @param collection $items A reference to the collection to use to store the metadata.
50 * @return collection The updated collection of metadata items.
51 */
52 public static function get_metadata(collection $items) : collection {
53 $items->add_database_table(
54 'tool_policy_acceptances',
55 [
56 'policyversionid' => 'privacy:metadata:acceptances:policyversionid',
57 'userid' => 'privacy:metadata:acceptances:userid',
58 'status' => 'privacy:metadata:acceptances:status',
59 'lang' => 'privacy:metadata:acceptances:lang',
60 'usermodified' => 'privacy:metadata:acceptances:usermodified',
61 'timecreated' => 'privacy:metadata:acceptances:timecreated',
62 'timemodified' => 'privacy:metadata:acceptances:timemodified',
63 'note' => 'privacy:metadata:acceptances:note',
64 ],
65 'privacy:metadata:acceptances'
66 );
67
68 return $items;
69 }
70
71 /**
72 * Get the list of contexts that contain user information for the specified user.
73 *
74 * @param int $userid The userid.
75 * @return contextlist The list of contexts containing user info for the user.
76 */
77 public static function get_contexts_for_userid(int $userid) : contextlist {
78 return new contextlist();
79 }
80
81 /**
82 * Export personal data for the given approved_contextlist. User and context information is contained within the contextlist.
83 *
84 * @param approved_contextlist $contextlist A list of contexts approved for export.
85 */
86 public static function export_user_data(approved_contextlist $contextlist) {
87 }
88
89 /**
90 * Delete all data for all users in the specified context.
91 *
92 * @param \context $context The context to delete in.
93 */
94 public static function delete_data_for_all_users_in_context(\context $context) {
95 }
96
97 /**
98 * Delete all user data for the specified user, in the specified contexts.
99 *
100 * @param approved_contextlist $contextlist A list of contexts approved for deletion.
101 */
102 public static function delete_data_for_user(approved_contextlist $contextlist) {
103 }
104}