Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 39 and 402]

   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.
  13  //
  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/>.
  16  
  17  /**
  18   * View current document policy version.
  19   *
  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).
  26   *
  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
  30   */
  31  
  32  use tool_policy\api;
  33  use tool_policy\output\page_viewdoc;
  34  
  35  // Do not check for the site policies in require_login() to avoid the redirect loop.
  36  define('NO_SITEPOLICY_CHECK', true);
  37  
  38  // See the {@see page_viewdoc} for the access control checks.
  39  require(__DIR__.'/../../../config.php'); // phpcs:ignore
  40  
  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);
  48  
  49  $PAGE->set_context(context_system::instance());
  50  $PAGE->set_pagelayout('standard');
  51  
  52  $viewpage = new page_viewdoc($policyid, $versionid, $returnurl, $behalfid, $manage, $numpolicy, $totalpolicies);
  53  
  54  $output = $PAGE->get_renderer('tool_policy');
  55  
  56  echo $output->header();
  57  echo $output->render($viewpage);
  58  echo $output->footer();