--- modules/taxonomy/taxonomy.module	2009-03-22 18:42:25.000000000 -0400
+++ modules/taxonomy/taxonomyNew.module	2009-03-22 18:27:04.000000000 -0400
@@ -952,17 +952,32 @@ function taxonomy_term_count_nodes($tid,
  *
  * @param name
  *   Name of the term to search for.
+ * 
+ * @param vid
+ * 	an array of vocabulary ids or a vocabulary id
  *
  * @return
  *   An array of matching term objects.
  */
-function taxonomy_get_term_by_name($name) {
-  $db_result = db_query(db_rewrite_sql("SELECT t.tid, t.* FROM {taxonomy_term_data} t WHERE LOWER(t.name) = LOWER('%s')", 't', 'tid'), trim($name));
+function taxonomy_get_term_by_name($name, $vid = NULL) {
+  $sql = NULL;
+  $args[] = $name;
+  // multiple vocabularies to select from?
+  if (is_array($vid)) {
+	   $placeholders = array_fill(0, count($vid), '?');
+    $sql = ' AND t.vid IN (' . implode(', ', $placeholders) . ') ';
+    $args = array_merge($args, $vid);
+  }
+  // single vocabulary to select from?
+  if (is_int($vid)) {
+    $sql = ' AND t.vid = ?';
+    $args[] = $vid;
+  }
+  $db_result = db_query(db_rewrite_sql("SELECT t.tid, t.* FROM {taxonomy_term_data} t WHERE LOWER(t.name) = LOWER(?)" . $sql, 't', 'tid'), $args);
   $result = array();
   while ($term = db_fetch_object($db_result)) {
     $result[] = $term;
   }
-
   return $result;
 }
 
