From 7e7da9f8943810acb5de5cb18a4090b68bbcc8f0 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Fri, 5 Jan 2024 16:51:12 +0000 Subject: [PATCH] MDL-79913 grade: respect messaging config for user heading buttons. --- grade/lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grade/lib.php b/grade/lib.php index 8878dbd3dd7..81f77e8eca6 100644 --- a/grade/lib.php +++ b/grade/lib.php @@ -985,7 +985,8 @@ function print_grade_page_head(int $courseid, string $active_type, ?string $acti $renderer = $PAGE->get_renderer('core_grades'); // If the user is viewing their own grade report, no need to show the "Message" // and "Add to contact" buttons in the user heading. - $showuserbuttons = $user->id != $USER->id; + $showuserbuttons = $user->id != $USER->id && !empty($CFG->messaging) && + has_capability('moodle/site:sendmessage', $PAGE->context); $output = $renderer->user_heading($user, $courseid, $showuserbuttons); } else if (!empty($heading)) { $output = $OUTPUT->heading($heading);