usertabs.module in User Tabs 7
Same filename and directory in other branches
This module puts the tab for the edition of the user account under the view tab
original module by Robert Garrigos http://garrigos.cat maintained my matslats http://matslats.net
File
usertabs.moduleView source
<?php
// $Id: usertabs.module,v 1.3.2.1 2010/12/31 14:37:24 matslats Exp $
/**
* @file
* usertabs.module
*
* This module puts the tab for the edition of the user account under the view tab
*
* original module by Robert Garrigos http://garrigos.cat
* maintained my matslats http://matslats.net
*/
/**
* Implements hook_menu_alter().
*/
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';
}
}
}
}
function _usertabs_move_item(&$callbacks, $from, $to, $type = NULL) {
$callbacks[$to] = $callbacks[$from];
if ($type) {
$callbacks[$to]['type'] = $type;
}
unset($callbacks[$from]);
}
/*
* implements hook_url_outbound
*/
function usertabs_url_outbound_alter(&$path, $options, $original_path) {
_update_user_edit_path($path);
}
/*
* implement hook_drupal_goto
*/
function usertabs_drupal_goto_alter(&$path, $options, $response_code) {
_update_user_edit_path($path);
}
/*
* implements hook form_FORM_ID_alter
* change the user edit links on the user management form
*/
function usertabs_preprocess_link(&$link) {
_update_user_edit_path($link['path']);
}
function _update_user_edit_path(&$path) {
if (substr($path, 0, 5) != 'user/') {
return;
}
$args = explode('/', $path);
if (count($args) > 2 && $args[2] == 'edit') {
$path = str_replace('edit', 'account/edit', $path);
}
}