domain_batch_validate

Versions
6 – 7
domain_batch_validate($values)

Validate handler for hook_domainbatch()

Code

contrib-6/domain/domain.module, line 2374

<?php
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 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]['. $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 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]['. $key, t('Each site name value must be unique.'));
        }
      }
      break;
  }
}
?>

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options