You are here

function fasttoggle_user_view in Fasttoggle 7

Implements hook_user().

Add togglable links to user pages.

File

module/fasttoggle_user/fasttoggle_user.module, line 107

Code

function fasttoggle_user_view($account, $view_mode, $langcode) {
  $link_data = fasttoggle_user_link('user', $account, TRUE);
  $links = array();
  foreach ($link_data as $name => $link) {
    if ($name == 'status_status') {
      $links['status'] = array(
        'title' => l(t('@title', array(
          '@title' => $link['title'],
        )), $link['href'], $link),
        'html' => TRUE,
      );
    }
    else {
      if (strpos($name, 'role_') === 0) {
        $links[$name] = array(
          'title' => l(t('@title', array(
            '@title' => $link['title'],
          )), $link['href'], $link),
          'html' => TRUE,
        );
      }
      else {
        $links[$name] = array(
          'title' => l($link['title'], $link['href'], $link),
          'html' => TRUE,
        );
      }
    }
  }

  // If any links were made, add them to the entity's links array.
  if (isset($links)) {
    $account->content['links']['fasttoggle'] = array(
      '#theme' => 'links',
      '#links' => $links,
      '#attributes' => array(
        'class' => array(
          'links',
          'inline',
        ),
      ),
    );
  }
}