You are here

function domain_batch_validate in Domain Access 5

Same name and namespace in other branches
  1. 6.2 domain.module \domain_batch_validate()
  2. 7.2 domain.module \domain_batch_validate()

Validate handler for hook_domainbatch()

1 string reference to 'domain_batch_validate'
domain_domainbatch in ./domain.module
Implement hook_domainbatch()

File

./domain.module, line 1411
Core module functions for the Domain Access suite.

Code

function domain_batch_validate($form_values) {
  $case = $form_values['variable'];
  $batch = $form_values['domain_batch'];
  switch ($case) {
    case 'domain_root':
      foreach ($batch as $key => $value) {
        $subdomain = strtolower(urlencode($value));
        $check = db_result(db_query("SELECT COUNT(domain_id) FROM {domain} WHERE subdomain = '%s' AND domain_id <> %d", $value, $key));
        if ($check > 0 || $key > 0 && $value == variable_get('domain_root', '')) {
          form_set_error('domain_batch', t('Each domain value must be unique.'));
        }
      }
      break;
    case 'domain_sitename':
      foreach ($batch as $key => $value) {
        $check = db_result(db_query("SELECT COUNT(domain_id) FROM {domain} WHERE sitename = '%s' AND domain_id <> %d", $value, $key));
        if ($check > 0 || $key > 0 && $value == variable_get('domain_sitename', 'Drupal')) {
          form_set_error('domain_batch', t('Each site name value must be unique.'));
        }
      }
      break;
  }

  #  exit;
}