2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * This file contains the polyfill to allow a plugin to operate with Moodle 3.3 up.
20 * @package core_privacy
21 * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 namespace core_privacy\local;
26 use \core_privacy\local\metadata\collection;
27 use \core_privacy\local\request\contextlist;
28 use \core_privacy\local\request\approved_contextlist;
29 use \core_privacy\local\request\deletion_criteria;
31 defined('MOODLE_INTERNAL') || die();
34 * The trait used to provide a backwards compatability for third-party plugins.
36 * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
39 trait legacy_polyfill {
42 * Get the language string identifier with the component's language
43 * file to explain why this plugin stores no data.
47 public static function get_reason() : string {
48 return static::_get_reason();
52 * Get the list of items.
54 * @param collection $collection The initialised collection to add items to.
55 * @return collection A listing of user data stored through this system.
57 public static function get_metadata(collection $collection) : collection {
58 return static::_get_metadata($collection);
62 * Export all user preferences for the plugin.
64 * @param int $userid The userid of the user whose data is to be exported.
66 public static function export_user_preferences(int $userid) {
67 return static::_export_user_preferences($userid);
71 * Get the list of contexts that contain user information for the specified user.
73 * @param int $userid The user to search.
74 * @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin.
76 public static function get_contexts_for_userid(int $userid) : contextlist {
77 return static::_get_contexts_for_userid($userid);
81 * Export all user data for the specified user, in the specified contexts.
83 * @param approved_contextlist $contextlist The approved contexts to export information for.
85 public static function export_user_data(approved_contextlist $contextlist) {
86 return static::_export_user_data($contextlist);
90 * Delete all use data which matches the specified deletion_criteria.
92 * @param deletion_criteria $criteria An object containing specific deletion criteria to delete for.
94 public static function delete_for_context(deletion_criteria $criteria) {
95 return static::_delete_for_context($criteria);
99 * Delete all user data for the specified user, in the specified contexts.
101 * @param approved_contextlist $contextlist The approved contexts and user information to delete information for.
103 public static function delete_user_data(approved_contextlist $contextlist) {
104 return static::_delete_user_data($contextlist);