You are here

function domain_install in Domain Access 7.2

Same name and namespace in other branches
  1. 8 domain/domain.install \domain_install()
  2. 5 domain.install \domain_install()
  3. 6.2 domain.install \domain_install()
  4. 7.3 domain.install \domain_install()

Implements hook_install()

File

./domain.install, line 11
Install file.

Code

function domain_install() {
  $root = strtolower(rtrim($_SERVER['SERVER_NAME']));
  $site = variable_get('site_name', 'Drupal');
  $scheme = 'http';
  if (!empty($_SERVER['HTTPS'])) {
    $scheme = 'https';
  }
  db_insert('domain')
    ->fields(array(
    'subdomain' => $root,
    'sitename' => $site,
    'scheme' => $scheme,
    'valid' => 1,
  ))
    ->execute();

  // MySQL won't let us insert row 0 into an autoincrement table. Deducting
  // the value itself like this also handles auto_increment_offset settings.
  // Similar to the {users} tablein Drupal 6, this leaves us with no row 1.
  db_update('domain')
    ->expression('domain_id', 'domain_id - domain_id')
    ->execute();

  // Set the default domain variables.
  variable_set('domain_root', $root);
  variable_set('domain_scheme', $scheme);
  variable_set('domain_sitename', $site);

  // Tag the default domain.
  // In a later update function, we will remove the 0 record
  // and change this value.
  variable_set('domain_default', 0);
}