Explorar el Código

Fixed bug in automatic citation generation

spficklin hace 11 años
padre
commit
148362fb34
Se han modificado 2 ficheros con 8 adiciones y 7 borrados
  1. 4 3
      tripal_pub/includes/pub_form.inc
  2. 4 4
      tripal_pub/tripal_pub.module

+ 4 - 3
tripal_pub/includes/pub_form.inc

@@ -200,6 +200,7 @@ function chado_pub_validate($node, &$form) {
   $pub_id       = $node->pub_id;
   $num_properties = $node->num_properties;
   $num_new = $node->num_new;
+  dpm($node);
   
   $pub = array();
 
@@ -241,15 +242,15 @@ function chado_pub_validate($node, &$form) {
       $pub[$prop_type->name] = $value;
     }
     // if this is a new property (added by this submit of the form)
-    elseif ($element = 'new_id') {
+    elseif ($element == 'new_id') {    	 
       $prop_type = tripal_cv_get_cvterm_by_id($value);
       if($prop_type->name == 'Conference Name' or $prop_type->name == 'Journal Name') {
         $series_name = $node->new_value;
       }
       if($prop_type->name == 'Citation') {
-        $uniquename = $value;
+        $uniquename = $node->new_value;
       }
-      $pub[$prop_type->name] = $value;
+      $pub[$prop_type->name] = $node->new_value;
     }
   }
   // if the citation is missing then try to generate one

+ 4 - 4
tripal_pub/tripal_pub.module

@@ -381,12 +381,13 @@ function chado_pub_insert($node) {
 
     // iterate through all of the properties and remove those that really are
     // part of the pub table fields
-    foreach ($properties as $name => $element) {
+    foreach ($properties as $name => $element) {    	    
+      $value = trim($element[0]);
+      
     	// populate our $pub_array for building a citation
     	$pub_arr[$name] = $value;
     	
-    	// remove properties that are stored in the pub table
-      $value = trim($element[0]);
+      // remove properties that are stored in the pub table
       if ($name == "Volume") {
         $volume = $value;
         unset($properties[$name]);
@@ -421,7 +422,6 @@ function chado_pub_insert($node) {
         $cross_refs[] = $value;
       }
     }
-    
     // generate a citation for this pub if one doesn't already exist 
     if (!$node->uniquename and array_key_exists('Citation', $properties)) {
     	$pub_type = tripal_cv_get_cvterm_by_id($node->type_id);