You are here

function domain_conf_domain_bootstrap_full in Domain Access 6.2

Same name and namespace in other branches
  1. 7.3 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) {
  static $check;

  // 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) {
    global $_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'];
  $data = array();
  $data = db_fetch_array(db_query("SELECT settings FROM {domain_conf} WHERE domain_id = %d", $domain['domain_id']));
  if (!empty($data)) {
    global $conf;
    $settings = domain_unserialize($data['settings']);

    // 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') {
        $table = domain_get_primary_table('system');
        $language = (bool) db_result(db_query("SELECT status FROM {$table} WHERE name = 'locale' AND type = 'module'"));
        if ($language) {
          $table = domain_get_primary_table('languages');
          $temp = db_fetch_object(db_query("SELECT * FROM {$table} WHERE language = '%s'", $value));
          if (!empty($temp)) {
            $value = $temp;
            $GLOBALS['language'] = $temp;
            $conf[$key] = $value;
          }
        }
      }
      else {
        $conf[$key] = $value;
      }
    }
  }
}