Skip to content

Commit

Permalink
MDL-72367 badges: require sesskey to remove badge alignment.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulholden authored and Jenkins committed Jan 11, 2022
1 parent b09d50d commit eda7d88
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
6 changes: 4 additions & 2 deletions badges/alignment_action.php
Expand Up @@ -25,9 +25,9 @@
require_once(__DIR__ . '/../config.php');
require_once($CFG->libdir . '/badgeslib.php');

$alignmentid = required_param('alignmentid', PARAM_INT); // Related badge ID.
$alignmentid = required_param('alignmentid', PARAM_INT); // Alignment ID.
$badgeid = required_param('id', PARAM_INT); // Badge ID.
$action = optional_param('action', 'remove', PARAM_TEXT); // Remove.
$action = optional_param('action', 'remove', PARAM_TEXT); // Action to perform.

require_login();
$return = new moodle_url('/badges/alignment.php', array('id' => $badgeid));
Expand All @@ -36,6 +36,8 @@
require_capability('moodle/badges:configuredetails', $context);

if ($action == 'remove') {
require_sesskey();
$badge->delete_alignment($alignmentid);
}

redirect($return);
15 changes: 8 additions & 7 deletions badges/renderer.php
Expand Up @@ -1339,13 +1339,14 @@ protected function render_badge_alignments(\core_badges\output\badge_alignments
);
if (!$currentbadge->is_active() && !$currentbadge->is_locked()) {
$delete = $this->output->action_icon(
new moodle_url('alignment_action.php',
array(
'id' => $currentbadge->id,
'alignmentid' => $item->id,
'action' => 'remove'
)
), new pix_icon('t/delete', get_string('delete')));
new moodle_url('/badges/alignment_action.php', [
'id' => $currentbadge->id,
'alignmentid' => $item->id,
'sesskey' => sesskey(),
'action' => 'remove'
]),
new pix_icon('t/delete', get_string('delete'))
);
$edit = $this->output->action_icon(
new moodle_url('alignment.php',
array(
Expand Down

0 comments on commit eda7d88

Please sign in to comment.