Browse Source

Project: Fixed bug restricting project relationships to 1 of each type

Lacey Sanderson 11 years ago
parent
commit
93cc0d4349
1 changed files with 16 additions and 20 deletions
  1. 16 20
      tripal_project/theme/tripal_project.theme.inc

+ 16 - 20
tripal_project/theme/tripal_project.theme.inc

@@ -6,11 +6,11 @@
  */
 function tripal_project_preprocess_tripal_project_relationships(&$variables) {
   $project = $variables['node']->project;
-  
+
   // expand the project object to include the project relationships.
   $options = array(
     'return_array' => 1,
-    // we don't want to fully recurse we only need information about the 
+    // we don't want to fully recurse we only need information about the
     // relationship type and the object and subject projects
     'include_fk' => array(
       'type_id'    => 1,
@@ -19,22 +19,22 @@ function tripal_project_preprocess_tripal_project_relationships(&$variables) {
     ),
   );
   $project = chado_expand_var($project, 'table', 'project_relationship', $options);
-  
+
   // get the subject relationships
   $srelationships = $project->project_relationship->subject_project_id;
   $orelationships = $project->project_relationship->object_project_id;
-  
+
   // combine both object and subject relationshisp into a single array
   $relationships = array();
   $relationships['object'] = array();
   $relationships['subject'] = array();
-  
+
   // iterate through the object relationships
   if ($orelationships) {
-    foreach ($orelationships as $relationship) {      
-       $rel = new stdClass(); 
+    foreach ($orelationships as $relationship) {
+       $rel = new stdClass();
        $rel->record = $relationship;
-       
+
        // get the relationship and child types
        $rel_type = t(preg_replace('/_/', " ", $relationship->type_id->name));
 
@@ -44,31 +44,27 @@ function tripal_project_preprocess_tripal_project_relationships(&$variables) {
        if ($n) {
           $rel->record->nid = $n->nid;
        }
-  
-       if (!array_key_exists($rel_type, $relationships['object'])) {
-         $relationships['object'][$rel_type][] = $rel;
-       }
+
+       $relationships['object'][$rel_type][] = $rel;
     }
   }
-  
+
   // now add in the subject relationships
   if ($srelationships) {
     foreach ($srelationships as $relationship) {
-       $rel = new stdClass(); 
+       $rel = new stdClass();
        $rel->record = $relationship;
-       
+
        $rel_type = t(preg_replace('/_/', " ", $relationship->type_id->name));
-       
+
        // get the node id of the subject
        $sql = "SELECT nid FROM {chado_project} WHERE project_id = :project_id";
        $n = db_query($sql, array(':project_id' => $relationship->object_project_id->project_id))->fetchObject();
        if ($n) {
           $rel->record->nid = $n->nid;
        }
-       
-       if (!array_key_exists($rel_type, $relationships['subject'])) {
-         $relationships['subject'][$rel_type][] = $rel;
-       }
+
+       $relationships['subject'][$rel_type][] = $rel;
     }
   }
   $project->all_relationships = $relationships;