Skip to content

Commit

Permalink
MDL-48935 navigation: Update the user nav breadcrumbs.
Browse files Browse the repository at this point in the history
Part of MDL-45774.
  • Loading branch information
abgreeve committed Apr 10, 2015
1 parent e42fb2d commit f495187
Show file tree
Hide file tree
Showing 19 changed files with 444 additions and 213 deletions.
1 change: 1 addition & 0 deletions admin/roles/check.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
$PAGE->set_url($url);

if ($context->contextlevel == CONTEXT_USER and $USER->id != $context->instanceid) {
$PAGE->navbar->includesettingsbase = true;
$PAGE->navigation->extend_for_user($user);
$PAGE->set_context(context_course::instance($course->id));
} else {
Expand Down
1 change: 1 addition & 0 deletions admin/roles/permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
$PAGE->set_url($url);

if ($context->contextlevel == CONTEXT_USER and $USER->id != $context->instanceid) {
$PAGE->navbar->includesettingsbase = true;
$PAGE->navigation->extend_for_user($user);
$PAGE->set_context(context_user::instance($user->id));
} else {
Expand Down
2 changes: 2 additions & 0 deletions blog/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
$sitecontext = context_system::instance();
$usercontext = context_user::instance($USER->id);
$PAGE->set_context($usercontext);
$blognode = $PAGE->settingsnav->find('blogadd', null);
$blognode->make_active();

require_login($courseid);

Expand Down
5 changes: 5 additions & 0 deletions blog/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@

$sitecontext = context_system::instance();

if (isset($userid) && $USER->id == $userid) {
$blognode = $PAGE->navigation->find('siteblog', null);
$blognode->make_inactive();
}

// Check basic permissions.
if ($CFG->bloglevel == BLOG_GLOBAL_LEVEL) {
// Everybody can see anything - no login required unless site is locked down using forcelogin.
Expand Down
2 changes: 2 additions & 0 deletions course/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@
$coursenode = $PAGE->navigation->find($course->id, navigation_node::TYPE_COURSE);
$coursenode->collapse = true;
$coursenode->make_inactive();
$url = new moodle_url('/course/user.php', array('id' => $id, 'user' => $user->id, 'mode' => $mode));
$reportnode = $PAGE->navbar->add(get_string('pluginname', 'gradereport_user'), $url);
}
echo $OUTPUT->header();

Expand Down
2 changes: 2 additions & 0 deletions grade/report/overview/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
} else {
$PAGE->set_context($context);
}
$settings = $PAGE->settingsnav->find('mygrades', null);
$settings->make_active();

$access = false;
if (has_capability('moodle/grade:viewall', $systemcontext)) {
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
} else if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_MY) && $redirect === 1) {
redirect($CFG->wwwroot .'/my/');
} else if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_USER)) {
$PAGE->settingsnav->get('usercurrentsettings')->add(
$PAGE->settingsnav->find('usercurrentsettings', null)->add(
get_string('makethismyhome'),
new moodle_url('/', array('setdefaulthome' => true)),
navigation_node::TYPE_SETTING);
Expand Down
2 changes: 0 additions & 2 deletions lang/en/moodle.php
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,6 @@
$string['user'] = 'User';
$string['useraccount'] = 'User account';
$string['userconfirmed'] = 'Confirmed {$a}';
$string['usercurrentsettings'] = 'Preferences';
$string['useractivity'] = 'Activity';
$string['userdata'] = 'User data';
$string['userdeleted'] = 'This user account has been deleted';
Expand All @@ -1935,7 +1934,6 @@
$string['usersnoaccesssince'] = 'Inactive for more than';
$string['userswithfiles'] = 'Users with files';
$string['useruploadtype'] = 'User upload type: {$a}';
$string['userviewingsettings'] = '{$a}\'s preferences';
$string['userzones'] = 'User zones';
$string['usetheme'] = 'Use theme';
$string['usingexistingcourse'] = 'Using existing course';
Expand Down
540 changes: 334 additions & 206 deletions lib/navigationlib.php

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions lib/outputrenderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -3388,6 +3388,11 @@ public function navbar() {
return '';
}

// Remove the Dashboard node from the breadcrumb. This saves doubling up of the same link.
if (get_home_page()) {
array_shift($items);
}

$htmlblocks = array();
// Iterate the navarray and display each node
$separator = get_separator();
Expand Down
1 change: 1 addition & 0 deletions message/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
if (is_siteadmin($user) and !is_siteadmin($USER)) {
print_error('useradmineditadmin');
}
$PAGE->navbar->includesettingsbase = true;
$PAGE->navigation->extend_for_user($user);
}

Expand Down
13 changes: 13 additions & 0 deletions message/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,19 @@
}
$PAGE->set_heading(fullname($USER));

