You are here

function sbp_paths_edit_form_submit in Search by Page 7

Same name and namespace in other branches
  1. 6 sbp_paths.module \sbp_paths_edit_form_submit()

Submit callback for sbp_paths_edit_form().

Adds/edits the path to be indexed, and updates database of paths.

File

./sbp_paths.module, line 444
Module file for Search by Page Paths, a sub-module for Search by Page.

Code

function sbp_paths_edit_form_submit($form, &$form_state) {
  $vals = $form_state['values'];
  $langs = serialize($vals['languages']);
  $envid = intval($vals['environment']);

  // Save the new information
  if (isset($vals['pid']) && $vals['pid']) {
    db_update('sbpp_path')
      ->fields(array(
      'environment' => $envid,
      'page_path' => $vals['path'],
      'title' => $vals['title'],
      'page_type' => $vals['type'],
      'snippet' => $vals['snippet'],
      'role' => $vals['role'],
      'languages' => $langs,
    ))
      ->condition('pid', $vals['pid'])
      ->execute();

    // Force this to be reindexed
    search_by_page_force_reindex('sbp_paths', $vals['pid'], $envid);
  }
  else {
    $vals['pid'] = db_insert('sbpp_path')
      ->fields(array(
      'environment' => $envid,
      'page_path' => $vals['path'],
      'title' => $vals['title'],
      'page_type' => $vals['type'],
      'snippet' => $vals['snippet'],
      'role' => $vals['role'],
      'languages' => $langs,
    ))
      ->execute();
  }

  // Update the translation strings
  _sbp_paths_update_translation($vals);

  // Go back to the paths list
  drupal_set_message(t('The page to index has been saved'));
  $form_state['redirect'] = 'admin/config/search/search_by_page/edit/' . $envid . '/paths';
}