Merge branch 'MDL-51803-master-mouse' of git://github.com/marinaglancy/moodle
[moodle.git] / admin / tool / policy / view.php
blobf2b4a77f77124dabc7f5afca4202ef0a550bdd3d
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * View current document policy version.
20 * Script parameters:
21 * versionid=<int> Policy version id, defaults to the current one.
22 * policyid=<int> Policy document id, defaults to the one matching the version.
23 * returnurl=<local url> URL to continue to after reading the policy document.
24 * behalfid=<id> The user id to view the policy version as (such as child's id).
25 * manage=<bool> View the policy as a part of the management UI (managedocs.php).
27 * @package tool_policy
28 * @copyright 2018 Sara Arjona (sara@moodle.com)
29 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32 use tool_policy\api;
33 use tool_policy\output\page_viewdoc;
35 // Do not check for the site policies in require_login() to avoid the redirect loop.
36 define('NO_SITEPOLICY_CHECK', true);
38 // @codingStandardsIgnoreLine See the {@link page_viewdoc} for the access control checks.
39 require(__DIR__.'/../../../config.php');
41 $versionid = optional_param('versionid', null, PARAM_INT);
42 $policyid = $versionid ? optional_param('policyid', null, PARAM_INT) : required_param('policyid', PARAM_INT);
43 $returnurl = optional_param('returnurl', null, PARAM_LOCALURL);
44 $behalfid = optional_param('behalfid', null, PARAM_INT);
45 $manage = optional_param('manage', false, PARAM_BOOL);
46 $numpolicy = optional_param('numpolicy', null, PARAM_INT);
47 $totalpolicies = optional_param('totalpolicies', null, PARAM_INT);
49 $PAGE->set_context(context_system::instance());
50 $PAGE->set_pagelayout('standard');
52 $viewpage = new page_viewdoc($policyid, $versionid, $returnurl, $behalfid, $manage, $numpolicy, $totalpolicies);
54 $output = $PAGE->get_renderer('tool_policy');
56 echo $output->header();
57 echo $output->render($viewpage);
58 echo $output->footer();