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 * Privacy Subsystem implementation for gradereport_user.
20 * @package gradereport_user
21 * @copyright 2018 Sara Arjona <sara@moodle.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 namespace gradereport_user\privacy;
27 defined('MOODLE_INTERNAL') || die();
29 use \core_privacy\local\metadata\collection;
30 use \core_privacy\local\request\transform;
31 use \core_privacy\local\request\writer;
33 require_once $CFG->libdir.'/grade/constants.php';
37 * Privacy Subsystem for gradereport_user implementing null_provider.
39 * @copyright 2018 Sara Arjona <sara@moodle.com>
40 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
42 class provider implements
43 \core_privacy\local\metadata\provider,
44 \core_privacy\local\request\user_preference_provider {
47 * Returns meta data about this system.
49 * @param collection $itemcollection The initialised item collection to add items to.
50 * @return collection A listing of user data stored through this system.
52 public static function get_metadata(collection $items) : collection {
53 // User preferences (shared between different courses).
54 $items->add_user_preference('gradereport_user_view_user', 'privacy:metadata:preference:gradereport_user_view_user');
60 * Store all user preferences for the plugin.
62 * @param int $userid The userid of the user whose data is to be exported.
64 public static function export_user_preferences(int $userid) {
65 $prefvalue = get_user_preferences('gradereport_user_view_user', null, $userid);
66 if ($prefvalue !== null) {
67 $transformedvalue = transform::yesno($prefvalue);
68 writer::export_user_preference(
70 'gradereport_user_view_user',
72 get_string('privacy:metadata:preference:gradereport_user_view_user', 'gradereport_user')