From 7a3eb1805b9ccdc1950e52ab48676521806f2968 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Wed, 12 Mar 2025 12:47:09 +0000 Subject: [PATCH] MDL-84745 cohort: capability check prior to bulk deletion button. --- cohort/index.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cohort/index.php b/cohort/index.php index f0b225c346d..7290f44cd7c 100644 --- a/cohort/index.php +++ b/cohort/index.php @@ -117,9 +117,13 @@ if (!empty($searchquery)) { // Show the report. echo $report->output(); -// Show the delete selected button if there are records. -if ($DB->record_exists('cohort', [])) { +// Show the delete selected button if there are records and user can manage cohorts in current context. +$canmanagecohorts = has_capability('moodle/cohort:manage', $context); +if ($showall) { + $canmanagecohorts = $canmanagecohorts || core_course_category::has_capability_on_any('moodle/cohort:manage'); +} +if ($canmanagecohorts && $DB->record_exists('cohort', [])) { echo $OUTPUT->render(new single_button( new moodle_url('#'), get_string('deleteselected'),