1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- function tripal_project_preprocess_tripal_project_relationships(&$variables) {
- $project = $variables['node']->project;
-
- $options = [
- 'return_array' => 1,
-
-
- 'include_fk' => [
- 'type_id' => 1,
- 'object_project_id' => 1,
- 'subject_project_id' => 1,
- ],
- ];
- $project = chado_expand_var($project, 'table', 'project_relationship', $options);
-
- $srelationships = $project->project_relationship->subject_project_id;
- $orelationships = $project->project_relationship->object_project_id;
-
- $relationships = [];
- $relationships['object'] = [];
- $relationships['subject'] = [];
-
- if ($orelationships) {
- foreach ($orelationships as $relationship) {
- $rel = new stdClass();
- $rel->record = $relationship;
-
- $rel_type = t(preg_replace('/_/', " ", $relationship->type_id->name));
-
- $sql = "SELECT nid FROM {chado_project} WHERE project_id = :project_id";
- $n = db_query($sql, [':project_id' => $relationship->subject_project_id->project_id])->fetchObject();
- if ($n) {
- $rel->record->nid = $n->nid;
- }
- $relationships['object'][$rel_type][] = $rel;
- }
- }
-
- if ($srelationships) {
- foreach ($srelationships as $relationship) {
- $rel = new stdClass();
- $rel->record = $relationship;
- $rel_type = t(preg_replace('/_/', " ", $relationship->type_id->name));
-
- $sql = "SELECT nid FROM {chado_project} WHERE project_id = :project_id";
- $n = db_query($sql, [':project_id' => $relationship->object_project_id->project_id])->fetchObject();
- if ($n) {
- $rel->record->nid = $n->nid;
- }
- $relationships['subject'][$rel_type][] = $rel;
- }
- }
- $project->all_relationships = $relationships;
- }
|