Skip to content

Commit 44c460c

Browse files
author
David Monllao
committed
Merge branch 'MDL-62558-35' of git://github.com/abgreeve/moodle into MOODLE_35_STABLE
2 parents 1209d00 + 8855e00 commit 44c460c

File tree

6 files changed

+329
-0
lines changed

6 files changed

+329
-0
lines changed

admin/tool/dataprivacy/classes/output/renderer.php

+11
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,15 @@ public function render_data_deletion_page(data_deletion_page $page) {
139139
$data = $page->export_for_template($this);
140140
return parent::render_from_template('tool_dataprivacy/data_deletion', $data);
141141
}
142+
143+
/**
144+
* Render the user data retention summary page.
145+
*
146+
* @param summary_page $page
147+
* @return string html for the page.
148+
*/
149+
public function render_summary_page(summary_page $page) {
150+
$data = $page->export_for_template($this);
151+
return parent::render_from_template('tool_dataprivacy/summary', $data);
152+
}
142153
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
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+
* Summary page renderable.
19+
*
20+
* @package tool_dataprivacy
21+
* @copyright 2018 Adrian Greeve
22+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23+
*/
24+
namespace tool_dataprivacy\output;
25+
defined('MOODLE_INTERNAL') || die();
26+
27+
use renderable;
28+
use renderer_base;
29+
use templatable;
30+
31+
32+
/**
33+
* Class containing the summary page renderable.
34+
*
35+
* @copyright 2018 Adrian Greeve
36+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37+
*/
38+
class summary_page implements renderable, templatable {
39+
40+
/**
41+
* Export this data so it can be used as the context for a mustache template.
42+
*
43+
* @param renderer_base $output
44+
* @return array
45+
*/
46+
public function export_for_template(renderer_base $output) {
47+
$contextlevels = [
48+
'contextlevelname10' => CONTEXT_SYSTEM,
49+
'contextlevelname30' => CONTEXT_USER,
50+
'contextlevelname40' => CONTEXT_COURSECAT,
51+
'contextlevelname50' => CONTEXT_COURSE,
52+
'contextlevelname70' => CONTEXT_MODULE,
53+
'contextlevelname80' => CONTEXT_BLOCK
54+
];
55+
56+
$data = [];
57+
$context = \context_system::instance();
58+
59+
foreach ($contextlevels as $levelname => $level) {
60+
$classname = \context_helper::get_class_for_level($level);
61+
list($purposevar, $categoryvar) = \tool_dataprivacy\data_registry::var_names_from_context($classname);
62+
$purposeid = get_config('tool_dataprivacy', $purposevar);
63+
$categoryid = get_config('tool_dataprivacy', $categoryvar);
64+
65+
$section = [];
66+
$section['contextname'] = get_string($levelname, 'tool_dataprivacy');
67+
68+
if (empty($purposeid)) {
69+
list($purposeid, $categoryid) =
70+
\tool_dataprivacy\data_registry::get_effective_default_contextlevel_purpose_and_category($level);
71+
}
72+
if ($purposeid == -1) {
73+
$purposeid = 0;
74+
}
75+
$purpose = new \tool_dataprivacy\purpose($purposeid);
76+
$export = new \tool_dataprivacy\external\purpose_exporter($purpose, ['context' => $context]);
77+
$purposedata = $export->export($output);
78+
$section['purpose'] = $purposedata;
79+
80+
if (empty($categoryid)) {
81+
list($purposeid, $categoryid) =
82+
\tool_dataprivacy\data_registry::get_effective_default_contextlevel_purpose_and_category($level);
83+
}
84+
if ($categoryid == -1) {
85+
$categoryid = 0;
86+
}
87+
$category = new \tool_dataprivacy\category($categoryid);
88+
$export = new \tool_dataprivacy\external\category_exporter($category, ['context' => $context]);
89+
$categorydata = $export->export($output);
90+
$section['category'] = $categorydata;
91+
$data['contexts'][] = $section;
92+
}
93+
94+
// Get activity module plugin info.
95+
$pluginmanager = \core_plugin_manager::instance();
96+
$modplugins = $pluginmanager->get_enabled_plugins('mod');
97+
98+
foreach ($modplugins as $name) {
99+
$classname = \context_helper::get_class_for_level($contextlevels['contextlevelname70']);
100+
list($purposevar, $categoryvar) = \tool_dataprivacy\data_registry::var_names_from_context($classname, $name);
101+
$categoryid = get_config('tool_dataprivacy', $categoryvar);
102+
$purposeid = get_config('tool_dataprivacy', $purposevar);
103+
if ($categoryid === false && $purposeid === false) {
104+
// If no purpose and category has been set for this plugin, then there's no need to show this on the list.
105+
continue;
106+
}
107+
108+
$section = [];
109+
$section['contextname'] = $pluginmanager->plugin_name('mod_' . $name);
110+
111+
if ($purposeid == -1) {
112+
$purposeid = 0;
113+
}
114+
$purpose = new \tool_dataprivacy\purpose($purposeid);
115+
$export = new \tool_dataprivacy\external\purpose_exporter($purpose, ['context' => $context]);
116+
$purposedata = $export->export($output);
117+
$section['purpose'] = $purposedata;
118+
119+
if ($categoryid == -1) {
120+
$categoryid = 0;
121+
}
122+
$category = new \tool_dataprivacy\category($categoryid);
123+
$export = new \tool_dataprivacy\external\category_exporter($category, ['context' => $context]);
124+
$categorydata = $export->export($output);
125+
$section['category'] = $categorydata;
126+
127+
$data['contexts'][] = $section;
128+
}
129+
130+
return $data;
131+
}
132+
}

