You are here

function domain_settings_reset in Domain Access 6.2

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

Erase Domain Conf and Batch settings but keep those set by this module.

Parameters

$domain_id: The domain_id to reset.

2 calls to domain_settings_reset()
domain_settings_batch_form_submit in domain_settings/domain_settings.module
Submit handler for batch domain settings.
domain_settings_reset_form_submit in domain_settings/domain_settings.module
Form submit handler to batch reset custom settings.

File

domain_settings/domain_settings.module, line 377
Allows domain-specific use of Drupal system settings forms.

Code

function domain_settings_reset($domain_id) {

  // Get the conf elements and erase them from the record.
  $batch = module_invoke_all('domainbatch');
  $conf = module_invoke_all('domainconf');
  $list = array_merge(array_keys($batch), array_keys($conf));

  // Get the existing data.
  $data = db_fetch_array(db_query("SELECT settings FROM {domain_conf} WHERE domain_id = %d", $domain_id));
  if (empty($data)) {
    return;
  }

  // Erase the settings by key.
  $settings = domain_unserialize($data['settings']);
  foreach ($list as $item) {
    if (isset($settings[$item])) {
      unset($settings[$item]);
    }
  }

  // Write the update.
  $sql = "UPDATE {domain_conf} SET settings = %b WHERE domain_id = %d";
  db_query($sql, serialize($settings), $domain_id);
}