_domain_conf_load_primary

Versions
domain
_domain_conf_load_primary($unset = FALSE)

Load the variables from the primary domain.

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

See also

domain_set_domain()

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.

Code

domain_conf/domain_conf.module, line 684

<?php
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_result(db_query("SELECT data FROM $cache_table WHERE cid = 'variables'"));
    if (!empty($data)) {
      $settings = domain_unserialize($data);
    }
    // If the cache has been cleared, this data will be empty.
    // In this case, grab the data directly from the base {variable} table.
    else {
      $variable_table = domain_get_primary_table('variable');
      $result = db_query("SELECT name, value FROM $variable_table");
      while ($vars = db_fetch_array($result)) {
        $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;
}
?>

Contact

  • agentrickard [at] gmail [dot] com

Donations

My Amazon.com Wish List