You are here

function search_files_helper_edit_form_submit in Search Files 7.2

Updates the helper to the database.

File

./search_files.module, line 419
Organizes and provides helper functions for extracting text from files.

Code

function search_files_helper_edit_form_submit($form, &$form_state) {
  $id = 0;
  if (isset($form_state['values']['search_files_id'])) {
    $id = intval($form_state['values']['search_files_id']);
  }
  if ($id) {
    $num = db_update('search_files_helpers')
      ->fields(array(
      'name' => $form_state['values']['search_files_name'],
      'extension' => $form_state['values']['search_files_extension'],
      'helper_path' => $form_state['values']['search_files_helper_path'],
    ))
      ->condition('id', $id)
      ->execute();
    if ($num) {
      drupal_set_message(t('Helper app %helper_name has been updated', array(
        '%helper_name' => $form_state['values']['search_files_name'],
      )));
    }
    else {
      drupal_set_message(t('An error occurred'));
    }
    drupal_goto('admin/config/search/search_files/helpers/list');
  }
  else {
    $result = search_files_helper_db_add($form_state['values']['search_files_name'], $form_state['values']['search_files_extension'], $form_state['values']['search_files_helper_path']);
    if ($result) {
      drupal_set_message(t('%helper helper added', array(
        '%helper' => $form_state['values']['search_files_name'],
      )));
    }
    else {
      drupal_set_message(t('An error occurred'));
    }
    if ($form_state['clicked_button']['#id'] == 'edit-submit-done') {
      drupal_goto('admin/config/search/search_files/helpers/list');
    }
  }
}