Skip to content

Commit

Permalink
MDL-62341 privacy: Add link to previous page in viewall policies page
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihail Geshoski committed Aug 13, 2018
1 parent e8452a3 commit 5241540
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
10 changes: 8 additions & 2 deletions admin/tool/policy/classes/output/page_viewalldoc.php
Expand Up @@ -48,12 +48,15 @@
*/
class page_viewalldoc implements renderable, templatable {

/** @var string Return url */
private $returnurl;

/**
* Prepare the page for rendering.
*
*/
public function __construct() {

public function __construct($returnurl) {
$this->returnurl = $returnurl;
$this->prepare_global_page_access();
$this->prepare_policies();
}
Expand Down Expand Up @@ -99,6 +102,9 @@ public function export_for_template(renderer_base $output) {
];

$data->policies = array_values($this->policies);
if (!empty($this->returnurl)) {
$data->returnurl = $this->returnurl;
}

array_walk($data->policies, function($item, $key) {
$item->policytypestr = get_string('policydoctype'.$item->type, 'tool_policy');
Expand Down
1 change: 1 addition & 0 deletions admin/tool/policy/lang/en/tool_policy.php
Expand Up @@ -50,6 +50,7 @@
$string['agreedyeswithlink'] = 'Consent given; click to withdraw user consent for {$a}';
$string['agreedyeswithlinkall'] = 'Consent given; click to withdraw user consent for all policies';
$string['agreepolicies'] = 'Please agree to the following policies';
$string['backtoprevious'] = 'Go back to previous page';
$string['backtotop'] = 'Back to top';
$string['consentbulk'] = 'Consent';
$string['consentdetails'] = 'Give consent on behalf of user';
Expand Down
6 changes: 3 additions & 3 deletions admin/tool/policy/lib.php
Expand Up @@ -96,17 +96,17 @@ function tool_policy_before_standard_html_head() {
/**
* Callback to add footer elements.
*
* @return str valid html footer content
* @return string HTML footer content
*/
function tool_policy_standard_footer_html() {
global $CFG;
global $CFG, $PAGE;

$output = '';
if (!empty($CFG->sitepolicyhandler)
&& $CFG->sitepolicyhandler == 'tool_policy') {
$policies = api::get_current_versions_ids();
if (!empty($policies)) {
$url = (new moodle_url('/admin/tool/policy/viewall.php'))->out();
$url = new moodle_url('/admin/tool/policy/viewall.php', ['returnurl' => $PAGE->url]);
$output .= html_writer::link($url, get_string('userpolicysettings', 'tool_policy'));
$output = html_writer::div($output, 'policiesfooter');
}
Expand Down
8 changes: 8 additions & 0 deletions admin/tool/policy/templates/page_viewalldoc.mustache
Expand Up @@ -26,10 +26,12 @@
-
Context variables required for this template:
* returnurl - url to the previous page
* policies - policy array
Example context (json):
{
"returnurl": "#",
"policies": [
{
"id": "2",
Expand All @@ -51,6 +53,12 @@
}
}}

{{#returnurl}}
<div class="text-right m-b-1">
<a href="{{returnurl}}">{{# str }} backtoprevious, tool_policy {{/ str }}</a>
</div>
{{/returnurl}}

<a id="top"></a>
<div id="policies_index">
<h1>{{# str }} listactivepolicies, tool_policy {{/ str }}</h1>
Expand Down
4 changes: 3 additions & 1 deletion admin/tool/policy/viewall.php
Expand Up @@ -34,7 +34,9 @@
// @codingStandardsIgnoreLine See the {@link page_viewalldoc} for the access control checks.
require(__DIR__.'/../../../config.php');

$viewallpage = new page_viewalldoc();
$returnurl = optional_param('returnurl', '', PARAM_LOCALURL); // A return URL.

$viewallpage = new page_viewalldoc($returnurl);

$output = $PAGE->get_renderer('tool_policy');

Expand Down

0 comments on commit 5241540

Please sign in to comment.