Implements hook_toolbar().
function user_toolbar() {
global $user;
// Add logout & user account links or login link.
if ($user->uid) {
$links = array(
'account' => array(
'title' => t('View profile'),
'href' => 'user',
'html' => TRUE,
'attributes' => array(
'title' => t('User account'),
),
),
'account_edit' => array(
'title' => t('Edit profile'),
'href' => 'user/' . $user->uid . '/edit',
'html' => TRUE,
'attributes' => array(
'title' => t('Edit user account'),
),
),
'logout' => array(
'title' => t('Log out'),
'href' => 'user/logout',
),
);
}
else {
$links = array(
'login' => array(
'title' => t('Log in'),
'href' => 'user',
),
);
}
$items['user'] = array(
'#type' => 'toolbar_item',
'tab' => array(
'#type' => 'link',
'#title' => user_format_name($user),
'#href' => 'user',
'#options' => array(
'attributes' => array(
'title' => t('My account'),
'class' => array(
'icon',
'icon-user',
),
),
),
),
'tray' => array(
'#heading' => t('User account actions'),
'user_links' => array(
'#theme' => 'links__toolbar_user',
'#links' => $links,
'#attributes' => array(
'class' => array(
'menu',
),
),
),
),
'#weight' => 100,
);
return $items;
}