Index: biblio.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/biblio/biblio.admin.inc,v
retrieving revision 1.9.2.35
diff -u -p -r1.9.2.35 biblio.admin.inc
--- biblio.admin.inc	22 Dec 2008 22:19:01 -0000	1.9.2.35
+++ biblio.admin.inc	30 Dec 2008 00:53:01 -0000
@@ -1037,8 +1037,9 @@ function biblio_admin_author_types_form_
 }
 function biblio_admin_author_edit_form($form_state, $author_id){
   $author = db_fetch_object(db_query('SELECT * FROM {biblio_contributor_data} b WHERE b.cid = %d ', $author_id));
-  
-  $form['#redirect'] = 'biblio/authors';
+
+  $base = variable_get('biblio_base', 'biblio');
+  $form['#redirect'] = "$base/authors";
 
   $form['cid'] = array(
     '#type' => 'value',
Index: biblio.contributors.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/biblio/Attic/biblio.contributors.inc,v
retrieving revision 1.1.2.23
diff -u -p -r1.1.2.23 biblio.contributors.inc
--- biblio.contributors.inc	9 Dec 2008 22:21:51 -0000	1.1.2.23
+++ biblio.contributors.inc	30 Dec 2008 00:53:01 -0000
@@ -56,24 +56,58 @@ function biblio_load_contributors($vid, 
   }
   return $contributors;
 }
+
+function biblio_authors_add_etal (&$authors, $type) {
+  $etal = "et al";
+  foreach ($authors as $author) {
+    if ($author['auth_type'] == $type && $author['name'] == $etal) return false;
+  }
+  $authors[] = array('name' => $etal, 'auth_type' => $type, 'lastname' => $etal);
+  return true;
+}
 /**
+ * Parse initial contributor array and augment with additional info
+ * @param $contributors initial contributor array
+ * @return augmented contributor array
+ */
+function biblio_parse_contributors($contributors) {
+  $authors = array(); $etal = array();
+  foreach ($contributors as $author) {
+    $author['name'] = trim($author['name']); 
+    if (strlen($author['name'])) {
+      $count=0;
+      $author['name'] = preg_replace("/et\.?\s+al\.?/",'',$author['name'],-1,$count);
+      if ($count && $author['auth_type'] != 1) $etal[$author['auth_type']] = true;
+
+      biblio_parse_author($author);
+      $authors[] = (array) $author;
+    }
+  }
+  foreach ($etal as $type => $dummy) {
+    if (biblio_authors_add_etal ($authors, $type))
+      biblio_parse_author($authors[sizeof($authors)-1]);
+  }
+  return $authors;
+}
+/**
+ * Save $node->biblio_contributors to database
  * @param $node
  * @param $update
- * @return unknown_type
+ * @return success of database operations
  */
 function biblio_save_contributors($node, $update = FALSE) {
-  if (!empty ($node->biblio_contributors))
-  biblio_parse_save($node->biblio_contributors, $node->nid, $node->vid, $update);
+  if (empty ($node->biblio_contributors)) return true;
+  return _save_contributors($node->biblio_contributors, $node->nid, $node->vid, $update);
 }
 /**
+ * Save contributors to the database
  * @param $authors
  * @param $nid
  * @param $vid
  * @param $update
- * @return unknown_type
+ * @return success of database operations
  */
 function _save_contributors($authors, $nid, $vid, $update = FALSE) {
-
   $rank = 0;
   $md5 = _loadMD5();
   db_query('DELETE FROM {biblio_contributor} WHERE nid = %d AND vid = %d', array($nid, $vid));
@@ -82,7 +116,7 @@ function _save_contributors($authors, $n
     if (empty ($author['cid']) && !empty ($md5))
     $author['cid'] = array_search($author['md5'], $md5);
     if (empty ($author['cid'])) {
-      drupal_write_record('biblio_contributor_data', $author);
+      if (!drupal_write_record('biblio_contributor_data', $author)) return false;
       $cid = db_last_insert_id('biblio_contributor_data', 'cid');
     } else {
       $cid = $author['cid'];
@@ -95,28 +129,9 @@ function _save_contributors($authors, $n
       'rank' => $rank++,
       'auth_type' => $author['auth_type']
     );
-    drupal_write_record('biblio_contributor', $link_array);
+    if (!drupal_write_record('biblio_contributor', $link_array)) return false;
   }
-}
-/**
- * @param $authors_array
- * @param $nid
- * @param $vid
- * @param $update
- * @return unknown_type
- */
-function biblio_parse_save($authors_array, $nid, $vid, $update = FALSE) {
-  $authors = array();
-  foreach ($authors_array as $author) {
-    if (strlen(trim($author['name']))) {
-      //$author['type'] = $ctid;
-      biblio_parse_author($author);
-      $authors[] = (array) $author;
-    }
-  }
-  if (!empty ($authors))
-  _save_contributors($authors, $nid, $vid, $update);
-  return;
+  return true; // successfully saved all contributors
 }
 /*
  Released through http://bibliophile.sourceforge.net under the GPL licence.
@@ -156,8 +171,8 @@ function biblio_parse_author(& $author_a
   $value = trim($author_array['name']);
   $appellation = $prefix = $surname = $firstname = $initials = '';
   $prefix = "";
-  //		$prefix2= array();
-  $author = explode(",", preg_replace("/\s{2,}/", ' ', trim($value)));
+  $value = preg_replace("/\s{2,}/", ' ', $value); // replace multiple white space by single space
+  $author = explode(",", $value);
   $size = sizeof($author);
   // No commas therefore something like Mark Grimshaw, Mark Nicholas Grimshaw, M N Grimshaw, Mark N. Grimshaw
   if ($size == 1) {
@@ -227,12 +242,11 @@ function _grabFirstnameInitials($remaind
     } else if (preg_match("/[a-zA-Z]{2,}/", trim($value))){
       $firstnameArray[] = trim($value);
     } else {
-      $initialsArray[] = str_replace(".", " ", trim($value));
+      $initialsArray[] = trim(str_replace(".", " ", trim($value)));
     }
   }
   if (isset ($initialsArray)) {
-    foreach ($initialsArray as $initial)
-    $initials .= ' ' . trim($initial);
+    $initials = join(" ", $initialsArray);
   }
   if (isset ($firstnameArray)) {
     $firstname = join(" ", $firstnameArray);
Index: biblio.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/biblio/biblio.install,v
retrieving revision 1.30.2.64
diff -u -p -r1.30.2.64 biblio.install
--- biblio.install	23 Dec 2008 20:40:38 -0000	1.30.2.64
+++ biblio.install	30 Dec 2008 00:53:03 -0000
@@ -1702,21 +1702,23 @@ function _parse_authors(&$biblio_contrib
 function biblio_update_6004()
 {
   drupal_get_schema('biblio_contributor_data', TRUE);
-  // this update will move author information from existion biblio table to the new
+  // this update will move author information from existing biblio table to the new
   // biblio_contributor_data table and make the appropriate links in the biblio_contributor table
   require_once(drupal_get_path('module', 'biblio') . '/biblio.contributors.inc');
   $res = db_query("SELECT nid,vid,biblio_authors, biblio_secondary_authors,biblio_tertiary_authors,biblio_corp_author FROM {biblio}  ");
-  $count=0;
+  $count=0; $count_success=0;
   while ($biblio = db_fetch_array($res)) {
     $biblio_contributors = array();
     if (!empty($biblio['biblio_authors'])) _parse_authors($biblio_contributors, $biblio['biblio_authors'], 1);
     if (!empty($biblio['biblio_secondary_authors'])) _parse_authors($biblio_contributors, $biblio['biblio_secondary_authors'], 2);
     if (!empty($biblio['biblio_tertiary_authors'])) _parse_authors($biblio_contributors, $biblio['biblio_tertiary_authors'], 3);
     if (!empty($biblio['biblio_corp_author'])) _parse_authors($biblio_contributors, $biblio['biblio_corp_author'], 5);
-    biblio_parse_save($biblio_contributors, $biblio['nid'], $biblio['vid']);
+    $biblio_contributors = biblio_parse_contributors($biblio_contributors);
+    if (_save_contributors($biblio_contributors, $biblio['nid'], $biblio['vid'])) $count_success++;
     $count++;
   }
-  $result[] = array('success' => TRUE, 'query' => 'Moved authors from '.$count.'publications to the new database stucture');
+  $result[] = array('success' => ($count_success == $count), 
+  					'query' => 'Moved authors from '.$count_success.' / '.$count.' publications to the new database stucture');
 
   return $result;
 }
@@ -1770,6 +1772,7 @@ function biblio_update_6009() {
 }
 function biblio_update_6010() {
   $result = array();
+/*
   $result[] = update_sql("ALTER TABLE {biblio_contributor_type} DROP PRIMARY KEY, ADD PRIMARY KEY  USING BTREE(`type`, `tid`, `ctdid`)");
   $result[] = update_sql(" UPDATE {biblio_contributor} 
   												SET ct_id = (SELECT bct.ctdid
@@ -1792,7 +1795,9 @@ function biblio_update_6010() {
  														ADD PRIMARY KEY  USING BTREE(`auth_type`) ");
   $result[] = update_sql("ALTER TABLE {biblio_contributor_data} ADD COLUMN `drupal_uid` INTEGER UNSIGNED ");
   $result[] = update_sql("ALTER TABLE {biblio_duplicates} ADD COLUMN `type` INTEGER UNSIGNED NOT NULL DEFAULT 0 ");
+
   $result[] = update_sql("ALTER TABLE {biblio_duplicates} DROP PRIMARY KEY, ADD PRIMARY KEY  USING BTREE(`vid`, `did`)");
+*/
   $result[] = biblio_md5_generate();
   
   return $result;
Index: biblio.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/biblio/biblio.module,v
retrieving revision 1.123.2.80
diff -u -p -r1.123.2.80 biblio.module
--- biblio.module	23 Dec 2008 19:12:57 -0000	1.123.2.80
+++ biblio.module	30 Dec 2008 00:53:04 -0000
@@ -349,7 +349,7 @@ function biblio_link($type, $node = NULL
  * Implementation of hook_user().
  */
 function biblio_user($type, & $edit, & $user, $category = NULL) {
-  if ($type == 'form' && $category == 'account' ){ //&& variable_get('biblio_show_user_profile_form', '1')) {
+  if ($type == 'form' && $category == 'account' && variable_get('biblio_show_user_profile_form', '1')) {
     $form = array();
     include_once drupal_get_path('module', 'biblio') .'/biblio.admin.inc';
     _biblio_get_user_profile_form($form, $user);
@@ -476,7 +476,7 @@ function biblio_menu() {
       'type' => MENU_CALLBACK
       );
       
-     $items['user/%user/biblio'] = array(
+     $items["user/%user/$base"] = array(
     'title' => t('Publications'),
     'page callback' => 'biblio_get_user_pubs',
     'page arguments' => array(1, 'profile'),
@@ -753,15 +753,7 @@ function biblio_nodeapi(& $node, $op, $t
 
   }
 }
-function biblio_node_form_submit(& $node) {
-  if (!is_numeric($node->biblio_year)) {
-    if (drupal_strtoupper($node->biblio_year) == drupal_strtoupper(t("In Press"))) {
-      $node->biblio_year = 9998;
-    }
-    if (drupal_strtoupper($node->biblio_year) == drupal_strtoupper(t("Submitted"))) {
-      $node->biblio_year = 9999;
-    }
-  }
+function biblio_form_submit(&$form, &$form_state) {
 //  if (variable_get('biblio_keyword_freetagging', 0) && variable_get('biblio_freetagging_vocab', 0)) {
 //    $vid = variable_get('biblio_freetagging_vocab', 0);
 //    $node->taxonomy['tags'][$vid] .= $node->biblio_keywords;
@@ -800,26 +792,25 @@ function biblio_form_alter(& $form, $for
  * that will be later placed inside the form.
  */
 function biblio_form($node, $form_state) {
-  //  print_r($node);print_r($form_state);
-  $output = '';
-  $node_tid = $node->biblio_type;
-  $form_state_tid = $form_state['post']['biblio_type'] ? $form_state['post']['biblio_type'] : $form_state['values']['biblio_type'];
+  $tid = $form_state['post']['biblio_type'] ? $form_state['post']['biblio_type'] : $form_state['values']['biblio_type'];
+  if (empty($tid)) $tid = $node->biblio_type;
+
   $show_fields = FALSE;
-  $tid = FALSE;
-  $tid = (!empty($form_state_tid)) ? $form_state_tid : $node_tid;
-  if (!empty($node->nid) || $tid)
-  $show_fields = TRUE;
+  if (!empty($node->nid) || $tid) $show_fields = TRUE;
+
+  $form['#validate'][] = 'biblio_form_validate';
+  $form['#submit'][] = 'biblio_form_submit';
+  $form['#cache'] = TRUE;
+
+  /* publication type */
   $param['options'] = array(
     "enctype" => "multipart/form-data"
     );
-    $result = db_query('SELECT t.* FROM {biblio_types} as t WHERE tid > -2 AND visible = 1');
-    while ($option = db_fetch_object($result)) {
-      $options["$option->tid"] = $option->name;
-    }
-    $form['#validate'][] = 'biblio_form_validate';
-    //  $form['#submit'][] = 'biblio_form_submit';
-    $form['#cache'] = TRUE;
-    $form['biblio_type'] = array(
+  $result = db_query('SELECT t.* FROM {biblio_types} as t WHERE tid > -2 AND visible = 1');
+  while ($option = db_fetch_object($result)) {
+    $options["$option->tid"] = $option->name;
+  }
+  $form['biblio_type'] = array(
     '#type' => 'select',
     '#title' => t('Publication Type'),
     '#default_value' => $tid,
@@ -832,8 +823,8 @@ function biblio_form($node, $form_state)
     '#multiple' => false,
     '#required' => true
       );
-      if ($show_fields) {
-        $form['title'] = array(
+  if ($show_fields) {
+    $form['title'] = array(
       '#type' => 'textfield',
       '#title' => t('Title'),
       '#required' => TRUE,
@@ -842,15 +833,15 @@ function biblio_form($node, $form_state)
       '#maxlength' => 255,
       '#weight' => -4
         );
-        // Build the field array used to make the form
-        $result = db_query("SELECT * FROM {biblio_fields} b, {biblio_field_type} bt, {biblio_field_type_data} btd
-                        WHERE bt.fid=b.fid AND btd.ftdid=bt.ftdid
-                        AND bt.tid=$tid
-                        ORDER by bt.weight ASC ");
-        while ($row = db_fetch_array($result)) {
-          $fields[$row['name']] = $row;
-        }
-        $form['other_fields'] = array(
+    // Build the field array used to make the form
+    $result = db_query("SELECT * FROM biblio_fields b 
+    					INNER JOIN biblio_field_type bt ON b.fid = bt.fid 
+    					INNER JOIN biblio_field_type_data btd ON btd.ftdid=bt.ftdid 
+    					WHERE bt.tid=100 ORDER BY bt.weight ASC; ");
+    while ($row = db_fetch_array($result)) {
+      $fields[$row['name']] = $row;
+    }
+    $form['other_fields'] = array(
       '#type' => 'fieldset',
       '#collapsible' => TRUE,
       '#collapsed' => TRUE,
@@ -858,35 +849,16 @@ function biblio_form($node, $form_state)
       '#description' => '',
       '#weight' => 19.5
         );
-        foreach ($fields as $key => $fld) {
-          if ($fld['common'] || $fld['visible']) {
-            if ($fld['type'] == 'textarea') { /* wrap all textarea fields in collapsed field sets to save
-              * space on the page
-              */
-              $colapse_field = $fld['name'] .'_field';
-              $form[$colapse_field] = array(
-            '#type' => 'fieldset',
-            '#collapsible' => TRUE,
-            '#collapsed' => TRUE,
-            '#title' => $fld['title'],
-            '#description' => '',
-            '#weight' => $fld['weight'] / 10
-              );
-              $form[$colapse_field][$key] = array(
-            '#default_value' => $node->$key,
-            '#type' => $fld['type'],
-            '#title' => $fld['title'],
-            '#size' => $fld['size'],
-            '#required' => $fld['required'],
-            '#maxlength' => $fld['maxsize'],
-            '#weight' => $fld['weight'] / 10,
-            '#autocomplete_path' => ($fld['autocomplete']) ? 'biblio/autocomplete/'. $fld['name'] : '',
-            '#description' => $fld['hint']
-              );
-            }
-            elseif ($fld['type'] == 'textfield') { // this is a regular textfield
-              $form[$key] = array(
-            '#default_value' => $node->$key,
+    foreach ($fields as $key => $fld) {
+      $main_area = $fld['common'] || $fld['visible'];
+      if ($fld['type'] == 'contrib_widget') {
+        if ($main_area)
+          _biblio_contributor_widget($form, $node, $fld, $tid);
+        else
+          _biblio_contributor_widget($form['other_fields'], $node, $fld, $tid,TRUE);
+      } else {
+        $field_widget = array(
+            '#default_value' => $node-> $key,
             '#type' => $fld['type'],
             '#title' => $fld['title'],
             '#size' => $fld['size'],
@@ -896,61 +868,38 @@ function biblio_form($node, $form_state)
             '#autocomplete_path' => ($fld['autocomplete']) ? 'biblio/autocomplete/'. $fld['name'] : '',
             '#description' => $fld['hint']
               );
-            }
-            elseif ($fld['type'] == 'contrib_widget') {
-              _biblio_contributor_widget($form, $node, $fld, $form_state_tid);
-            }
-          }
-          else { /* add remaining which have not been specifcally associated with
-            * this type to the "Other Biblio Fields" fieldset
-            */
-            if ($fld['type'] == 'contrib_widget') {
-              _biblio_contributor_widget($form['other_fields'], $node, $fld, $form_state_tid,TRUE);
-            }
-            else {
-              $form['other_fields'][$key] = array(
-            '#default_value' => $node-> $key,
-            '#type' => $fld['type'],
+        if ($key == 'biblio_year') $field_widget['#maxlength'] = 9;
+        
+        if ($main_area && $fld['type'] == 'textarea') { 
+          /* wrap all textarea fields in collapsed field sets to save space on the page */
+          $field_widget = array(
+            '#type' => 'fieldset',
+            '#collapsible' => TRUE,
+            '#collapsed' => TRUE,
             '#title' => $fld['title'],
-            '#size' => $fld['size'],
-            '#required' => $fld['required'],
-            '#maxlength' => $fld['maxsize'],
+            '#description' => '',
             '#weight' => $fld['weight'] / 10,
-            '#autocomplete_path' => ($fld['autocomplete']) ? 'biblio/autocomplete/'. $fld['name'] : '',
-            '#description' => $fld['hint']
+            $key => $field_widget
               );
-            }
-          }
-        }
-        if (isset($form_state['contributor_count'])) {
-          $contributor_count = $form_state['contributor_count'];
+          $key = $fld['name'] .'_field';
         }
-        else {
-          $contributor_count = max(4, empty($node->contributors) ? 2 : count($node->contributors));
-        }
-        $form['body_field'] = array(
-      '#type' => 'fieldset',
-      '#collapsible' => TRUE,
-      '#collapsed' => TRUE,
-      '#title' => t('Full Text'),
-      '#description' => '',
-      '#weight' => 19
-        );
-        $form['body_field']['body'] = array(
-      '#type' => 'textarea',
-      '#title' => t('Full Text'),
-      '#default_value' => $node->body,
-      '#rows' => 10,
-      '#required' => FALSE,
-      '#description' => t('You may enter a full text or HTML version of the publication here.'),
-      '#weight' => 19
-        );
-        $form['format'] = filter_form($node->format, 20);
+        if ($main_area) $form[$key] = $field_widget;
+        else $form['other_fields'][$key] = $field_widget;
       }
-      return $form;
+    }
+    if (isset($form_state['contributor_count'])) {
+      $contributor_count = $form_state['contributor_count'];
+    }
+    else {
+      $contributor_count = max(4, empty($node->contributors) ? 2 : count($node->contributors));
+    }
+    $form['body_field']['#title'] = t('Full Text');
+    $form['body_field']['body']['#title'] = t('Full Text');
+    $form['body_field']['body']['#description'] = t('You may enter a full text or HTML version of the publication here.');
+    // $form['format'] = filter_form($node->format, 20);
+  }
+  return $form;
 }
-// $biblio_type must be passed when we authors are not visible and we got $form['other_fields']
-// passed as $form, because we don't have $form['biblio_type'] available then.
 
 /**
  * @param $form
@@ -1131,7 +1080,6 @@ function biblio_contributors_js($fld_nam
  * Errors should be signaled with form_set_error().
  */
 function biblio_form_validate($form, & $form_state) {
-  //print_r($form_state);
   if ($form_state['storage'] == $form_state['values']['biblio_type'] || (!empty($form['#node']->biblio_type) && $form['#node']->biblio_type == $form_state['values']['biblio_type'])) {
     $form_state['storage'] = "";
     $form_state['rebuild'] = false;
@@ -1141,43 +1089,59 @@ function biblio_form_validate($form, & $
     $form_state['rebuild'] = true;
     return;
   }
-  if ($form_state['values']['biblio_type'] == 0) {
-    form_set_error('biblio_type', t('You must select the type of publication'));
-    return;
-  }
-  if (!isset($form_state['values']['biblio_year'])) {
-    form_set_error('biblio_year', t('You must supply the year of publication'));
-  }
   $today = getdate();
-  if (!is_numeric($form_state['values']['biblio_year']) && $form_state['values']['biblio_year'] != t("In Press") && $form_state['values']['biblio_year'] != t("Submitted")) {
+  if (!is_numeric(_biblio_numeric_year($form_state['values']['biblio_year']))) {
     form_set_error('biblio_year', t('Year of Publication must be a number between 1 and @thisyear or the words "In Press" or "Submitted" ', array(
       '@thisyear' => $today['year'] + 1
     )));
   }
-  /*  if (!$node->biblio_secondary_title) {
-   form_set_error('biblio_secondary_title', t('You must supply the Journal Title, Conference Name or Book Title'));
-   }
-   */
+}
+function _biblio_numeric_year ($year) {
+  if (!is_numeric($year)) {
+    if (drupal_strtoupper($year) == drupal_strtoupper(t("In Press")))  return 9998;
+    if (drupal_strtoupper($year) == drupal_strtoupper(t("Submitted"))) return 9999;
+  } else return $year;
+}
+function _biblio_text_year ($year) {
+  if ($year == 9998) return t("In Press");
+  if ($year == 9999) return t("Submitted");
+  return $year;
 }
 /**
- * Implementation of hook_insert().
- *
- * As a new node is being inserted into the database, we need to do our own
- * database inserts.
+ * Prepare a node for submit to database. Contains code common to insert and update.
+ * 
+ * @param $node
+ * @return none
  */
-function biblio_insert($node) {
+function _biblio_prepare_submit($node) {
   require_once(drupal_get_path('module', 'biblio') .'/biblio.contributors.inc');
-  //$node->biblio_coins = biblio_coins($node);
+  $node->biblio_contributors = biblio_parse_contributors($node->biblio_contributors);
+  
+  $node->biblio_year = _biblio_numeric_year ($node->biblio_year);
+  
+  $node->biblio_coins = biblio_coins($node);
   if (variable_get('biblio_auto_citekey', 1) && empty($node->biblio_citekey))
-  $node->biblio_citekey = biblio_citekey_generate($node);
+    $node->biblio_citekey = biblio_citekey_generate($node);
+
   $duplicate = biblio_hash($node);
-  if (isset ($duplicate)) { // if this is a potential duplcate, write the nids of the pre-existing and new nodes
+  if (isset ($duplicate) && $duplicate != $node->nid) { 
+    // write the nids of the pre-existing and new nodes into duplicates database
     $dup_map = array (
             'vid' => $duplicate,
             'did' => $node->nid
     );
     drupal_write_record('biblio_duplicates', $dup_map);
   }
+  
+}
+/**
+ * Implementation of hook_insert().
+ *
+ * As a new node is being inserted into the database, we need to do our own
+ * database inserts.
+ */
+function biblio_insert($node) {
+  _biblio_prepare_submit($node);
   drupal_write_record('biblio', $node);
   biblio_save_contributors($node);
 }
@@ -1188,26 +1152,14 @@ function biblio_insert($node) {
  * database updates.
  */
 function biblio_update($node) {
-  require_once(drupal_get_path('module', 'biblio') .'/biblio.contributors.inc');
-  $node->biblio_coins = biblio_coins($node);
-  $duplicate = biblio_hash($node);
-  if (!is_numeric($node->biblio_year)) {
-    if (drupal_strtoupper($node->biblio_year) == drupal_strtoupper(t("In Press"))) {
-      $node->biblio_year = 9998;
-    }
-    if (drupal_strtoupper($node->biblio_year) == drupal_strtoupper(t("Submitted"))) {
-      $node->biblio_year = 9999;
-    }
-  }
+  _biblio_prepare_submit($node);
   // Update the node in the database:
-  //print_r($node);die;
   if ($node->revision) {
     drupal_write_record('biblio', $node);
   }
   else {
     drupal_write_record('biblio', $node, 'vid');
   }
-
   biblio_save_contributors($node, TRUE);
 }
 /**
@@ -1238,15 +1190,11 @@ function biblio_load($node) {
                                          FROM {biblio} b
                                          LEFT JOIN {biblio_types} bt on b.biblio_type = bt.tid
                                          WHERE b.vid = %d', $node->vid));
-//  if ($additions->biblio_year == 9998) {
-//    $additions->biblio_year = t("In Press");
-//  }
-//  if ($additions->biblio_year == 9999) {
-//    $additions->biblio_year = t("Submitted");
-//  }
+  $additions->biblio_year = _biblio_text_year($additions->biblio_year);
   $additions->biblio_contributors = biblio_load_contributors($node->vid, $additions->biblio_type);
   return $additions;
 }
+/*
 function biblio_citekey_generate($node) {
   $prefix          = variable_get('biblio_citekey_prefix', '');
   $primary_field   = variable_get('biblio_citekey_field1', 'nid');
@@ -1254,6 +1202,35 @@ function biblio_citekey_generate($node) 
   $citekey = (!empty($node-> $primary_field)) ? $node-> $primary_field : (!empty($node-> $secondary_field)) ? $node-> $secondary_field : $node->nid;
   return $prefix . $citekey;
 }
+*/
+function biblio_citekey_generate($node) {
+  $citekey = ""; $num=0;
+  foreach ($node->biblio_contributors as $author) {
+    if ($author['auth_type'] == 1 && strlen(trim($author['name']))) {
+      if ($num == 3) {
+        $citekey .= "EtAl";
+        break;
+      }  
+      $citekey .= ucfirst(strtolower($author['lastname']));
+      $num++;
+    }
+  }
+
+  // year
+  $citekey .= $node->biblio_year . "-";
+   
+  // characters of first three words
+  $num=0;
+  foreach(explode(" ", $node->title) as $w) {
+    if (strlen($w) > 3) {
+      $citekey .= strtoupper(substr($w,0,1));
+      $num++;
+      if ($num == 3) break;
+    }
+  }
+  return $citekey;
+}
+
 /**
  * Implementation of hook_view().
  *
Index: biblio.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/biblio/Attic/biblio.pages.inc,v
retrieving revision 1.1.2.42
diff -u -p -r1.1.2.42 biblio.pages.inc
--- biblio.pages.inc	23 Dec 2008 19:14:02 -0000	1.1.2.42
+++ biblio.pages.inc	30 Dec 2008 00:53:04 -0000
@@ -882,7 +882,6 @@ function biblio_citekey_view() {
  */
 function _biblio_author_link($author, $aid, $base='biblio', $inline = FALSE) {
   $options = array();
-  $inline = $inline ? "/inline" : "";
 
   if (isset($_GET['sort'])) {
     $options['query']  .= "sort=" . $_GET['sort'];
@@ -892,7 +891,7 @@ function _biblio_author_link($author, $a
     $options['query']   .= "order=" . $_GET['order'];
   }
 
-  $html = l(trim($author), "$base/author/$aid".$inline,$options );
+  $html = l(trim($author), "$base/author/$aid",$options );
 
   return $html;
 }
