Skip to content

Commit

Permalink
MDL-63726 tool_dataprivacy: En-/disable 'Data retention summary' link
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaboesch committed Oct 31, 2018
1 parent 4b68132 commit 4f32e3a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
2 changes: 2 additions & 0 deletions admin/tool/dataprivacy/lang/en/tool_dataprivacy.php
Expand Up @@ -277,6 +277,8 @@
$string['sensitivedatareasons'] = 'Sensitive personal data processing reasons';
$string['sensitivedatareasons_help'] = 'Select one or more applicable reasons that exempts the prohibition of processing sensitive personal data tied to this purpose. For more information, please see <a href="https://gdpr-info.eu/art-9-gdpr/" target="_blank">GDPR Art. 9.2</a>';
$string['setdefaults'] = 'Set defaults';
$string['showdataretentionsummary'] = 'Show data retention summary';
$string['showdataretentionsummary_desc'] = 'If enabled, a link to the data retention summary is shown in the page footer and in the user profile page.';
$string['statusapproved'] = 'Approved';
$string['statusawaitingapproval'] = 'Awaiting approval';
$string['statuscancelled'] = 'Cancelled';
Expand Down
30 changes: 24 additions & 6 deletions admin/tool/dataprivacy/lib.php
Expand Up @@ -87,10 +87,19 @@ function tool_dataprivacy_myprofile_navigation(tree $tree, $user, $iscurrentuser
}
}

$summaryurl = new moodle_url('/admin/tool/dataprivacy/summary.php');
$summarynode = new core_user\output\myprofile\node('privacyandpolicies', 'retentionsummary',
// A returned 0 means that the setting was set and disabled, false means that there is no value for the provided setting.
$showsummary = get_config('tool_dataprivacy', 'showdataretentionsummary');
if ($showsummary === false) {
// This means that no value is stored in db. We use the default value in this case.
$showsummary = true;
}

if ($showsummary) {
$summaryurl = new moodle_url('/admin/tool/dataprivacy/summary.php');
$summarynode = new core_user\output\myprofile\node('privacyandpolicies', 'retentionsummary',
get_string('dataretentionsummary', 'tool_dataprivacy'), null, $summaryurl);
$category->add_node($summarynode);
$category->add_node($summarynode);
}

// Add the Privacy category to the tree if it's not empty and it doesn't exist.
$nodes = $category->nodes;
Expand All @@ -110,11 +119,20 @@ function tool_dataprivacy_myprofile_navigation(tree $tree, $user, $iscurrentuser
* @return string HTML footer content
*/
function tool_dataprivacy_standard_footer_html() {
$output = '';

$url = new moodle_url('/admin/tool/dataprivacy/summary.php');
$output = html_writer::link($url, get_string('dataretentionsummary', 'tool_dataprivacy'));
$output = html_writer::div($output, 'summaryfooter');
// A returned 0 means that the setting was set and disabled, false means that there is no value for the provided setting.
$showsummary = get_config('tool_dataprivacy', 'showdataretentionsummary');
if ($showsummary === false) {
// This means that no value is stored in db. We use the default value in this case.
$showsummary = true;
}

if ($showsummary) {
$url = new moodle_url('/admin/tool/dataprivacy/summary.php');
$output = html_writer::link($url, get_string('dataretentionsummary', 'tool_dataprivacy'));
$output = html_writer::div($output, 'tool_dataprivacy');
}
return $output;
}

Expand Down
6 changes: 6 additions & 0 deletions admin/tool/dataprivacy/settings.php
Expand Up @@ -66,6 +66,12 @@
new lang_string('requireallenddatesforuserdeletion', 'tool_dataprivacy'),
new lang_string('requireallenddatesforuserdeletion_desc', 'tool_dataprivacy'),
1));

// Whether the data retention summary should be shown in the page footer and in the user profile page.
$privacysettings->add(new admin_setting_configcheckbox('tool_dataprivacy/showdataretentionsummary',
new lang_string('showdataretentionsummary', 'tool_dataprivacy'),
new lang_string('showdataretentionsummary_desc', 'tool_dataprivacy'),
1));
}
}

Expand Down

0 comments on commit 4f32e3a

Please sign in to comment.