You are here

function domain_user_view in Domain Access 7.2

Same name and namespace in other branches
  1. 7.3 domain.module \domain_user_view()

Implements hook_user_view().

File

./domain.module, line 444
Core module functions for the Domain Access suite.

Code

function domain_user_view($account, $view_mode) {

  // Only show on full view.
  if ($view_mode != 'full') {
    return;
  }

  // Only show trusted users.
  // TODO: Make this a new permission.
  if (!user_access('assign domain editors')) {
    return;
  }
  $output = '';
  $account->content['domain'] = array(
    '#type' => 'user_profile_category',
    '#weight' => 10,
    '#title' => t('Domain status'),
  );
  if (empty($account->domain_user)) {
    $output = t('This user is not assigned to a domain.');
  }
  else {
    $items = array();
    foreach (array_filter($account->domain_user) as $id) {
      $id == -1 ? $key = 0 : ($key = $id);
      $domain = domain_lookup($key);
      $items[] = check_plain($domain['sitename']);
    }
    $output = theme('item_list', array(
      'items' => $items,
    ));
  }
  $account->content['domain']['domain_settings'] = array(
    '#type' => 'user_profile_item',
    '#title' => t('Assigned domains'),
    '#markup' => $output,
  );
}