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 * Adds Data privacy-related settings.
20 * @package tool_dataprivacy
21 * @copyright 2018 onwards Jun Pataleta
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') ||
die;
28 $privacysettings = $ADMIN->locate('privacysettings');
30 if ($ADMIN->fulltree
) {
31 // Contact data protection officer. Disabled by default.
32 $privacysettings->add(new admin_setting_configcheckbox('tool_dataprivacy/contactdataprotectionofficer',
33 new lang_string('contactdataprotectionofficer', 'tool_dataprivacy'),
34 new lang_string('contactdataprotectionofficer_desc', 'tool_dataprivacy'), 0)
37 // Set days approved data requests will be accessible. 1 week default.
38 $privacysettings->add(new admin_setting_configduration('tool_dataprivacy/privacyrequestexpiry',
39 new lang_string('privacyrequestexpiry', 'tool_dataprivacy'),
40 new lang_string('privacyrequestexpiry_desc', 'tool_dataprivacy'),
43 // Fetch roles that are assignable.
44 $assignableroles = get_assignable_roles(context_system
::instance());
46 // Fetch roles that have the capability to manage data requests.
47 $capableroles = get_roles_with_capability('tool/dataprivacy:managedatarequests');
49 // Role(s) that map to the Data Protection Officer role. These are assignable roles with the capability to
50 // manage data requests.
52 foreach ($capableroles as $key => $role) {
53 if (array_key_exists($key, $assignableroles)) {
54 $roles[$key] = $assignableroles[$key];
58 $privacysettings->add(new admin_setting_configmulticheckbox('tool_dataprivacy/dporoles',
59 new lang_string('dporolemapping', 'tool_dataprivacy'),
60 new lang_string('dporolemapping_desc', 'tool_dataprivacy'), null, $roles)
66 // Restrict config links to the DPO.
67 if (tool_dataprivacy\api
::is_site_dpo($USER->id
)) {
68 // Link that leads to the data requests management page.
69 $ADMIN->add('privacy', new admin_externalpage('datarequests', get_string('datarequests', 'tool_dataprivacy'),
70 new moodle_url('/admin/tool/dataprivacy/datarequests.php'), 'tool/dataprivacy:managedatarequests')
73 // Link that leads to the data registry management page.
74 $ADMIN->add('privacy', new admin_externalpage('dataregistry', get_string('dataregistry', 'tool_dataprivacy'),
75 new moodle_url('/admin/tool/dataprivacy/dataregistry.php'), 'tool/dataprivacy:managedataregistry')
78 // Link that leads to the review page of expired contexts that are up for deletion.
79 $ADMIN->add('privacy', new admin_externalpage('datadeletion', get_string('datadeletion', 'tool_dataprivacy'),
80 new moodle_url('/admin/tool/dataprivacy/datadeletion.php'), 'tool/dataprivacy:managedataregistry')
83 // Link that leads to the other data registry management page.
84 $ADMIN->add('privacy', new admin_externalpage('pluginregistry', get_string('pluginregistry', 'tool_dataprivacy'),
85 new moodle_url('/admin/tool/dataprivacy/pluginregistry.php'), 'tool/dataprivacy:managedataregistry')