MDL-48931 navigation: Update grade lib for the user context header.

Part of MDL-45774
This commit is contained in:
Adrian Greeve 2015-03-05 16:51:31 +08:00
parent 283ea788bf
commit 1acbd1f9b4

View File

@ -818,12 +818,14 @@ class grade_plugin_info {
* @param boolean $shownavigation should the gradebook navigation drop down (or tabs) be shown? * @param boolean $shownavigation should the gradebook navigation drop down (or tabs) be shown?
* @param string $headerhelpidentifier The help string identifier if required. * @param string $headerhelpidentifier The help string identifier if required.
* @param string $headerhelpcomponent The component for the help string. * @param string $headerhelpcomponent The component for the help string.
* @param stdClass $user The user object for use with the user context header.
* *
* @return string HTML code or nothing if $return == false * @return string HTML code or nothing if $return == false
*/ */
function print_grade_page_head($courseid, $active_type, $active_plugin=null, function print_grade_page_head($courseid, $active_type, $active_plugin=null,
$heading = false, $return=false, $heading = false, $return=false,
$buttons=false, $shownavigation=true, $headerhelpidentifier = null, $headerhelpcomponent = null) { $buttons=false, $shownavigation=true, $headerhelpidentifier = null, $headerhelpcomponent = null,
$user = null) {
global $CFG, $OUTPUT, $PAGE; global $CFG, $OUTPUT, $PAGE;
if ($active_type === 'preferences') { if ($active_type === 'preferences') {
@ -870,9 +872,16 @@ function print_grade_page_head($courseid, $active_type, $active_plugin=null,
} }
if ($shownavigation) { if ($shownavigation) {
$navselector = null;
if ($courseid != SITEID && if ($courseid != SITEID &&
($CFG->grade_navmethod == GRADE_NAVMETHOD_COMBO || $CFG->grade_navmethod == GRADE_NAVMETHOD_DROPDOWN)) { ($CFG->grade_navmethod == GRADE_NAVMETHOD_COMBO || $CFG->grade_navmethod == GRADE_NAVMETHOD_DROPDOWN)) {
$returnval .= print_grade_plugin_selector($plugin_info, $active_type, $active_plugin, $return); // It's absolutely essential that this grade plugin selector is shown after the user header. Just ask Fred.
$navselector = print_grade_plugin_selector($plugin_info, $active_type, $active_plugin, true);
if ($return) {
$returnval .= $navselector;
} else if (!isset($user)) {
echo $navselector;
}
} }
$output = ''; $output = '';
@ -880,7 +889,17 @@ function print_grade_page_head($courseid, $active_type, $active_plugin=null,
if (isset($headerhelpidentifier)) { if (isset($headerhelpidentifier)) {
$output = $OUTPUT->heading_with_help($heading, $headerhelpidentifier, $headerhelpcomponent); $output = $OUTPUT->heading_with_help($heading, $headerhelpidentifier, $headerhelpcomponent);
} else { } else {
$output = $OUTPUT->heading($heading); if (isset($user)) {
$output = $OUTPUT->context_header(
array(
'heading' => fullname($user),
'user' => $user,
'usercontext' => context_user::instance($user->id)
), 2
) . $navselector;
} else {
$output = $OUTPUT->heading($heading);
}
} }
if ($return) { if ($return) {