You are here

function domain_nav_menu in Domain Access 7.2

Same name and namespace in other branches
  1. 5 domain_nav/domain_nav.module \domain_nav_menu()
  2. 6.2 domain_nav/domain_nav.module \domain_nav_menu()
  3. 7.3 domain_nav/domain_nav.module \domain_nav_menu()

Implements hook_menu()

File

domain_nav/domain_nav.module, line 25
Navigation block and menu options for Domain Access

Code

function domain_nav_menu() {
  $items = array();

  // The exists check is needed on uninstall. See http://drupal.org/node/995342
  if (DOMAIN_NAV_MENU == TRUE && module_exists('domain')) {
    $root = domain_default(TRUE, TRUE);
    $items['domain'] = array(
      'title' => 'Domain',
      'type' => MENU_SUGGESTED_ITEM,
      'page callback' => 'drupal_goto',
      'page arguments' => array(
        $root['path'],
      ),
      'access callback' => 'domain_nav_check',
      'access arguments' => array(
        TRUE,
      ),
      'description' => 'Go to main site',
    );

    // Generate the list of active domains as menu items
    $domains = domain_domains();
    foreach ($domains as $domain) {

      // If the domain is not valid, we disable it by default.
      $type = MENU_NORMAL_ITEM;
      if (empty($domain['valid'])) {
        $type = MENU_SUGGESTED_ITEM;
      }
      $items['domain/' . filter_xss_admin($domain['subdomain'])] = array(
        'title' => check_plain($domain['sitename']),
        'type' => $type,
        'page callback' => 'drupal_goto',
        'page arguments' => array(
          $domain['path'],
        ),
        'access callback' => 'domain_nav_check',
        'access arguments' => array(
          TRUE,
        ),
        'description' => 'Go to ' . filter_xss_admin($domain['subdomain']),
      );
    }
  }
  return $items;
}