mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 20:53:53 +01:00
Merge branch 'MDL-62341-master' of git://github.com/mihailges/moodle
This commit is contained in:
commit
92af6a3998
@ -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');
|
||||
|
@ -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';
|
||||
|
@ -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');
|
||||
}
|
||||
|
@ -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}}
|
||||
<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>
|
||||
|
@ -256,3 +256,21 @@ Feature: Manage policies
|
||||
| Policy1 Site policy, All users | Inactive | v1 | 1 of 4 (25%) |
|
||||
And I should not see "v2"
|
||||
And I log out
|
||||
|
||||
Scenario: Current user can go back to previous page in List of active policies page
|
||||
Given the following policies exist:
|
||||
| Name | Revision | Content | Summary | Status |
|
||||
| Policy1 | v1 | full text2 | short text2 | active |
|
||||
And I log in as "user1"
|
||||
And I press "Next"
|
||||
And I set the field "I agree to the Policy1" to "1"
|
||||
And I press "Next"
|
||||
And I follow "Preferences" in the user menu
|
||||
And I should see "Preferences"
|
||||
And I should see "Policies"
|
||||
# User should see a redirect back to previous page link.
|
||||
And I click on "Policies" "link"
|
||||
And I should see "List of active policies"
|
||||
And I should see "Go back to previous page"
|
||||
When I click on "Go back to previous page" "link"
|
||||
Then I should see "Preferences"
|
||||
|
@ -34,7 +34,9 @@ define('NO_SITEPOLICY_CHECK', true);
|
||||
// @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');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user