MDL-79913 grade: respect messaging config for user heading buttons.

This commit is contained in:
Paul Holden 2024-01-05 16:51:12 +00:00
parent 757be30c39
commit 7e7da9f894
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164

View File

@ -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);