3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
19 * Allow overriding of roles by other roles
23 * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 require_once(dirname(__FILE__
) . '/../../config.php');
28 require_once($CFG->libdir
. '/adminlib.php');
29 require_once($CFG->dirroot
. '/' . $CFG->admin
. '/roles/lib.php');
31 $mode = required_param('mode', PARAM_ACTION
);
32 $classformode = array(
33 'assign' => 'role_allow_assign_page',
34 'override' => 'role_allow_override_page',
35 'switch' => 'role_allow_switch_page'
37 if (!isset($classformode[$mode])) {
38 print_error('invalidmode', '', '', $mode);
41 $baseurl = new moodle_url('/admin/roles/allow.php', array('mode'=>$mode));
42 admin_externalpage_setup('defineroles', '', array(), $baseurl);
44 $syscontext = get_context_instance(CONTEXT_SYSTEM
);
45 require_capability('moodle/role:manage', $syscontext);
47 $controller = new $classformode[$mode]();
49 if (optional_param('submit', false, PARAM_BOOL
) && data_submitted() && confirm_sesskey()) {
50 $controller->process_submission();
51 mark_context_dirty($syscontext->path
);
52 add_to_log(SITEID
, 'role', 'edit allow ' . $mode, str_replace($CFG->wwwroot
. '/', '', $baseurl), '', '', $USER->id
);
56 $controller->load_current_settings();
58 // Display the editing form.
59 echo $OUTPUT->header();
62 require('managetabs.php');
64 $table = $controller->get_table();
66 echo $OUTPUT->box($controller->get_intro_text());
68 echo '<form action="' . $baseurl . '" method="post">';
69 echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
70 echo html_writer
::table($table);
71 echo '<div class="buttons"><input type="submit" name="submit" value="'.get_string('savechanges').'"/>';
74 echo $OUTPUT->footer();