function tripal_mviews_form_submit

2.x tripal_core.mviews.inc tripal_mviews_form_submit($form, &$form_state)
3.x tripal_chado.mviews.inc tripal_mviews_form_submit($form, &$form_state)
1.x mviews.inc tripal_mviews_form_submit($form, &$form_state)

Submit the Create/Edit Materialized View Form Implements hook_form_submit().

Related topics

File

tripal_core/includes/tripal_core.mviews.inc, line 545
Contains functions for viewing and editing of Materialized Views on a Tripal website.

Code

function tripal_mviews_form_submit($form, &$form_state) {

  $ret = array();

  $action = $form_state['values']['action'];
  $mview_id = $form_state['values']['mview_id'];
  $name = trim($form_state['values']['name']);
  $is_legacy = $form_state['values']['is_legacy'];
  $query = $form_state['values']['mvquery'];
  $comment = trim($form_state['values']['comment']);
  $schema = $form_state['values']['schema'];
  $modulename = trim($form_state['values']['modulename']);
  $mv_table = '';
  $mv_specs = '';
  $indexed = '';
  $special_index = '';

  // if this is a legacy materialized view (no longer supported in Tripal v2.0
  // but code left just in case)
  if ($is_legacy) {
    $mv_table = $form_state['values']['mv_table'];
    $mv_specs = $form_state['values']['mv_specs'];
    $indexed = $form_state['values']['indexed'];
    $special_index = ''; //$form_state['values']['special_index'];
  }

  if (!$modulename) {
    $modulename = 'tripal_core';
  }

  // if this is an edit action
  if (strcmp($action, 'Edit') == 0) {
    tripal_edit_mview($mview_id, $name, $modulename, $mv_table, $mv_specs, 
    $indexed, $query, $special_index, $comment, $schema);
  }
  // else an add action
  elseif (strcmp($action, 'Add') == 0) {
    // convert the schema into a PHP array
    $schema_arr = array();
    eval("\$schema_arr = $schema;");
    tripal_add_mview($name, $modulename, $schema_arr, $query, $comment);
    drupal_goto("admin/tripal/schema/mviews");
  }
  else {
    drupal_set_message(t("No action performed."));
  }

  return '';
}