? 785818-domain-batch.patch
? 793558-source-form.patch
? test.patch
Index: API.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/API.php,v
retrieving revision 1.51.2.4
diff -u -p -r1.51.2.4 API.php
--- API.php	2 Mar 2010 20:38:24 -0000	1.51.2.4
+++ API.php	9 May 2010 02:27:17 -0000
@@ -785,3 +785,32 @@ function hook_domain_settings($domain_id
     }
   }
 }
+
+/**
+ * Alter the validation step of a domain record.
+ *
+ * This hook allows modules to change or extend how domain validation
+ * happens. Most useful for international domains or other special cases
+ * where a site wants to restrict domain creation is some manner.
+ *
+ * NOTE: This does not apply to Domain Alias records.
+ *
+ * @param &$error_list
+ *   The list of current vaidation errors. Modify this value by reference.
+ *   If you return an empty array or NULL, the domain is considered valid.
+ * @param $subdomain
+ *   The HTTP_HOST string value being validated, such as one.example.com.
+ *   Note that this is checked for uniqueness separately. This value is not
+ *   modifiable.
+ * @return
+ *   No return value. Modify $error_list by reference. Return an empty array
+ *   or NULL to validate this domain.
+ *
+ * @see domain_valid_domain()
+ */
+function hook_domain_validate_alter(&$error_list, $subdomain) {
+  // Only allow TLDs to be .org for our site.
+  if (substr($subdomain, -4) != '.org') {
+    $error_list[] = t('Only .org domains may be registered.');
+  }
+}
Index: domain.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain.install,v
retrieving revision 1.25.2.1
diff -u -p -r1.25.2.1 domain.install
--- domain.install	27 Apr 2010 23:02:40 -0000	1.25.2.1
+++ domain.install	9 May 2010 02:27:19 -0000
@@ -223,3 +223,23 @@ function domain_update_6205() {
   $ret[] = update_sql("DELETE FROM {domain_editor} WHERE uid NOT IN (SELECT u.uid FROM {users} u)");
   return $ret;
 }
+
+/**
+ * Remove UPPERCASE from domain records.
+ *
+ * @link http://drupal.org/node/785818
+ */
+function domain_update_6206() {
+  $ret = array();
+  $result = db_query("SELECT domain_id, subdomain FROM {domain}");
+  while ($domain = db_fetch_array($result)) {
+    $string = drupal_strtolower($domain['subdomain']);
+    if ($string != $domain['subdomain']) {
+      db_query("UPDATE {domain} SET subdomain = '%s' WHERE domain_id = %d", $string, $domain['domain_id']);
+      if ($domain['domain_id'] == 0) {
+        variable_set('domain_root', $string);
+      }
+    }
+  }
+  return $ret;
+}
Index: domain.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain.module,v
retrieving revision 1.134.2.24
diff -u -p -r1.134.2.24 domain.module
--- domain.module	7 May 2010 18:31:35 -0000	1.134.2.24
+++ domain.module	9 May 2010 02:27:23 -0000
@@ -949,12 +949,15 @@ function domain_valid_domain($subdomain)
     $error_list[] = t('The domain must not end with a dot (.)');
   }
   // Check for valid characters
-  $pattern = '/^[a-z0-9\.\-:]*$/i';
+  $pattern = '/^[a-z0-9\.\-:]*$/';
   if (!preg_match($pattern, $subdomain)) {
-    $error_list[] = t('Only alphanumeric characters, dashes, and a colon are allowed.');
+    $error_list[] = t('Only lower-case alphanumeric characters, dashes, and a colon are allowed.');
   }
+  // Allow modules to alter this behavior.
+  drupal_alter('domain_validate', $error_list, $subdomain);
+  // Return the errors, if any.
   if (!empty($error_list)) {
-    return t('The domain string is invalid:') . theme('item_list', $error_list);
+    return t('The domain string is invalid for %subdomain:', array('%subdomain' => $subdomain)) . theme('item_list', $error_list);
   }
 }
 
@@ -2353,11 +2356,18 @@ function domain_batch_validate($values) 
   $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', t('Each domain value must be unique.'));
+          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;
@@ -2365,7 +2375,7 @@ function domain_batch_validate($values) 
       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.'));
+          form_set_error('domain_batch]['. $key, t('Each site name value must be unique.'));
         }
       }
       break;
@@ -2627,3 +2637,4 @@ function domain_db_rewrite_sql($query, $
   );
   return $return;
 }
+
