You are here

function domain_settings_reset in Domain Access 7.2

Same name and namespace in other branches
  1. 6.2 domain_settings/domain_settings.module \domain_settings_reset()
  2. 7.3 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 364
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.
  $result = db_query("SELECT domain_id, settings FROM {domain_conf} WHERE domain_id = :domain_id", array(
    ':domain_id' => $domain_id,
  ))
    ->fetchObject();
  if (!empty($result->settings)) {
    return;
  }

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

  // Write the update.
  db_update('domain_conf')
    ->fields(array(
    'settings' => serialize($settings),
  ))
    ->condition('domain_id', $result->domain_id)
    ->execute();
}