Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

   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   * Allow overriding of roles by other roles.
  19   *
  20   * @package    core_role
  21   * @copyright  1999 onwards Martin Dougiamas (http://dougiamas.com)
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  require_once(__DIR__ . '/../../config.php');
  26  require_once($CFG->libdir . '/adminlib.php');
  27  
  28  $mode = required_param('mode', PARAM_ALPHANUMEXT);
  29  $classformode = array(
  30      'assign' => 'core_role_allow_assign_page',
  31      'override' => 'core_role_allow_override_page',
  32      'switch' => 'core_role_allow_switch_page',
  33      'view' => 'core_role_allow_view_page'
  34  );
  35  if (!isset($classformode[$mode])) {
  36      print_error('invalidmode', '', '', $mode);
  37  }
  38  
  39  $baseurl = new moodle_url('/admin/roles/allow.php', array('mode'=>$mode));
  40  admin_externalpage_setup('defineroles', '', array(), $baseurl);
  41  
  42  $syscontext = context_system::instance();
  43  require_capability('moodle/role:manage', $syscontext);
  44  
  45  $controller = new $classformode[$mode]();
  46  
  47  if (optional_param('submit', false, PARAM_BOOL) && data_submitted() && confirm_sesskey()) {
  48      $controller->process_submission();
  49      redirect($baseurl);
  50  }
  51  
  52  $controller->load_current_settings();
  53  
  54  // Display the editing form.
  55  echo $OUTPUT->header();
  56  
  57  $currenttab = $mode;
  58  require ('managetabs.php');
  59  
  60  $table = $controller->get_table();
  61  
  62  echo $OUTPUT->box($controller->get_intro_text());
  63  
  64  echo '<form action="' . $baseurl . '" method="post">';
  65  echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
  66  echo html_writer::table($table);
  67  echo '<div class="buttons">';
  68  echo '<input type="submit" class="btn btn-primary" name="submit" value="' . get_string('savechanges') . '"/>';
  69  echo '</div></form>';
  70  
  71  echo $OUTPUT->footer();