mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
MDL-77008 mod_data: require sesskey to reset module templates.
This commit is contained in:
parent
128c0c2160
commit
355556c05f
@ -198,7 +198,10 @@ class action_bar {
|
||||
|
||||
// Reset all templates action.
|
||||
$resetallurl = new moodle_url($this->currenturl);
|
||||
$resetallurl->param('action', 'resetalltemplates');
|
||||
$resetallurl->params([
|
||||
'action' => 'resetalltemplates',
|
||||
'sesskey' => sesskey(),
|
||||
]);
|
||||
$presetsactions->add(new \action_menu_link(
|
||||
$resetallurl,
|
||||
null,
|
||||
|
@ -57,6 +57,12 @@ $PAGE->set_url($url);
|
||||
require_login($course, false, $cm);
|
||||
require_capability('mod/data:managetemplates', $context);
|
||||
|
||||
if ($action == 'resetalltemplates') {
|
||||
require_sesskey();
|
||||
$manager->reset_all_templates();
|
||||
redirect($PAGE->url, get_string('templateresetall', 'mod_data'), null, \core\output\notification::NOTIFY_SUCCESS);
|
||||
}
|
||||
|
||||
$manager->set_template_viewed();
|
||||
|
||||
if ($useeditor !== null) {
|
||||
@ -86,11 +92,6 @@ if (!$manager->has_fields()) {
|
||||
$actionbar = new \mod_data\output\action_bar($instance->id, $url);
|
||||
echo $actionbar->get_templates_action_bar();
|
||||
|
||||
if ($action == 'resetalltemplates') {
|
||||
$manager->reset_all_templates();
|
||||
$notificationstr = get_string('templateresetall', 'mod_data');
|
||||
}
|
||||
|
||||
if (($formdata = data_submitted()) && confirm_sesskey()) {
|
||||
if (!empty($formdata->defaultform)) {
|
||||
// Reset the template to default.
|
||||
|
Loading…
x
Reference in New Issue
Block a user