You are here

function domain_conf_variable_save in Domain Access 7.2

Same name and namespace in other branches
  1. 6.2 domain_conf/domain_conf.module \domain_conf_variable_save()
  2. 7.3 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()

3 calls to domain_conf_variable_save()
domain_batch_form_submit in ./domain.admin.inc
FormsAPI for saving batch form actions.
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 785
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_query("SELECT settings FROM {domain_conf} WHERE domain_id = :domain_id", array(
    ':domain_id' => $domain_id,
  ))
    ->fetchField();

  // Settings found, update them.
  if ($serialized) {
    $settings = domain_unserialize($serialized);
    $settings[$variable] = $value;
    db_update('domain_conf')
      ->condition('domain_id', $domain_id)
      ->fields(array(
      'settings' => serialize($settings),
    ))
      ->execute();
  }
  elseif (domain_lookup($domain_id) != -1) {
    $settings = array(
      $variable => $value,
    );
    db_insert('domain_conf')
      ->fields(array(
      'domain_id' => $domain_id,
      'settings' => serialize($settings),
    ))
      ->execute();
  }
}