You are here

function domain_conf_domain_bootstrap_full in Domain Access 7.3

Same name and namespace in other branches
  1. 6.2 domain_conf/domain_conf.module \domain_conf_domain_bootstrap_full()
  2. 7.2 domain_conf/domain_conf.module \domain_conf_domain_bootstrap_full()

Implements hook_domain_bootstrap_full().

File

domain_conf/domain_conf.module, line 18
Domain manager configuration options.

Code

function domain_conf_domain_bootstrap_full($domain) {
  $check =& drupal_static(__FUNCTION__);

  // If running domain_set_domain(), we have issues with the variables
  // from the primary domain, which need to be loaded from cache.
  // @link http://drupal.org/node/412156
  if ($check) {
    $_domain = domain_get_domain();
    if ($domain['domain_id'] == 0 && $check != $_domain['domain_id']) {
      _domain_conf_load_primary(TRUE);
    }
  }

  // Flag that we have already loaded.
  $check = $domain['domain_id'];
  $settings = domain_conf_data_get($domain['domain_id']);
  if (!empty($settings)) {
    global $conf;

    // Overwrite the $conf variables.
    foreach ($settings as $key => $value) {
      if ($value === 'domain-conf-ignore') {
        continue;
      }

      // Language handling is a special case.
      if ($key == 'language_default') {
        $language = (bool) db_query("SELECT status FROM {system} WHERE name = 'locale' AND type = 'module'")
          ->fetchField();
        if ($language) {
          $temp = db_query('SELECT * FROM {languages} WHERE language = :language', array(
            ':language' => $value,
          ))
            ->fetchObject();
          if (!empty($temp)) {
            $value = $temp;
            $GLOBALS['language'] = $temp;
            $conf[$key] = $value;
          }

          // Ensure we store the default language in case of reset.
          // See domain_conf_js_maintain().
          $result = db_query('SELECT value FROM {variable} WHERE name = :name', array(
            ':name' => $key,
          ))
            ->fetchField();
          if (!empty($result)) {
            domain_conf_default_language(unserialize($result));
          }
        }
      }
      else {
        $conf[$key] = $value;
      }
    }
  }
}