diff --git a/modules/simpletest/tests/menu.test b/modules/simpletest/tests/menu.test index b31fee6..79f798f 100644 --- a/modules/simpletest/tests/menu.test +++ b/modules/simpletest/tests/menu.test @@ -1440,7 +1440,10 @@ class MenuBreadcrumbTestCase extends MenuWebTestCase { $trail += array( 'user/' . $this->web_user->uid => $this->web_user->name, ); - $this->assertBreadcrumb('user/' . $this->web_user->uid . '/edit', $trail, $this->web_user->name); + $tree = array( + 'user' => t('My account'), + ); + $this->assertBreadcrumb('user/' . $this->web_user->uid . '/edit', $trail, $this->web_user->name, $tree); // Add a Navigation menu links for 'user' and $this->admin_user. // Although it may be faster to manage these links via low-level API diff --git a/modules/user/user.install b/modules/user/user.install index 217577d..6bf447e 100644 --- a/modules/user/user.install +++ b/modules/user/user.install @@ -909,5 +909,17 @@ function user_update_7018() { } /** + * Move menu link "My account" and its children from Navigation to User menu, by + * deleting them if non-customized. + */ +function user_update_7019() { + db_delete('menu_links') + ->condition('link_path', db_like('user/%') . '%', 'LIKE') + ->condition('module', 'system') + ->condition('customized', 0) + ->execute(); +} + +/** * @} End of "addtogroup updates-7.x-extra". */ diff --git a/modules/user/user.module b/modules/user/user.module index 47ac642..a97e750 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -1736,12 +1736,6 @@ function user_menu() { 'page arguments' => array(1), 'access callback' => 'user_view_access', 'access arguments' => array(1), - // By assigning a different menu name, this item (and all registered child - // paths) are no longer considered as children of 'user'. When accessing the - // user account pages, the preferred menu link that is used to build the - // active trail (breadcrumb) will be found in this menu (unless there is - // more specific link), so the link to 'user' will not be in the breadcrumb. - 'menu_name' => 'navigation', ); $items['user/%user/view'] = array( @@ -1869,6 +1863,17 @@ function user_menu_link_alter(&$link) { } /** + * Implements hook_menu_breadcrumb_alter(). + */ +function user_menu_breadcrumb_alter(&$active_trail, $item) { + // Remove "My account" from the breadcrumb when $item is descendant-or-self + // of system path user/%. + if (isset($active_trail[1]['module']) && $active_trail[1]['module'] == 'system' && $active_trail[1]['link_path'] == 'user' && strpos($item['path'], 'user/%') === 0) { + array_splice($active_trail, 1, 1); + } +} + +/** * Implements hook_translated_menu_link_alter(). */ function user_translated_menu_link_alter(&$link) {