|
| 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 class for requesting user data. |
| 19 | + * |
| 20 | + * @package core |
| 21 | + * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk> |
| 22 | + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
| 23 | + */ |
| 24 | + |
| 25 | +namespace core\privacy; |
| 26 | + |
| 27 | +defined('MOODLE_INTERNAL') || die(); |
| 28 | + |
| 29 | +use \core_privacy\local\metadata\collection; |
| 30 | +use \core_privacy\local\request\contextlist; |
| 31 | +use \core_privacy\local\request\approved_contextlist; |
| 32 | + |
| 33 | +/** |
| 34 | + * Privacy class for requesting user data. |
| 35 | + * |
| 36 | + * @package core |
| 37 | + * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk> |
| 38 | + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
| 39 | + */ |
| 40 | +class provider implements \core_privacy\local\metadata\provider, \core_privacy\local\request\subsystem\provider { |
| 41 | + |
| 42 | + /** |
| 43 | + * Returns information about the user data stored in this component. |
| 44 | + * |
| 45 | + * @param collection $collection A list of information about this component |
| 46 | + * @return collection The collection object filled out with information about this component. |
| 47 | + */ |
| 48 | + public static function get_metadata(collection $collection) { |
| 49 | + // These tables are really data about site configuration and not user data. |
| 50 | + |
| 51 | + // The config_log includes information about which user performed a configuration change. |
| 52 | + // The value and oldvalue may contain sensitive information such as accounts for service passwords.. |
| 53 | + // This is not considered to be user data. |
| 54 | + $collection->add_database_table('config_log', [ |
| 55 | + 'userid' => 'privacy:metadata:config_log:userid', |
| 56 | + 'timemodified' => 'privacy:metadata:config_log:timemodified', |
| 57 | + 'plugin' => 'privacy:metadata:config_log:plugin', |
| 58 | + 'name' => 'privacy:metadata:config_log:name', |
| 59 | + 'value' => 'privacy:metadata:config_log:value', |
| 60 | + 'oldvalue' => 'privacy:metadata:config_log:oldvalue', |
| 61 | + ], 'privacy:metadata:config_log'); |
| 62 | + |
| 63 | + // The upgrade_log includes information about which user performed an upgrade. |
| 64 | + // This is not considered to be user data. |
| 65 | + $collection->add_database_table('upgrade_log', [ |
| 66 | + 'type' => 'privacy:metadata:upgrade_log:type', |
| 67 | + 'plugin' => 'privacy:metadata:upgrade_log:plugin', |
| 68 | + 'version' => 'privacy:metadata:upgrade_log:version', |
| 69 | + 'targetversion' => 'privacy:metadata:upgrade_log:targetversion', |
| 70 | + 'info' => 'privacy:metadata:upgrade_log:info', |
| 71 | + 'details' => 'privacy:metadata:upgrade_log:details', |
| 72 | + 'backtrace' => 'privacy:metadata:upgrade_log:backtrace', |
| 73 | + 'userid' => 'privacy:metadata:upgrade_log:userid', |
| 74 | + 'timemodified' => 'privacy:metadata:upgrade_log:timemodified', |
| 75 | + ], 'privacy:metadata:upgrade_log'); |
| 76 | + |
| 77 | + // The task_adhoc includes information about pending adhoc tasks, some of which may be run as a user. |
| 78 | + // These are removed as the task completes. |
| 79 | + $collection->add_database_table('task_adhoc', [ |
| 80 | + 'component' => 'privacy:metadata:task_adhoc:component', |
| 81 | + 'nextruntime' => 'privacy:metadata:task_adhoc:nextruntime', |
| 82 | + 'userid' => 'privacy:metadata:task_adhoc:userid', |
| 83 | + ], 'privacy:metadata:task_adhoc'); |
| 84 | + |
| 85 | + // The events_queue includes information about pending events tasks. |
| 86 | + // These are stored for short periods whilst being processed into other locations. |
| 87 | + $collection->add_database_table('events_queue', [ |
| 88 | + 'eventdata' => 'privacy:metadata:events_queue:eventdata', |
| 89 | + 'stackdump' => 'privacy:metadata:events_queue:stackdump', |
| 90 | + 'userid' => 'privacy:metadata:events_queue:userid', |
| 91 | + 'timecreated' => 'privacy:metadata:events_queue:timecreated', |
| 92 | + ], 'privacy:metadata:events_queue'); |
| 93 | + |
| 94 | + return $collection; |
| 95 | + } |
| 96 | + |
| 97 | + /** |
| 98 | + * Get the list of contexts that contain user information for the specified user. |
| 99 | + * |
| 100 | + * @param int $userid The user to search. |
| 101 | + * @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin. |
| 102 | + */ |
| 103 | + public static function get_contexts_for_userid($userid) { |
| 104 | + return new contextlist(); |
| 105 | + } |
| 106 | + |
| 107 | + /** |
| 108 | + * Export all user data for the specified user, in the specified contexts. |
| 109 | + * |
| 110 | + * @param approved_contextlist $contextlist The approved contexts to export information for. |
| 111 | + */ |
| 112 | + public static function export_user_data(approved_contextlist $contextlist) { |
| 113 | + // None of the core tables should be exported. |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * Delete all data for all users in the specified context. |
| 118 | + * |
| 119 | + * @param context $context The specific context to delete data for. |
| 120 | + */ |
| 121 | + public static function delete_data_for_all_users_in_context(\context $context) { |
| 122 | + // None of the the data from these tables should be deleted. |
| 123 | + } |
| 124 | + |
| 125 | + /** |
| 126 | + * Delete all user data for the specified user, in the specified contexts. |
| 127 | + * |
| 128 | + * @param approved_contextlist $contextlist The approved contexts and user information to delete information for. |
| 129 | + */ |
| 130 | + public static function delete_data_for_user(approved_contextlist $contextlist) { |
| 131 | + // None of the the data from these tables should be deleted. |
| 132 | + // Note: Although it may be tempting to delete the adhoc task data, do not do so. |
| 133 | + // The delete process is run as an adhoc task. |
| 134 | + } |
| 135 | +} |
0 commit comments