function tripal_cv_edit_form_submit

1.x tripal_cv_admin.inc tripal_cv_edit_form_submit($form, &$form_state)

Purpose: The submit function of the update/delete controlled vocabulary form

Related topics

File

tripal_cv/includes/tripal_cv_admin.inc, line 134

Code

function tripal_cv_edit_form_submit($form, &$form_state) {

  $name = $form_state['values']['name'];
  $desc = $form_state['values']['definition'];
  $cvid = $form_state['values']['cvid'];
  $op = $form_state['values']['op'];

  if (strcmp($op, 'Update') == 0) {
    $sql = "
       UPDATE {cv} SET
         name = '%s',
         definition = '%s'
       WHERE cv_id = %d
    ";
    $db = chado_query($sql, $name, $desc, $cvid);
    if ($db) {
      drupal_set_message(t("Controlled vocabulary updated"));
    }
    else {
      drupal_set_message(t("Failed to update controlled vocabulary."), 'error');
    }
  }
  if (strcmp($op, 'Delete') == 0) {
    $sql = "
       DELETE FROM {cv}
       WHERE cv_id = %d
    ";
    $db = chado_query($sql, $cvid);
    if ($db) {
      drupal_set_message(t("Controlled vocabulary deleted"));
    }
    else {
      drupal_set_message(t("Failed to delete controlled vocabulary."), 'error');
    }
  }

}