You are here

function apachesolr_search_enable in Apache Solr Search 7

Same name and namespace in other branches
  1. 8 apachesolr_search.install \apachesolr_search_enable()
  2. 6.3 apachesolr_search.install \apachesolr_search_enable()

Implements hook_enable().

File

./apachesolr_search.install, line 37
Install and related hooks for apachesolr_search.

Code

function apachesolr_search_enable() {

  // Make sure the default core search page is installed.
  $search_page = apachesolr_search_page_load('core_search');
  if (empty($search_page)) {

    // Add Default search page (core search)
    // This is a duplication from update_7004 but it is intended
    // so future changes are possible without breaking the update
    $settings = array(
      'apachesolr_search_search_type' => 'custom',
      'apachesolr_search_per_page' => 10,
      'apachesolr_search_browse' => 'browse',
      'apachesolr_search_spellcheck' => TRUE,
      'apachesolr_search_not_removable' => TRUE,
      'apachesolr_search_search_box' => TRUE,
    );
    $settings = serialize($settings);
    $fields = array(
      'page_id' => 'core_search',
      'label' => 'Core Search',
      'description' => 'Core Search',
      'search_path' => 'search/site',
      'env_id' => 'solr',
      'page_title' => 'Site',
      'settings' => $settings,
    );
    db_insert('apachesolr_search_page')
      ->fields($fields)
      ->execute();
  }
  $active = variable_get('search_active_modules', array(
    'node',
    'user',
  ));
  $active[] = 'apachesolr_search';
  variable_set('search_active_modules', array_unique($active));
}