You are here

function admin_menu_links_account in Administration menu 8.3

Same name and namespace in other branches
  1. 7.3 admin_menu.inc \admin_menu_links_account()

Builds the account links.

See also

theme_admin_menu_links()

1 call to admin_menu_links_account()
admin_menu_output in ./admin_menu.module
Build the administration menu output.

File

./admin_menu.inc, line 528
Menu builder functions for Administration menu.

Code

function admin_menu_links_account() {
  $links = [
    '#theme' => 'admin_menu_links',
    '#wrapper_attributes' => [
      'id' => 'admin-menu-account',
    ],
    '#weight' => 100,
  ];
  $links['account'] = [
    '#title' => user_format_name($GLOBALS['user']),
    '#weight' => -99,
    '#attributes' => [
      'class' => [
        'admin-menu-action',
        'admin-menu-account',
      ],
    ],
    '#href' => 'user/' . $GLOBALS['user']->uid,
  ];
  $links['logout'] = [
    '#title' => t('Log out'),
    '#weight' => -100,
    '#attributes' => [
      'class' => [
        'admin-menu-action',
      ],
    ],
    '#href' => 'user/logout',
  ];

  // Add Devel module switch user links.
  if (!module_exists('masquerade')) {
    $switch_links = module_invoke('devel', 'switch_user_list');
    if (!empty($switch_links) && count($switch_links) > 1) {
      foreach ($switch_links as $uid => $link) {
        $links['account'][$uid] = [
          '#title' => $link['title'],
          '#description' => $link['attributes']['title'],
          '#href' => $link['href'],
          '#options' => [
            'query' => $link['query'],
            'html' => !empty($link['html']),
          ],
        ];
      }
    }
  }
  return $links;
}