You are here

function _acquia_search_set_variables in Acquia Search 6

Helper function - set apachesolr variables to Acquia values..

2 calls to _acquia_search_set_variables()
acquia_search_enable in ./acquia_search.module
Implementation of hook_enable().
acquia_search_settings_submit in ./acquia_search.module
Added submit function for acquia_agent_settings and apachesolr_settings forms.

File

./acquia_search.module, line 25
Integration between Acquia Drupal and Acquia's hosted solr search service.

Code

function _acquia_search_set_variables() {
  $identifier = acquia_agent_settings('acquia_identifier');
  $subscription = acquia_agent_settings('acquia_subscription_data');
  $search_host = variable_get('acquia_search_host', 'search.acquia.com');

  // @todo rework this logic once we have AH_SERVER_REGION
  // legacy_internal will be true if 'internal-' is the start of the host
  // name that's set in via Acquia Cloud platform or vset.
  $legacy_internal = preg_match('/internal[-.]/', $search_host);

  // Adding the subscription specific colony to the heartbeat data
  if (!empty($subscription['heartbeat_data']['search_service_colony'])) {
    $search_host = $subscription['heartbeat_data']['search_service_colony'];
    if ($legacy_internal) {

      // If we want to be using an internal host name, fix the one
      // from the hearbeat data here.
      $search_host = 'internal-' . $search_host;
    }
  }

  // Check if we are on Acquia Cloud hosting. @see NN-2503
  if (!empty($_ENV['AH_SITE_ENVIRONMENT']) && !empty($_ENV['AH_SERVER_REGION'])) {
    if ($_ENV['AH_SERVER_REGION'] == 'us-east-1' && $search_host == 'search.acquia.com') {
      $search_host = 'internal-search.acquia.com';
    }
    elseif (strpos($search_host, 'search-' . $_ENV['AH_SERVER_REGION']) === 0) {
      $search_host = 'internal-' . $search_host;
    }
  }
  variable_set('apachesolr_host', $search_host);
  variable_set('apachesolr_port', variable_get('acquia_search_port', '80'));
  variable_set('apachesolr_path', variable_get('acquia_search_path', '/solr/' . $identifier));
  variable_set('apachesolr_service_class', array(
    'acquia_search',
    'Acquia_Search_Service.php',
    'Acquia_Search_Service',
  ));
  if (!variable_get('apachesolr_failure', FALSE)) {
    variable_set('apachesolr_failure', 'show_drupal_results');
  }
  variable_set('apachesolr_search_make_default', 1);

  // Refresh the salt with the subscription data returned by the heartbeat
  // since it can change periodically.
  $salt = variable_get('acquia_search_derived_key_salt', '');
  if (isset($subscription['derived_key_salt']) && $salt != $subscription['derived_key_salt']) {
    variable_set('acquia_search_derived_key_salt', $subscription['derived_key_salt']);
  }
}