--- C:\server\tac_lite.module	Sun Apr 02 22:07:06 2006
+++ C:\server\tac_lite_new.module	Fri Apr 28 12:54:55 2006
@@ -262,15 +262,63 @@
 */
 function _tac_lite_get_terms(&$node) {
   $tids = array();
+  
   // emulating code from taxonomy_node_save here.
   // note that free tagging vocabs not currently supported
   if (count($node->taxonomy)) {
 	foreach ($node->taxonomy as $term) {
 	  if (is_array($term)) {
 		foreach ($term as $tid) {
-		  if ($tid) {
+		  if (is_numeric($tid)) {
 			$tids[$tid] = $tid;
 		  }
+		  else {
+// Myriad's magic fix
+// gotta insert the free tag first, then add each new tid as tac_lite expects
+// copied almost exactly from taxonomy.module
+		  // Free tagging vocabularies do not send their tids in the form,
+		  // so we'll detect them here and process them independently.
+		 
+		    $typed_input[0] = $tid; // foreach expects an array
+		    
+		
+		    foreach ($typed_input as $vid => $vid_value) {
+		      // This regexp allows the following types of user input:
+		      // this, "somecmpany, llc", "and ""this"" w,o.rks", foo bar
+		      $regexp = '%(?:^|,\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^",]*))%x';
+		      preg_match_all($regexp, $vid_value, $matches);
+		      $typed_terms = $matches[1];
+		
+		      foreach ($typed_terms as $typed_term) {
+		        // If a user has escaped a term (to demonstrate that it is a group,
+		        // or includes a comma or quote character), we remove the escape
+		        // formatting so to save the term into the DB as the user intends.
+		        $typed_term = str_replace('""', '"', preg_replace('/^"(.*)"$/', '\1', $typed_term));
+		        $typed_term = trim($typed_term);
+		        if ($typed_term == "") { continue; }
+		
+		        // See if the term exists in the chosen vocabulary
+		        // and return the tid, otherwise, add a new record.
+		        $possibilities = taxonomy_get_term_by_name($typed_term);
+		        $typed_term_tid = NULL; // tid match if any.
+		        foreach ($possibilities as $possibility) {
+		          if ($possibility->vid == $vid) {
+		            $typed_term_tid = $possibility->tid;
+		            $tids[$typed_term_tid] = $typed_term_tid; // add the numeric tid to the tac_lite array
+		          }
+		        }
+		
+		        if (!$typed_term_tid) {
+		          $edit = array('vid' => $vid, 'name' => $typed_term);
+		          $status = taxonomy_save_term($edit); // saves the free tags and modifies the $edit['tid'] directly from inside
+		          $typed_term_tid = $edit['tid'];
+		          $tids[$typed_term_tid] = $typed_term_tid; // add the numeric tid to the tac_lite array
+		        }
+		
+		       // db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $typed_term_tid);
+		      }
+		    }
+		  }
 		}
 	  }
 	  else {
@@ -280,6 +328,8 @@
 	}
   }
 
+
+// end taxonomy.module
   return $tids;
 }
 
