function tripal_add_join_to_views_integration

2.x tripal_views.api.inc tripal_add_join_to_views_integration($table_name, $priority, $join)
3.x tripal_chado_views.api.inc tripal_add_join_to_views_integration($table_name, $priority, $join)

Adds the given field to an existing or cloned integration. In the case of a cloned integration, the lightest integration is used as the template for the clone.

NOTE: If that field already exists in the specified integration then it will first be deleted and the new one added.

Parameters

$table_name: The name of the table the integration is for

$priority: The priority of the integration to use; pass NULL to use the lightest integration

$field: An array describing the join to add. it should contain the following keys: base_table, base_field, left_table, left_field, handler, relationship_handler, relationship_only

Return value

TRUE if the field was added successfully; FALSE otherwise

Related topics

File

tripal_views/api/tripal_views.api.inc, line 1232
API functions for Tripal Views Integration

Code

function tripal_add_join_to_views_integration($table_name, $priority, $join) {
  $no_errors = TRUE;

  // If no priority is supplied then add the field to the lightest integration
  if (empty($priority)) {
    $priority = tripal_get_lightest_views_integration_priority($table_name);
  }

  // First get the setup_id
  $setup_id = db_query(
  "SELECT setup_id FROM {tripal_views} WHERE table_name=:table AND priority=:priority", 
  array(
    ':table' => $table_name,
    ':priority' => $priority
  )
  );
  $setup_id = $setup_id->fetchField();

  // If there isn't an integration matching that table/priority combination
  // then clone the lightest priority integration
  if (empty($setup_id)) {
    $setup_id = tripal_clone_views_integration($table_name, $priority);
  }

  // Add the setup_id to the join record passed in
  $join['setup_id'] = $setup_id;

  drupal_write_record('tripal_views_join', $join);
}