You are here

function _domain_bootstrap in Domain Access 6.2

Same name and namespace in other branches
  1. 7.3 domain.bootstrap.inc \_domain_bootstrap()
  2. 7.2 domain.bootstrap.inc \_domain_bootstrap()

Calls individual bootstrap phases.

Parameters

$phase: The domain bootstrap phase to call.

Return value

Returns TRUE if the bootstrap phase was successful and FALSE otherwise.

1 call to _domain_bootstrap()
domain_bootstrap in ./domain.bootstrap.inc
Domain module bootstrap: calls all bootstrap phases.

File

./domain.bootstrap.inc, line 72
Domain bootstrap file.

Code

function _domain_bootstrap($phase) {
  global $_domain;
  switch ($phase) {
    case DOMAIN_BOOTSTRAP_INIT:

      // Make sure database is loaded
      drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);

      // If the module has been disabled, stop loading.
      $table = domain_get_primary_table('system');
      $check = db_result(db_query("SELECT status FROM {$table} WHERE name = 'domain' AND type = 'module'"));
      if (empty($check)) {
        return NULL;
      }

      // Load bootstrap modules registered by Domain Access.
      _domain_bootstrap_modules_load();

      // If essential core module file has not been loaded, bootstrap fails.
      if (!function_exists('domain_load')) {
        return FALSE;
      }
      break;
    case DOMAIN_BOOTSTRAP_NAME_RESOLVE:

      // Get the domain_id of the request.
      $_domain = domain_resolve_host();

      // If we don't have a valid domain id now, we can't really go on, bootstrap fails.
      if (empty($_domain) || !is_numeric($_domain['domain_id'])) {
        return FALSE;
      }
      break;
    case DOMAIN_BOOTSTRAP_FULL:

      // Make sure the load process worked correctly before invoking the hook.
      if (!domain_settings_setup_ok()) {
        return FALSE;
      }

      // Grant access to all affiliates. See http://drupal.org/node/770650
      $_domain['site_grant'] = DOMAIN_SITE_GRANT;
      _domain_bootstrap_invoke_all('full', $_domain);
      break;
  }
  return TRUE;
}