You are here

function domain_conf_variable_save in Domain Access 6.2

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

Store a single variable in {domain_conf}.

@link http://drupal.org/node/367963

Parameters

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

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

$value: The value of the variable to set. You may leave this value blank in order to unset the custom variable.

See also

domain_conf_variable_set()

2 calls to domain_conf_variable_save()
domain_conf_variable_set in domain_conf/domain_conf.module
Change the variable setting for a domain. This function is called by external modules that wish to alter Domain Conf settings.
domain_settings_form_submit in domain_settings/domain_settings.module
Submit handler for domain-specific settings.

File

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

Code

function domain_conf_variable_save($domain_id, $variable, $value = NULL) {

  // Get the current settings for this domain, if any.
  $serialized = db_result(db_query("SELECT settings FROM {domain_conf} WHERE domain_id = %d", $domain_id));

  // Settings found, update them.
  if ($serialized) {
    $settings = domain_unserialize($serialized);
    $settings[$variable] = $value;
    db_query("UPDATE {domain_conf} SET settings = %b WHERE domain_id = %d", serialize($settings), $domain_id);
  }
  else {
    if (domain_lookup($domain_id) != -1) {
      $settings = array(
        $variable => $value,
      );
      db_query("INSERT INTO {domain_conf} (domain_id, settings) VALUES (%d, %b)", $domain_id, serialize($settings));
    }
  }
}