Browse Source

Small Bug Fix to properties/dbxrefs/relationships API so that there is no error is no elements get added

Lacey Sanderson 11 năm trước cách đây
mục cha
commit
beb7dc17f9

+ 8 - 5
tripal_core/api/tripal_core.database_references.api.inc

@@ -530,11 +530,14 @@ function theme_tripal_core_additional_dbxrefs_form_table($variables) {
  */
 function tripal_core_additional_dbxrefs_form_retreive($node) {
   $dbxrefs = array();
-  foreach ($node->dbxref_table as $db_id => $elements) {
-    if ($db_id != 'new') {
-      foreach ($elements as $version => $dbxref) {
-        $dbxref_id = (!empty($dbxref['dbxref_id'])) ? $dbxref['dbxref_id'] : 'NONE';
-        $dbxrefs[$db_id][$version][$dbxref_id] = $dbxref['accession'];
+
+  if (isset($node->dbxref_table)) {
+    foreach ($node->dbxref_table as $db_id => $elements) {
+      if ($db_id != 'new') {
+        foreach ($elements as $version => $dbxref) {
+          $dbxref_id = (!empty($dbxref['dbxref_id'])) ? $dbxref['dbxref_id'] : 'NONE';
+          $dbxrefs[$db_id][$version][$dbxref_id] = $dbxref['accession'];
+        }
       }
     }
   }

+ 7 - 4
tripal_core/api/tripal_core.properties.api.inc

@@ -913,10 +913,13 @@ function theme_chado_node_properties_form_table($variables) {
  */
 function chado_node_properties_form_retreive($node) {
   $properties = array();
-  foreach ($node->property_table as $type_id => $elements) {
-    if ($type_id != 'new' AND $type_id != 'details') {
-      foreach ($elements as $rank => $element) {
-        $properties[$type_id][$rank] = $element['prop_value'];
+
+  if (isset($node->property_table)) {
+    foreach ($node->property_table as $type_id => $elements) {
+      if ($type_id != 'new' AND $type_id != 'details') {
+        foreach ($elements as $rank => $element) {
+          $properties[$type_id][$rank] = $element['prop_value'];
+        }
       }
     }
   }

+ 8 - 5
tripal_core/api/tripal_core.relationships.api.inc

@@ -668,11 +668,14 @@ function theme_tripal_core_relationships_form_table($variables) {
  */
 function tripal_core_relationships_form_retreive($node) {
   $rels = array();
-  foreach ($node->rel_table as $type_id => $elements) {
-    if ($type_id != 'new') {
-      foreach ($elements as $rank => $relationships) {
-        $rels[$type_id][$rank]['subject_id'] = $relationships['subject_id'];
-        $rels[$type_id][$rank]['object_id'] = $relationships['object_id'];
+
+  if (isset($node->rel_table)) {
+    foreach ($node->rel_table as $type_id => $elements) {
+      if ($type_id != 'new') {
+        foreach ($elements as $rank => $relationships) {
+          $rels[$type_id][$rank]['subject_id'] = $relationships['subject_id'];
+          $rels[$type_id][$rank]['object_id'] = $relationships['object_id'];
+        }
       }
     }
   }