diff --git a/admin/tool/policy/classes/output/page_viewalldoc.php b/admin/tool/policy/classes/output/page_viewalldoc.php index 66ea3aa25a7..801aac0c516 100644 --- a/admin/tool/policy/classes/output/page_viewalldoc.php +++ b/admin/tool/policy/classes/output/page_viewalldoc.php @@ -48,12 +48,15 @@ use tool_policy\policy_version; */ 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(); } @@ -99,6 +102,9 @@ class page_viewalldoc implements renderable, templatable { ]; $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'); diff --git a/admin/tool/policy/lang/en/tool_policy.php b/admin/tool/policy/lang/en/tool_policy.php index 3a752851900..8f2a1d5658d 100644 --- a/admin/tool/policy/lang/en/tool_policy.php +++ b/admin/tool/policy/lang/en/tool_policy.php @@ -50,6 +50,7 @@ $string['agreedyesonbehalfwithlinkall'] = 'Consent given on behalf of user; clic $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'; diff --git a/admin/tool/policy/lib.php b/admin/tool/policy/lib.php index 62919d38b63..563254d814c 100644 --- a/admin/tool/policy/lib.php +++ b/admin/tool/policy/lib.php @@ -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'); } diff --git a/admin/tool/policy/templates/page_viewalldoc.mustache b/admin/tool/policy/templates/page_viewalldoc.mustache index 2f9df36e0a5..3e4664c1a0a 100644 --- a/admin/tool/policy/templates/page_viewalldoc.mustache +++ b/admin/tool/policy/templates/page_viewalldoc.mustache @@ -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", @@ -51,6 +53,12 @@ } }} +{{#returnurl}} +
+{{/returnurl}} +