// Remove the user node from the main navigation for this page.
$usernode = $PAGE->navigation->find('users', null);
$usernode->remove();

$settings = $PAGE->settingsnav->find('messages', null);
// Add the user we are contacting to the breadcrumb.
if (!empty($user2realuser)) {
$usernode = $settings->add(fullname($user2), new moodle_url('/user/profile.php', array('id' => $user2->id)));
$usernode->make_active();
} else {
$settings->make_active();
}

//now the page contents
echo $OUTPUT->header();

Expand Down
48 changes: 48 additions & 0 deletions mod/forum/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,43 @@
} else {
$notification = get_string('nopostsmadebyyou', 'forum');
}
// These are the user's forum interactions.
// Shut down the navigation 'Users' node.
$usernode = $PAGE->navigation->find('users', null);
$usernode->make_inactive();
// Edit navbar.
if (isset($courseid) && $courseid != SITEID) {
// Create as much of the navbar automatically.
$newusernode = $PAGE->navigation->find('user' . $user->id, null);
$newusernode->make_active();
// Check to see if this is a discussion or a post.
if ($mode == 'posts') {
$navbar = $PAGE->navbar->add(get_string('posts', 'forum'), new moodle_url('/mod/forum/user.php',
array('id' => $user->id, 'course' => $courseid)));
} else {
$navbar = $PAGE->navbar->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php',
array('id' => $user->id, 'course' => $courseid, 'mode'=>'discussions')));
}
}
} else if ($canviewuser) {
$PAGE->navigation->extend_for_user($user);
$PAGE->navigation->set_userid_for_parent_checks($user->id); // see MDL-25805 for reasons and for full commit reference for reversal when fixed.

// Edit navbar.
if (isset($courseid) && $courseid != SITEID) {
// Create as much of the navbar automatically.
$usernode = $PAGE->navigation->find('user' . $user->id, null);
$usernode->make_active();
// Check to see if this is a discussion or a post.
if ($mode == 'posts') {
$navbar = $PAGE->navbar->add(get_string('posts', 'forum'), new moodle_url('/mod/forum/user.php',
array('id' => $user->id, 'course' => $courseid)));
} else {
$navbar = $PAGE->navbar->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php',
array('id' => $user->id, 'course' => $courseid, 'mode'=>'discussions')));
}
}

$fullname = fullname($user);
if ($discussionsonly) {
$notification = get_string('nodiscussionsstartedby', 'forum', $fullname);
Expand Down Expand Up @@ -340,6 +374,20 @@
$PAGE->navigation->extend_for_user($user);
$PAGE->navigation->set_userid_for_parent_checks($user->id); // see MDL-25805 for reasons and for full commit reference for reversal when fixed.

// Edit navbar.
if (isset($courseid) && $courseid != SITEID) {
$usernode = $PAGE->navigation->find('user' . $user->id , null);
$usernode->make_active();
// Check to see if this is a discussion or a post.
if ($mode == 'posts') {
$navbar = $PAGE->navbar->add(get_string('posts', 'forum'), new moodle_url('/mod/forum/user.php',
array('id' => $user->id, 'course' => $courseid)));
} else {
$navbar = $PAGE->navbar->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php',
array('id' => $user->id, 'course' => $courseid, 'mode'=>'discussions')));
}
}

