You are here

function _domain_conf_load_primary in Domain Access 7.2

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

Load the variables from the primary domain.

We run this special handler when not able to trust variable_get() during domain switching.

Parameters

$unset: If TRUE, this will reset the global $conf array.

Return value

If set to TRUE, no return, just modify the global $conf array. Otherwise, return the settings data for the primary domain.

See also

domain_set_domain()

2 calls to _domain_conf_load_primary()
domain_conf_domain_bootstrap_full in domain_conf/domain_conf.module
Implements hook_domain_bootstrap_full().
domain_conf_variable_get in domain_conf/domain_conf.module
Load a variable specific to a domain.

File

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

Code

function _domain_conf_load_primary($unset = FALSE) {
  static $settings;
  if (!isset($settings)) {

    // Account for table prefixing.
    $cache_table = domain_get_primary_table('cache');

    // Load the query.
    $data = db_query("SELECT data FROM {$cache_table} WHERE cid = 'variables'")
      ->fetchField();
    if (!empty($data)) {
      $settings = domain_unserialize($data);
    }
    else {
      $variable_table = domain_get_primary_table('variable');
      $result = db_query("SELECT name, value FROM {$variable_table}");
      foreach ($result as $vars) {
        $data[$vars->name] = domain_unserialize($vars->value);
      }
      $settings = $data;
    }
  }

  // Do we reset the global or just return data?
  if ($unset) {
    global $conf;
    $conf = $settings;
    return;
  }
  return $settings;
}