2 // This file is part of Moodle - http://moodle.org/
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.
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/>.
18 * Customise the course role names.
21 * @copyright 2023 Ferran Recio <ferran@moodle.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 require('../config.php');
26 require_once("$CFG->dirroot/course/lib.php");
29 $id = required_param('id', PARAM_INT
);
30 $action = optional_param('action', '', PARAM_ALPHANUMEXT
);
31 $filter = optional_param('ifilter', 0, PARAM_INT
);
33 $course = $DB->get_record('course', ['id' => $id], '*', MUST_EXIST
);
34 $context = core\context\course
::instance($course->id
, MUST_EXIST
);
36 require_login($course);
37 require_capability('moodle/course:renameroles', $context);
39 if ($course->id
== SITEID
) {
40 redirect("$CFG->wwwroot/");
43 $PAGE->set_pagelayout('admin');
44 $PAGE->set_url('/enrol/renameroles.php', ['id' => $course->id
]);
45 $PAGE->set_pagelayout('standard');
46 $PAGE->set_title(get_string('rolerenaming'));
47 $PAGE->set_heading($course->fullname
);
49 echo $OUTPUT->header();
50 echo $OUTPUT->render_participants_tertiary_nav($course);
52 echo $OUTPUT->paragraph(get_string('rolerenaming_help'));
56 'roles' => role_get_names($context, ROLENAME_ORIGINAL
),
58 $mform = new core_enrol\form\renameroles
(null, $customdata);
59 if ($data = $mform->get_data()) {
60 save_local_role_names($course->id
, (array)$data);
61 core\notification
::add(get_string('rolerenaming_success'), core\notification
::SUCCESS
);
66 echo $OUTPUT->footer();