You are here

function apachesolr_search_enable in Apache Solr Search 6.3

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

Implements hook_enable().

1 call to apachesolr_search_enable()
apachesolr_search_update_6302 in ./apachesolr_search.install
This function cleans up the old apachesolr tables. There is no magic upgrade pat. The old facet and MLT blocks will be gone

File

./apachesolr_search.install, line 19
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', TRUE);
  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,
    );
    $search_page = array();
    $search_page['page_id'] = 'core_search';
    $search_page['label'] = 'Core Search';
    $search_page['description'] = 'Core Search';
    $search_page['search_path'] = 'search/site';
    $search_page['env_id'] = 'solr';
    $search_page['page_title'] = 'Site';
    $search_page['settings'] = $settings;
    apachesolr_search_page_save($search_page);
  }
  $search_page = apachesolr_search_page_load('taxonomy_search', TRUE);
  if (empty($search_page)) {

    // Add a taxonomy search page to the database
    $settings = array(
      'apachesolr_search_search_type' => 'tid',
      'apachesolr_search_per_page' => 10,
      'apachesolr_search_browse' => 'results',
      'apachesolr_search_spellcheck' => FALSE,
      'apachesolr_search_search_box' => FALSE,
    );
    $search_page = array();
    $search_page['page_id'] = 'taxonomy_search';
    $search_page['label'] = 'Taxonomy Search';
    $search_page['description'] = 'Search all items with given term';
    $search_page['search_path'] = 'taxonomy/term/%';
    $search_page['env_id'] = '';
    $search_page['page_title'] = '%value';
    $search_page['settings'] = $settings;
    apachesolr_search_page_save($search_page);
  }
  $active = variable_get('search_active_modules', array(
    'node',
    'user',
  ));
  $active[] = 'apachesolr_search';
  variable_set('search_active_modules', array_unique($active));
}