echo $OUTPUT->header();
echo $OUTPUT->heading($inpageheading);
echo html_writer::start_tag('div', array('class' => 'user-content'));
Expand Down
5 changes: 4 additions & 1 deletion my/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@
if (optional_param('setdefaulthome', false, PARAM_BOOL)) {
set_user_preference('user_home_page_preference', HOMEPAGE_MY);
} else if (!empty($CFG->defaulthomepage) && $CFG->defaulthomepage == HOMEPAGE_USER) {
$PAGE->settingsnav->get('usercurrentsettings')->add(get_string('makethismyhome'), new moodle_url('/my/', array('setdefaulthome'=>true)), navigation_node::TYPE_SETTING);
$PAGE->settingsnav->find('usercurrentsettings', null)->add(get_string('makethismyhome'),
new moodle_url('/my/', array('setdefaulthome'=>true)), navigation_node::TYPE_SETTING);
}
} else {
$mycoursenode = $PAGE->navigation->get('mycourses')->make_inactive();
}
}

Expand Down
4 changes: 4 additions & 0 deletions notes/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@
if ($userid) {
$PAGE->set_context(context_user::instance($user->id));
$PAGE->navigation->extend_for_user($user);
// If we are looking at our own notes, then change focus to 'my notes'.
if ($userid == $USER->id) {
$notenode = $PAGE->navigation->find('notes', null)->make_inactive();
}
} else {
$link = null;
if (has_capability('moodle/course:viewparticipants', $coursecontext)
Expand Down
6 changes: 6 additions & 0 deletions theme/bootstrapbase/renderers/core_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public function navbar() {
if (empty($items)) {
return '';
}

// Remove the Dashboard node from the breadcrumb. This saves doubling up of the same link.
if (get_home_page()) {
array_shift($items);
}

$breadcrumbs = array();
foreach ($items as $item) {
$item->hideicon = true;
Expand Down
1 change: 1 addition & 0 deletions user/editadvanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
require_capability('moodle/user:update', $systemcontext);
$user = $DB->get_record('user', array('id' => $id), '*', MUST_EXIST);
$PAGE->set_context(context_user::instance($user->id));
$PAGE->navbar->includesettingsbase = true;
if ($user->id != $USER->id) {
$PAGE->navigation->extend_for_user($user);
} else {
Expand Down
15 changes: 13 additions & 2 deletions user/preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,20 @@

if (!$currentuser) {
$PAGE->navigation->extend_for_user($user);
$settings = $PAGE->settingsnav->get('userviewingsettings' . $user->id);
$settings = $PAGE->settingsnav->find('userviewingsettings' . $user->id, null);
$settings->make_active();
$url = new moodle_url('/user/preferences.php', array('userid' => $userid));
$navbar = $PAGE->navbar->add(get_string('preferences', 'moodle'), $url);
} else {
$settings = $PAGE->settingsnav->get('usercurrentsettings');
// Shutdown the users node in the navigation menu.
$usernode = $PAGE->navigation->find('users', null);
$usernode->make_inactive();

$PAGE->set_title(get_string('preferences'));
$PAGE->set_heading(get_string('preferences'));

$settings = $PAGE->settingsnav->find('usercurrentsettings', null);
$settings->make_active();
}

// Identifying the nodes.
Expand Down
2 changes: 1 addition & 1 deletion user/profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
if ($node = $PAGE->settingsnav->get('userviewingsettings'.$user->id)) {
$node->forceopen = true;
}
} else if ($node = $PAGE->settingsnav->get('usercurrentsettings', navigation_node::TYPE_CONTAINER)) {
} else if ($node = $PAGE->settingsnav->get('dashboard', navigation_node::TYPE_CONTAINER)) {
$node->forceopen = true;
}
if ($node = $PAGE->settingsnav->get('root')) {
Expand Down

0 comments on commit f495187

Please sign in to comment.