admin/tool/dataprivacy/lang/en/tool_dataprivacy.php

+3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
$string['dataprivacy:downloadallrequests'] = 'Download exported data for everyone';
7777
$string['dataregistry'] = 'Data registry';
7878
$string['dataregistryinfo'] = 'The data registry enables categories (types of data) and purposes (the reasons for processing data) to be set for all content on the site - from users and courses down to activities and blocks. For each purpose, a retention period may be set. When a retention period has expired, the data is flagged and listed for deletion, awaiting admin confirmation.';
79+
$string['dataretentionexplanation'] = 'This summary shows the default categories and purposes for retaining user\'s information on this system. Certain areas of the system may have more specific categories and purposes than those listed here.';
80+
$string['dataretentionsummary'] = 'Data retention summary';
7981
$string['datarequestcreatedforuser'] = 'Data request created for {$a}';
8082
$string['datarequestemailsubject'] = 'Data request: {$a}';
8183
$string['datarequests'] = 'Data requests';
@@ -274,6 +276,7 @@
274276
$string['statusrejected'] = 'Rejected';
275277
$string['subjectscope'] = 'Subject scope';
276278
$string['subjectscope_help'] = 'The subject scope lists the roles which may be assigned in this context.';
279+
$string['summary'] = 'Registry configuration summary';
277280
$string['user'] = 'User';
278281
$string['viewrequest'] = 'View the request';
279282
$string['visible'] = 'Expand all';

admin/tool/dataprivacy/lib.php

+19
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ function tool_dataprivacy_myprofile_navigation(tree $tree, $user, $iscurrentuser
6565
$category->add_node($node);
6666
}
6767

