You are here

function domain_batch_validate in Domain Access 6.2

Same name and namespace in other branches
  1. 5 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 2548
Core module functions for the Domain Access suite.

Code

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