You are here

function domain_default in Domain Access 7.3

Same name and namespace in other branches
  1. 5 domain.module \domain_default()
  2. 6.2 domain.module \domain_default()
  3. 7.2 domain.module \domain_default()

Assigns the default settings to domain 0, the root domain.

This value is used throughout the modules. Even though this record is in the {domain} table, we use the value stored as a variable. Doing so prevents the module from firing when it has not been configured.

Parameters

$reset: A boolean flag indicating whether to reset the static array or not.

$alter: A boolean flag indicating whether to allow hook_domain_load(). In some cases where external scripts do not pass an HTTP_HOST, Drupal does not behave as expected and we cannot trigger this API call.

Return value

The domain array for the default domain.

See also

domain_request_name()

28 calls to domain_default()
DomainCacheTest::testDomainPageCache in tests/domain.test
DomainConfTestCase::testCrudUtilities in domain_conf/tests/domain_conf.test
Base test assertions for the CRUD layer in Domain Conf.
DomainConfTestCase::testDomainConfDataGetCashes in domain_conf/tests/domain_conf.test
DomainCreateTest::testDomainSave in tests/domain.test
DomainHookTest::testDomainHooks in tests/domain.test

... See full list

1 string reference to 'domain_default'
domain_update_7301 in ./domain.install
Add default domain flag and weight the default higher.

File

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

Code

function domain_default($reset = FALSE, $alter = TRUE) {
  $default =& drupal_static(__FUNCTION__);
  $altered =& drupal_static(__FUNCTION__ . '_altered');
  if (empty($default) || $reset) {
    $altered = FALSE;

    // Temporary hack for update to 7.x.3.
    if (db_table_exists('domain_export')) {
      $default = db_query("SELECT domain_id, subdomain, sitename, scheme, valid, weight, is_default, machine_name FROM {domain} WHERE is_default = 1")
        ->fetchAssoc();
    }
    else {
      $default = db_query("SELECT domain_id, subdomain, sitename, scheme, valid, weight, is_default FROM {domain} WHERE is_default = 1")
        ->fetchAssoc();
    }

    // Let submodules overwrite the defaults, if they wish.
    if (empty($default)) {
      $default = array(
        'domain_id' => 0,
        // Indicates we have not set a real domain.
        'subdomain' => isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '',
        'sitename' => variable_get('site_name', 'Drupal'),
        'scheme' => empty($_SERVER['HTTPS']) ? 'http' : 'https',
        'valid' => 1,
        'is_default' => 1,
        'machine_name' => domain_machine_name($default['subdomain']),
      );
    }
  }

  // If an altered version is requested, has $default been altered before?
  if ($alter && !$altered) {

    // Let submodules overwrite the defaults, if they wish.
    $default = domain_api($default, $reset);
  }
  return $default;
}