You are here

function domain_conf_variable_get in Domain Access 7.2

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

Load a variable specific to a domain.

Parameters

$domain_id: The unique domain ID that is being edited.

$variable: The name of the variable you wish to get.

$all: A boolean flag indicating whether to return the entire variable array.

$reset: A boolean flag to reset the static variable array for the domain. Useful if you are changing variables during a page request.

Return value

The value of the variable for that domain, or NULL if not set, or an array of variables, in the case of $all.

File

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

Code

function domain_conf_variable_get($domain_id, $variable = '', $all = FALSE, $reset = FALSE) {
  global $_domain;
  static $settings, $base;
  if (empty($base)) {
    $base = _domain_conf_load_primary(FALSE);
  }
  if (!isset($settings[$domain_id]) || $reset) {

    // Get the current settings for this domain, if any.
    $data = domain_unserialize(db_query("SELECT settings FROM {domain_conf} WHERE domain_id = :domain_id", array(
      ':domain_id' => $domain_id,
    ))
      ->fetchField());
    if (empty($data)) {
      $data = array();
    }
    $settings[$domain_id] = array_merge($base, $data);
  }
  if ($all) {
    return $settings[$domain_id];
  }
  if (isset($settings[$domain_id][$variable])) {
    return $settings[$domain_id][$variable];
  }
  return NULL;
}