--- PARSEENTRIES.php.orig	2008-12-01 09:44:24.000000000 +0100
+++ PARSEENTRIES.php	2008-12-01 10:11:12.000000000 +0100
@@ -605,22 +605,46 @@
           $node_array[$node_id]['biblio_type'] = 124;
           break;
       }
+      // Get the ct_id for the "type=1/type=2" authors. We assume
+      // that type 1 authors are the normal authors and use type 2
+      // for editors if no dedicated editor types are set.
+      if (!empty($entry['author']) || !empty($entry['editor'])){
+        $auth_ctid_query = db_query('
+                        SELECT ct_id
+                        FROM {biblio_contributor_type}
+                        WHERE tid = %d and type in (1,2)
+                        ORDER BY type', 
+                        $node_array[$node_id]['biblio_type']);
+        $auth_ctid = db_result($auth_ctid_query);
+      }
       if (!empty($entry['author'])){
         // split on ' and '
         $authorArray = preg_split("/\s(and|&)\s/i", trim($entry['author']));
         foreach ($authorArray as $key => $author)
         {
-          $node_array[$node_id]['biblio_contributors'][]= array('name' => $author, 'type' => 1);
+          $node_array[$node_id]['biblio_contributors'][]= array('name' => $author, 'type' => 1, 'ct_id' => $auth_ctid);
         }
       }
 
       if (!empty($entry['bibtexCitation'])) $node_array[$node_id]['biblio_citekey'] = $entry['bibtexCitation'];
       if (!empty($entry['editor']))
       {
+        // Search for the first author type which is an editor (10 or 14).
+        $editor_result = db_fetch_array(db_query_range('
+                    SELECT ct_id, type
+                    FROM {biblio_contributor_type}
+                    WHERE tid = %d and ctdid in (10,14)
+                    ORDER by type', 
+                    array($node_array[$node_id]['biblio_type']), 0, 1));
+        // If we have no editor type, store them as normal authors
+        if (!$editor_result) {
+          $editor_ctid = db_result($auth_ctid_query);
+          $editor_result = array ('ct_id' => $editor_ctid, 'type' => 2);
+        }
         $authorArray = preg_split("/\s(and|&)\s/i", trim($entry['editor']));
         foreach ($authorArray as $key => $author)
         {
-          $node_array[$node_id]['biblio_contributors'][]= array('name' => $author, 'type' => 2);
+          $node_array[$node_id]['biblio_contributors'][]= array('name' => $author, 'type' => $editor_result['type'], 'ct_id' => $editor_result['ct_id']);
         }
       }
 
