You are here

function usertabs_menu_alter in User Tabs 7

Same name and namespace in other branches
  1. 6 usertabs.module \usertabs_menu_alter()

Implements hook_menu_alter().

File

./usertabs.module, line 19
usertabs.module

Code

function usertabs_menu_alter(&$callbacks) {
  $callbacks['user/%user/account'] = array(
    'title' => 'Account',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
    'load arguments' => array(
      '%map',
      '%index',
    ),
  );

  //move the original edit and view items to below this container
  _usertabs_move_item($callbacks, 'user/%user/view', 'user/%user/account/view', MENU_DEFAULT_LOCAL_TASK);
  _usertabs_move_item($callbacks, 'user/%user/edit', 'user/%user/account/edit', MENU_LOCAL_TASK);
  unset($callbacks['user/%user_category/edit/account']);
  if (($categories = _user_categories()) && count($categories) > 1) {
    foreach ($categories as $key => $category) {

      // 'account' is already handled by the MENU_DEFAULT_LOCAL_TASK.
      if ($category['name'] != 'account') {

        //it was too friggin complicated to support %user_category

        //see comments in user_category_load

        //all it does is check that the category name is valid
        _usertabs_move_item($callbacks, 'user/%user_category/edit/' . $category['name'], 'user/%user/account/' . $category['name']);
        $callbacks['user/%user/account/' . $category['name']]['tab_parent'] = 'user/%/account';
      }
    }
  }
}