function tripal_clone_views_integration

2.x tripal_views.api.inc tripal_clone_views_integration($table_name, $new_priority = NULL, $template_priority = NULL)
3.x tripal_chado_views.api.inc tripal_clone_views_integration($table_name, $new_priority = NULL, $template_priority = NULL)

Clone an integration. This is often a great way to create your own module-specific integration while still benifiting from an existing (or even the lightest priority) integration.

Parameters

$table_name: The table for which you'd like to clone an integration

$new_priority: The priority of the clone; this is the integration which will be created. If no priority is supplied then one lighter then the $template_priority will be used.

$template_priority: The priority of the template to be used for the clone; this is an existing integration. If no priority is supplied then the lightest priority will be used.

Related topics

3 calls to tripal_clone_views_integration()
tripal_add_field_to_views_integration in tripal_views/api/tripal_views.api.inc
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.
tripal_add_join_to_views_integration in tripal_views/api/tripal_views.api.inc
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.
tripal_views_clone_integration in tripal_views/api/tripal_views.DEPRECATED.inc
1 string reference to 'tripal_clone_views_integration'

File

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

Code

function tripal_clone_views_integration($table_name, $new_priority = NULL, $template_priority = NULL) {

  if (empty($template_priority)) {
    $template_setup_id = tripal_get_lightest_views_integration_setup($table_name);
  }
  else {
    $template_setup_id = tripal_get_views_integration_setup_id($table_name, $template_priority);
  }

  $defn_array = tripal_export_views_integration($template_setup_id);

  if (empty($new_priority)) {
    $defn_array['priority'] = $new_priority;
  }
  else {
    $new_priority = $defn_array['priority'] - 1;
    $defn_array['priority'] = $defn_array['priority'] - 1;
  }

  tripal_add_views_integration($defn_array);
  $setup_id = db_query(
  "SELECT setup_id FROM {tripal_views} WHERE table_name=:table AND priority=:priority", 
  array(
    ':table' => $table_name,
    ':priority' => $new_priority
  )
  );
  $setup_id = $setup_id->fetchField();

  if (empty($setup_id)) {
    tripal_report_error('tripal_views', TRIPAL_ERROR, 'Unable to clone the setup for %table in order to add the following field to the integration: %field.', 
    array('%table' => $table_name, '%field' => print_r($field_array, TRUE)));
    return FALSE;
  }
  else {
    return $setup_id;
  }

}