source: moodle/trunk/fuentes/admin/roles/allow.php @ 1331

Last change on this file since 1331 was 136, checked in by mabarracus, 4 years ago

Ported code to xenial

File size: 2.8 KB
Line 
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
25require_once(dirname(__FILE__) . '/../../config.php');
26require_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);
34if (!isset($classformode[$mode])) {
35    print_error('invalidmode', '', '', $mode);
36}
37
38$baseurl = new moodle_url('/admin/roles/allow.php', array('mode'=>$mode));
39admin_externalpage_setup('defineroles', '', array(), $baseurl);
40
41$syscontext = context_system::instance();
42require_capability('moodle/role:manage', $syscontext);
43
44$controller = new $classformode[$mode]();
45
46if (optional_param('submit', false, PARAM_BOOL) && data_submitted() && confirm_sesskey()) {
47    $controller->process_submission();
48    $syscontext->mark_dirty();
49    $event = null;
50    // Create event depending on mode.
51    switch ($mode) {
52        case 'assign':
53            $event = \core\event\role_allow_assign_updated::create(array('context' => $syscontext));
54            break;
55        case 'override':
56            $event = \core\event\role_allow_override_updated::create(array('context' => $syscontext));
57            break;
58        case 'switch':
59            $event = \core\event\role_allow_switch_updated::create(array('context' => $syscontext));
60            break;
61    }
62    if ($event) {
63        $event->trigger();
64    }
65    redirect($baseurl);
66}
67
68$controller->load_current_settings();
69
70// Display the editing form.
71echo $OUTPUT->header();
72
73$currenttab = $mode;
74require('managetabs.php');
75
76$table = $controller->get_table();
77
78echo $OUTPUT->box($controller->get_intro_text());
79
80echo '<form action="' . $baseurl . '" method="post">';
81echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
82echo html_writer::table($table);
83echo '<div class="buttons"><input type="submit" name="submit" value="'.get_string('savechanges').'"/>';
84echo '</div></form>';
85
86echo $OUTPUT->footer();
Note: See TracBrowser for help on using the repository browser.