From d5cfbc918fe2fc6e53aea5cab7bcf02690c772e7 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Mon, 16 Apr 2018 14:25:42 +0800 Subject: [PATCH] MDL-61864 tool_policy: cancel button when agreeing to policies Show cancel button during signup only and do not show when user is logged in and has to accept changed policies When cancel button is clicked redirect to the site homepage --- admin/tool/policy/classes/output/page_agreedocs.php | 3 +++ admin/tool/policy/index.php | 7 +++++-- admin/tool/policy/templates/page_agreedocs.mustache | 8 ++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/admin/tool/policy/classes/output/page_agreedocs.php b/admin/tool/policy/classes/output/page_agreedocs.php index 049b7db3c29..171a62a1716 100644 --- a/admin/tool/policy/classes/output/page_agreedocs.php +++ b/admin/tool/policy/classes/output/page_agreedocs.php @@ -401,6 +401,9 @@ class page_agreedocs implements renderable, templatable { $data->behalfuser = html_writer::link(\context_user::instance($this->behalfid)->get_url(), $userfullname); } + // User can cancel accepting policies only if it is a part of signup. + $data->cancancel = !isloggedin() || isguestuser(); + return $data; } diff --git a/admin/tool/policy/index.php b/admin/tool/policy/index.php index d53c0c558c3..38073ac9951 100644 --- a/admin/tool/policy/index.php +++ b/admin/tool/policy/index.php @@ -35,7 +35,8 @@ define('NO_SITEPOLICY_CHECK', true); // @codingStandardsIgnoreLine See the {@link page_agreedocs} for the access control checks. require(__DIR__.'/../../../config.php'); -$action = optional_param('action', null, PARAM_ALPHA); +$submit = optional_param('submit', null, PARAM_NOTAGS); +$cancel = optional_param('cancel', null, PARAM_NOTAGS); $agreedocs = optional_param_array('agreedoc', null, PARAM_INT); $behalfid = optional_param('userid', null, PARAM_INT); @@ -59,8 +60,10 @@ if (!empty($USER->id)) { if (!$haspermissionagreedocs) { $outputpage = new \tool_policy\output\page_nopermission($behalfid); +} else if ($cancel) { + redirect(new moodle_url('/')); } else { - $outputpage = new \tool_policy\output\page_agreedocs($agreedocs, $behalfid, $action); + $outputpage = new \tool_policy\output\page_agreedocs($agreedocs, $behalfid, $submit); } $output = $PAGE->get_renderer('tool_policy'); diff --git a/admin/tool/policy/templates/page_agreedocs.mustache b/admin/tool/policy/templates/page_agreedocs.mustache index 029b4335668..31674de4217 100644 --- a/admin/tool/policy/templates/page_agreedocs.mustache +++ b/admin/tool/policy/templates/page_agreedocs.mustache @@ -57,7 +57,6 @@
- {{#behalfuser}}
@@ -115,9 +114,10 @@ {{# str }}somefieldsrequired, form, {{/ str }}
- - - + +{{#cancancel}} + +{{/cancancel}} {{#js}}