function tripal_views_clone_integration

2.x tripal_views.DEPRECATED.inc tripal_views_clone_integration($table_name, $new_priority = NULL, $template_priority = NULL)
1.x tripal_views.api.inc tripal_views_clone_integration($table_name, $new_priority = NULL, $template_priority = NULL)

Clone an 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

1 call to tripal_views_clone_integration()
tripal_views_add_field_to_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.

File

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

Code

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

  if (empty($template_priority)) {
    $template_setup_id = tripal_views_get_lightest_priority_setup($table_name);
  }
  else {
    $template_setup_id = tripal_views_get_setup_id($table_name, $template_priority);
  }

  $defn_array = tripal_views_integration_export_entry($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_views_integration_add_entry($defn_array);
  $setup_id = db_result(db_query("SELECT setup_id FROM {tripal_views} WHERE table_name='%s' AND priority=%d", $table_name, $new_priority));

  if (empty($setup_id)) {
    watchdog('tripal_views', '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)), WATCHDOG_ERROR);
    return FALSE;
  }
  else {
    return $setup_id;
  }

}