MDL-59826 output: make context_header() aware of page context.

There are times, such as when viewing a user profile within a course,
when user_can_view_profile() should be passed a course to force it to
restrict its capability checks to only the supplied course. This change
makes sure that core_renderer->context_header() calls this correctly.
This commit is contained in:
Jake Dallimore
2017-08-18 11:07:19 +08:00
parent 27466d7548
commit 788ea5c85c
+5 -5
View File
@@ -4185,12 +4185,12 @@ EOD;
}
// Only provide user information if the user is the current user, or a user which the current user can view.
$canviewdetails = false;
if ($user->id == $USER->id || user_can_view_profile($user)) {
$canviewdetails = true;
}
// When checking user_can_view_profile(), either:
// If the page context is course, check the course context (from the page object) or;
// If page context is NOT course, then check across all courses.
$course = ($this->page->context->contextlevel == CONTEXT_COURSE) ? $this->page->course : null;
if ($canviewdetails) {
if (user_can_view_profile($user, $course)) {
// Use the user's full name if the heading isn't set.
if (!isset($heading)) {
$heading = fullname($user);