You are here

function domain_block_view_switcher in Domain Access 7.2

Same name and namespace in other branches
  1. 7.3 domain.blocks.inc \domain_block_view_switcher()

A nifty little domain-switcher block, useful during debugging.

See also

domain_block_view()

File

./domain.blocks.inc, line 13
Block view functions for Domain Access.

Code

function domain_block_view_switcher() {
  $output = '';
  $list = array();
  $domains = domain_domains();
  $msg = FALSE;
  foreach ($domains as $domain) {
    if ($domain['valid']) {
      $title = $domain['sitename'];
      $allow = TRUE;
    }
    else {
      $title = $domain['sitename'] . ' *';
      $allow = FALSE;
      if (user_access('access inactive domains')) {
        $msg = TRUE;
        $allow = TRUE;
      }
    }
    if ($allow) {
      $list[] = l($title, domain_get_uri($domain), array(
        'absolute' => TRUE,
      ));
    }
  }
  $items = array(
    'items' => $list,
  );
  $output = theme('item_list', $items);
  $block = array(
    'subject' => t('Domain switcher'),
    'content' => array(
      '#markup' => $output,
    ),
  );
  return $block;
}