68+
$summaryurl = new moodle_url('/admin/tool/dataprivacy/summary.php');
69+
$summarynode = new core_user\output\myprofile\node('privacyandpolicies', 'retentionsummary',
70+
get_string('dataretentionsummary', 'tool_dataprivacy'), null, $summaryurl);
71+
$category->add_node($summarynode);
72+
6873
// Add the Privacy category to the tree if it's not empty and it doesn't exist.
6974
$nodes = $category->nodes;
7075
if (!empty($nodes)) {
@@ -77,6 +82,20 @@ function tool_dataprivacy_myprofile_navigation(tree $tree, $user, $iscurrentuser
7782
return false;
7883
}
7984

85+
/**
86+
* Callback to add footer elements.
87+
*
88+
* @return string HTML footer content
89+
*/
90+
function tool_dataprivacy_standard_footer_html() {
91+
92+
$url = new moodle_url('/admin/tool/dataprivacy/summary.php');
93+
$output = html_writer::link($url, get_string('dataretentionsummary', 'tool_dataprivacy'));
94+
$output = html_writer::div($output, 'summaryfooter');
95+
96+
return $output;
97+
}
98+
8099
/**
81100
* Fragment to add a new purpose.
82101
*

admin/tool/dataprivacy/summary.php

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
* Prints the compliance data registry main page.
19+
*
20+
* @copyright 2018 onwards Adrian Greeve <adriangreeve.com>
21+
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
22+
* @package tool_dataprivacy
23+
*/
24+
25+
require_once(__DIR__ . '/../../../config.php');
26+
require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/dataprivacy/lib.php');
27+
28+
$url = new moodle_url('/' . $CFG->admin . '/tool/dataprivacy/summary.php');
29+
$title = get_string('summary', 'tool_dataprivacy');
30+
31+
$context = \context_system::instance();
32+
$PAGE->set_url($url);
33+
$PAGE->set_context($context);
34+
$PAGE->set_title($title);
35+
$PAGE->set_heading($SITE->fullname);
36+
37+
$output = $PAGE->get_renderer('tool_dataprivacy');
38+
echo $output->header();
39+
$summarypage = new \tool_dataprivacy\output\summary_page();
40+
echo $output->render($summarypage);
41+
echo $output->footer();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{{!
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+
@template tool_dataprivacy/summary
19+
20+
Summary
21+
22+
Classes required for JS:
23+
24+
Data attributes required for JS:
25+
26+
Context variables required for this template:
27+
28+
Example context (json):
29+
{
30+
31+
"contexts": [
32+
{
33+
"contextname": "Site",
34+
"category":
35+
{
36+
"name": "Test category",
37+
"description": "<p>Description for category</p>"
38+
},
39+
"purpose":
40+
{
41+
"name": "Test purpose",
42+
"description": "<p>Description for purpose</p>",
43+
"lawfulbases": "gdpr_art_6_1_c",
44+
"sensitivedatareasons": "gdpr_art_9_2_f",
45+
"formattedlawfulbases": [
46+
{
47+
"name": "Lawful base 1(a)",
48+
"description": "We need your information"
49+
},
50+
{
51+
"name": "Lawful base 1(b)",
52+
"description": "We really do need your information"
53+
}
54+
],
55+
"formattedsensitivedatareasons": [
56+
{
57+
"name": "Sensitive data reason number 1",
58+
"description": "Number 1"
59+
},
60+
{
61+
"name": "Sensitive data reason number 1",
62+
"description": "Number 2"
63+
}
64+
],
65+
"formattedretentionperiod": "10 Years"
66+
}
67+
}
68+
]
69+
}
70+
}}
71+
<h2>{{#str}}dataretentionsummary, tool_dataprivacy{{/str}}</h2>
72+
<p>{{#str}}dataretentionexplanation, tool_dataprivacy{{/str}}</p>
73+
<div>
74+
{{#contexts}}
75+
<div class="card mb-3">
76+
<div class="card-header"><h3>{{contextname}}</h3></div>
77+
<div class="card-body p-l-2 p-r-2">
78+
79+
{{#category.name}}
80+
<h4>{{#str}}category, tool_dataprivacy{{/str}}</h4>
81+
<dl>
82+
<dt>{{category.name}}</dt>
83+
<dd>{{{category.description}}}</dd>
84+
</dl>
85+
<hr />
86+
{{/category.name}}
87+
<h4>{{#str}}purpose, tool_dataprivacy{{/str}}</h4>
88+
<dl>
89+
<dt>{{purpose.name}}</dt>
90+
<dd>{{{purpose.description}}}</dd>
91+
<dt>{{#str}}retentionperiod, tool_dataprivacy{{/str}}</dt>
92+
<dd>{{purpose.formattedretentionperiod}}</dd>
93+
</dl>
94+
{{#purpose.lawfulbases}}
95+
<table class="table table-bordered">
96+
<thead><tr><th colspan="2">{{#str}}lawfulbases, tool_dataprivacy{{/str}}</th></tr></thead>
97+
<tbody>
98+
{{#purpose.formattedlawfulbases}}
99+
<tr>
100+
<td>{{name}}</td>
101+
<td>{{description}}</td>
102+
</tr>
103+
{{/purpose.formattedlawfulbases}}
104+
</tbody>
105+
</table>
106+
{{/purpose.lawfulbases}}
107+
{{#purpose.sensitivedatareasons}}
108+
<table class="table table-bordered">
109+
<thead><tr><th colspan="2">{{#str}}sensitivedatareasons, tool_dataprivacy{{/str}}</th></tr></thead>
110+
<tbody>
111+
{{#purpose.formattedsensitivedatareasons}}
112+
<tr>
113+
<td>{{name}}</td>
114+
<td>{{description}}</td>
115+
</tr>
116+
{{/purpose.formattedsensitivedatareasons}}
117+
</tbody>
118+
</table>
119+
{{/purpose.sensitivedatareasons}}
120+
</div>
121+
</div>
122+
{{/contexts}}
123+
</div>

0 commit comments

Comments
 (0)