From 0138ad60b0b5d9b70c71e5978deb3e918832d316 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Wed, 4 Jul 2018 07:52:47 +0200 Subject: [PATCH 1/2] MDL-62670 policy: Remove footer link when there are not active policies --- admin/tool/policy/lang/en/tool_policy.php | 1 + admin/tool/policy/lib.php | 9 ++++++--- admin/tool/policy/templates/page_viewalldoc.mustache | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/admin/tool/policy/lang/en/tool_policy.php b/admin/tool/policy/lang/en/tool_policy.php index c451c1a5cd0..b6b20d7aa98 100644 --- a/admin/tool/policy/lang/en/tool_policy.php +++ b/admin/tool/policy/lang/en/tool_policy.php @@ -92,6 +92,7 @@ $string['moveup'] = 'Move up'; $string['mustagreetocontinue'] = 'Before continuing you must agree to all these policies.'; $string['newpolicy'] = 'New policy'; $string['newversion'] = 'New version'; +$string['noactivepolicies'] = 'There are no policies with an active version.'; $string['nofiltersapplied'] = 'No filters applied'; $string['nopermissiontoagreedocs'] = 'No permission to agree to the policies'; $string['nopermissiontoagreedocs_desc'] = 'Sorry, you do not have the required permissions to agree to the policies.
You will not be able to use this site until the following policies are agreed:'; diff --git a/admin/tool/policy/lib.php b/admin/tool/policy/lib.php index 3073212169b..8bffdf503f7 100644 --- a/admin/tool/policy/lib.php +++ b/admin/tool/policy/lib.php @@ -104,9 +104,12 @@ function tool_policy_standard_footer_html() { $output = ''; if (!empty($CFG->sitepolicyhandler) && $CFG->sitepolicyhandler == 'tool_policy') { - $url = (new moodle_url('/admin/tool/policy/viewall.php'))->out(); - $output .= html_writer::link($url, get_string('userpolicysettings', 'tool_policy')); - $output = html_writer::div($output, 'policiesfooter'); + $policies = api::get_current_versions_ids(); + if (!empty($policies)) { + $url = (new moodle_url('/admin/tool/policy/viewall.php'))->out(); + $output .= html_writer::link($url, get_string('userpolicysettings', 'tool_policy')); + $output = html_writer::div($output, 'policiesfooter'); + } } return $output; diff --git a/admin/tool/policy/templates/page_viewalldoc.mustache b/admin/tool/policy/templates/page_viewalldoc.mustache index d25e40c8978..89812ffa07b 100644 --- a/admin/tool/policy/templates/page_viewalldoc.mustache +++ b/admin/tool/policy/templates/page_viewalldoc.mustache @@ -58,6 +58,10 @@ +{{^policies }} + {{# str }} noactivepolicies, tool_policy {{/ str }} +{{/policies }} + {{#policies }}
From 8502f02ae093b5f1c2efecd368c3e193b8b5c5b0 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Wed, 4 Jul 2018 07:59:54 +0200 Subject: [PATCH 2/2] MDL-62670 policy: viewall.php must display always all active policies The viewall.php page is called from the mobile app to display the policies to the users before agree them. That's why it must display all the active policies (even for guests), to guarantee the users agree all current policies from the app. --- admin/tool/policy/classes/output/page_viewalldoc.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/admin/tool/policy/classes/output/page_viewalldoc.php b/admin/tool/policy/classes/output/page_viewalldoc.php index f8dacf434d7..5ca5d99bd5e 100644 --- a/admin/tool/policy/classes/output/page_viewalldoc.php +++ b/admin/tool/policy/classes/output/page_viewalldoc.php @@ -63,14 +63,7 @@ class page_viewalldoc implements renderable, templatable { * */ protected function prepare_policies() { - global $USER; - - if (isguestuser() || empty($USER->id)) { - $audience = policy_version::AUDIENCE_GUESTS; - } else { - $audience = policy_version::AUDIENCE_LOGGEDIN; - } - $this->policies = api::list_current_versions($audience); + $this->policies = api::list_current_versions(); } /**