Browse Source

Fixed bug in matching of publication to title/year if year is missing

Stephen Ficklin 12 years ago
parent
commit
69ce3b1886
1 changed files with 12 additions and 6 deletions
  1. 12 6
      tripal_pub/api/tripal_pub.api.inc

+ 12 - 6
tripal_pub/api/tripal_pub.api.inc

@@ -308,11 +308,17 @@ function tripal_pub_add_publication($pub_details, $do_contact) {
   
    // check to see if the publication already exists
    $pub_id = 0;
-   $values = array(
-     'title' => $pub_details['Title'],
-     'pyear' => $pub_details['Year'],
-   );
-   $options = array('statement_name' => 'sel_pub_tipy');
+   $values = array();
+   $stmnt_suffix = '';
+   if ($pub_details['Title']) {
+     $values['title'] = $pub_details['Title'];
+     $stmnt_suffix .= 'ti';
+   }
+   if ($pub_details['Year']) {
+     $values['pyear'] = $pub_details['Year'];
+     $stmnt_suffix .= 'py';
+   }
+   $options = array('statement_name' => 'sel_pub_');
    $results = tripal_core_chado_select('pub', array('*'), $values, $options);
 
    if (count($results) == 1) {
@@ -476,4 +482,4 @@ function tripal_pub_add_authors($pub_id, $authors, $do_contact) {
     }
     $rank++;   
   }
-}
+}