--- taxonomy.admin.inc.orig	2008-02-08 03:46:57.000000000 +0700
+++ taxonomy.admin.inc	2008-03-31 06:19:13.000000000 +0700
@@ -532,6 +532,30 @@ function taxonomy_overview_terms_submit(
 }
 
 /**
+ * Validation handler for the terms overview form. Ensure the lack of term
+ * duplications
+ *
+ * @see taxonomy_overview_terms()
+ */
+function taxonomy_overview_terms_validate($form, &$form_state) {
+  if ($form_state['clicked_button']['#value'] == t('Reset to alphabetical')) {
+    return;
+  }
+
+  foreach ($form_state['values'] as $tid => $values) {
+    if (isset($form[$tid]['#term'])) {
+      $term = $form[$tid]['#term'];
+      if ($values['parent'] != $term['parent']) {
+        if (db_result(db_query("SELECT COUNT(t.tid) FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE t.name = '%s' AND h.parent = '%d' AND t.tid != '%d'", $term['name'], $values['parent'], $term['tid'])) > 0) {
+          drupal_set_message('Changes made in this table will not be saved until the form is submitted without errors.', 'warning', FALSE);
+          form_set_error($tid, t('Cannot move term %term to the given location to prevent duplication.', array('%term' => $term['name'])));
+        }      
+      }      
+    }
+  }
+}
+
+/**
  * Theme the terms overview as a sortable list of terms.
  *
  * @ingroup themeable
@@ -730,7 +754,8 @@ function taxonomy_form_term(&$form_state
 }
 
 /**
- * Validation handler for the term edit form. Ensure numeric weight values.
+ * Validation handler for the term edit form. Ensure numeric weight values and lack
+ * of term duplication
  *
  * @see taxonomy_form_term()
  */
@@ -738,6 +763,24 @@ function taxonomy_form_term_validate($fo
   if (isset($form_state['values']['weight']) && !is_numeric($form_state['values']['weight'])) {
     form_set_error('weight', t('Weight value must be numeric.'));
   }
+
+  if ($form_state['clicked_button']['#value'] == t('Delete')) {
+    return;
+  }
+  
+  $parent = empty($form_state['values']['parent']) ? array(0) : $form_state['values']['parent'];
+  $args = array_merge(array($form_state['values']['name']), array_values($parent));
+  if (!empty($form_state['values']['tid'])) {
+    array_push($args, $form_state['values']['tid']);
+    if (db_result(db_query("SELECT COUNT(t.tid) FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE t.name = '%s' AND h.parent IN (".db_placeholders($parent).") AND t.tid != '%d'", $args)) > 0) {
+      form_set_error('name', t('A term with the same name and the same parent already exists.'));
+    }
+  }
+  else {
+    if (db_result(db_query("SELECT COUNT(t.tid) FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE t.name = '%s' AND h.parent IN (".db_placeholders($parent).")", $args)) > 0) {
+      form_set_error('name', t('A term with the same name and the same parent already exists.'));
+    }
+  }
 }
 
 /**
