You are here

function apachesolr_search_type_boost_form_submit in Apache Solr Search 5.2

Same name and namespace in other branches
  1. 6 apachesolr_search.admin.inc \apachesolr_search_type_boost_form_submit()
  2. 6.2 apachesolr_search.admin.inc \apachesolr_search_type_boost_form_submit()

Submit callback for apachesolr_search_type_boost_form().

This is call include system_settings_form_submit().

File

./apachesolr_search.admin.inc, line 229
Administrative settings for searching.

Code

function apachesolr_search_type_boost_form_submit($form_id, $form_values) {
  $old_excluded_types = variable_get('apachesolr_search_excluded_types', array());
  $new_excluded_types = $form_values['apachesolr_search_excluded_types'];

  // Check whether we are resetting the values.
  if ($form_values['op'] == $form_values['reset']) {
    $new_excluded_types = array();
  }
  foreach ($new_excluded_types as $type => $excluded) {

    // Remove newly omitted node types.
    // Note - we omit a check on empty($old_excluded_types[$type]) so that
    // the admin can re-submit this page if the delete operation fails.
    if (!empty($new_excluded_types[$type])) {
      try {
        $solr = apachesolr_get_solr();
        $solr
          ->deleteByQuery("type:{$type}");
        apachesolr_index_updated(time());
      } catch (Exception $e) {
        watchdog('Apache Solr', nl2br(check_plain($e
          ->getMessage())), NULL, WATCHDOG_ERROR);
        drupal_set_message(t('The Apache Solr search engine is not available. Please contact your site administrator.'), 'error');
      }
    }
  }
  foreach ($old_excluded_types as $type => $excluded) {

    // Set no longer omitted node types for reindexing.
    if (empty($new_excluded_types[$type]) && !empty($old_excluded_types[$type])) {
      db_query("UPDATE {apachesolr_search_node} SET changed = %d WHERE nid IN (SELECT nid FROM {node} WHERE type = '%s')", time(), $type);
    }
  }
  system_settings_form_submit($form_id, $form_values);
}