navigation MDL-20235 Added ignore_active method for navbar and corrected user/view

This commit is contained in:
samhemelryk 2009-09-08 08:43:44 +00:00
parent 63dc5bfcb2
commit 3175908906
4 changed files with 17 additions and 8 deletions

View File

@ -1680,7 +1680,6 @@ $string['usernamelowercase'] = 'Only lowercase letters allowed';
$string['usernamenotfound'] = 'The username was not found in the database';
$string['usernotconfirmed'] = 'Could not confirm $a';
$string['userpic'] = 'User picture';
$string['userprofilefor'] = 'User profile for $a';
$string['users'] = 'Users';
$string['userselectorpreserveselected'] = 'Keep selected users, even if they no longer match the search';
$string['userselectorautoselectunique'] = 'If only one user matches the search, select them automatically';
@ -1695,7 +1694,7 @@ $string['valuealreadyused'] = 'This value has already been used.';
$string['version'] = 'Version';
$string['view'] = 'View';
$string['viewfileinpopup'] = 'View file in a popup window';
$string['viewmyprofile'] = 'View my profile';
$string['viewprofile'] = 'View profile';
$string['views'] = 'Views';
$string['viewsolution'] = 'view solution';
$string['virusfound'] = 'Attention administrator! Clam AV has found a virus in a file uploaded by $a->user for the course $a->course. Here is the output of clamscan:';

View File

@ -1793,6 +1793,8 @@ class navbar extends navigation_node {
/** @var page object */
protected $page;
/** @var bool */
protected $ignoreactive = false;
/** @var bool */
protected $duringinstall = false;
/**
@ -1822,7 +1824,14 @@ class navbar extends navigation_node {
return false;
}
$this->page->navigation->initialise();
return (count($this->page->navbar->children)>0 || $this->page->navigation->contains_active_node() || $this->page->settingsnav->contains_active_node());
return (count($this->page->navbar->children)>0 || (!$this->ignoreactive && (
$this->page->navigation->contains_active_node() ||
$this->page->settingsnav->contains_active_node())
));
}
public function ignore_active($setting=true) {
$this->ignoreactive = ($setting);
}
/**
@ -1857,10 +1866,10 @@ class navbar extends navigation_node {
$customchildren = (count($this->children) > 0);
// Check if navigation contains the active node
if ($this->page->navigation->contains_active_node()) {
if (!$this->ignoreactive && $this->page->navigation->contains_active_node()) {
// Parse the navigation tree to get the active node
$output .= $this->parse_branch_to_html($this->page->navigation->children, true, $customchildren);
} else if ($this->page->settingsnav->contains_active_node()) {
} else if (!$this->ignoreactive && $this->page->settingsnav->contains_active_node()) {
// Parse the settings navigation to get the active node
$output .= $this->parse_branch_to_html($this->page->settingsnav->children, true, $customchildren);
} else {
@ -2688,9 +2697,9 @@ class settings_navigation extends navigation_node {
// Add a link to view the user profile
if ($currentuser) {
$usersetting->add(get_string('viewmyprofile'), $profileurl, self::TYPE_SETTING);
$usersetting->add(get_string('viewprofile'), $profileurl, self::TYPE_SETTING);
} else {
$usersetting->add(get_string('userprofilefor','',$fullname), $profileurl, self::TYPE_SETTING);
$usersetting->add(get_string('viewprofile','',$fullname), $profileurl, self::TYPE_SETTING);
}
// Add the profile edit link

View File

@ -97,7 +97,7 @@
$personalcontext = get_context_instance(CONTEXT_USER, $user->id);
if ($user->id == $USER->id || has_capability('moodle/user:viewdetails', $coursecontext) || has_capability('moodle/user:viewdetails', $personalcontext) ) {
$toprow[] = new tabobject('profile', $CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$course->id, get_string('profile'));
$toprow[] = new tabobject('profile', $CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$course->id, get_string('viewprofile'));
}

View File

@ -78,6 +78,7 @@
if (has_capability('moodle/course:viewparticipants', $coursecontext) || has_capability('moodle/site:viewparticipants', $systemcontext)) {
$link = new moodle_url($CFG->wwwroot."/user/index.php", array('id'=>$course->id));
}
$PAGE->navbar->ignore_active();
$PAGE->navbar->add($strparticipants, $link);
/// If the user being shown is not ourselves, then make sure we are allowed to see them!