You are here

function acquia_search_requirements in Acquia Connector 7.3

Same name and namespace in other branches
  1. 8 acquia_search/acquia_search.install \acquia_search_requirements()
  2. 7 acquia_search/acquia_search.install \acquia_search_requirements()
  3. 7.2 acquia_search/acquia_search.install \acquia_search_requirements()

Implements hook_requirements().

File

acquia_search/acquia_search.install, line 11
Install file.

Code

function acquia_search_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break at install time.
  $t = get_t();

  // Skip install checks if install.php is running. The weak install profile
  // API means install.php calls hook_requirements for every module in a
  // profile.
  if ($phase == 'install' && defined('MAINTENANCE_MODE') && MAINTENANCE_MODE != 'install') {
    if (module_invoke('acquia_agent', 'has_credentials')) {
      $severity = REQUIREMENT_OK;
    }
    else {
      $severity = REQUIREMENT_ERROR;
    }
    $requirements['acquia_search_credentials'] = array(
      'description' => $t('In order to use Acquia search module you must have an Acquia subscription. Please enter your Acquia subscription keys.'),
      'severity' => $severity,
      'value' => '',
    );
  }
  if ($phase == 'runtime') {

    // Check SSL support.
    if (in_array('ssl', stream_get_transports(), TRUE)) {
      $severity = REQUIREMENT_OK;
      $requirements['acquia_search_ssl'] = array(
        'description' => $t('The Acquia Search module is using SSL to protect the privacy of your content.'),
      );
    }
    else {
      $severity = REQUIREMENT_WARNING;
      $requirements['acquia_search_ssl'] = array(
        'description' => $t('In order to protect the privacy of your content with the Acquia Search module you must have SSL support enabled in PHP on your host.'),
      );
    }
    $requirements['acquia_search_ssl']['title'] = $t('Acquia Search');
    $requirements['acquia_search_ssl']['severity'] = $severity;
    $requirements['acquia_search_ssl']['value'] = '';

    // Show available search indexes.
    $environments = apachesolr_load_all_environments();
    foreach ($environments as $env_id => $environment) {

      // Flag when read-only mode was forced because of not finding the right
      // index.
      if (isset($environment['overridden_by_acquia_search']) && $environment['overridden_by_acquia_search'] == ACQUIA_SEARCH_AUTO_OVERRIDE_READ_ONLY) {
        $msg = acquia_search_get_read_only_mode_warning($environment, $t);
        $requirements['acquia_search_read_only']['title'] = $t('Acquia Search');
        $requirements['acquia_search_read_only']['severity'] = REQUIREMENT_WARNING;
        $requirements['acquia_search_read_only']['value'] = $msg;
        break;
      }
    }

    // Flag if acquia_search_multi_subs module is enabled.
    if (module_exists('acquia_search_multi_subs')) {
      $requirements['acquia_search_read_only']['title'] = $t('Acquia Search');
      $requirements['acquia_search_read_only']['severity'] = REQUIREMENT_WARNING;
      $requirements['acquia_search_read_only']['value'] = $t('Warning: acquia_search_multi_subs.module is enabled, but most of its functionality is now included in the Acquia Search module. Please read <a href="@url">our documentation</a>.', array(
        '@url' => 'https://docs.acquia.com/acquia-search/multiple-cores',
      ));
    }

    // Check Apache Solr API version.
    if (!defined('APACHESOLR_API_VERSION') || version_compare(APACHESOLR_API_VERSION, '3.0', '<')) {
      $requirements['acquia_search_apachesolr']['title'] = $t('Acquia Search');
      $requirements['acquia_search_apachesolr']['severity'] = REQUIREMENT_ERROR;
      $requirements['acquia_search_apachesolr']['description'] = $t('Apache Solr API Integration requires  API version 3.0.  Please upgrade your Apache Solr Search Integration module');
      $requirements['acquia_search_apachesolr']['value'] = $t('Incompatible API version');
    }
  }

  // Update the cached version whenever we may be updating the module.
  if ($phase == 'runtime' || $phase == 'update') {
    _acquia_search_set_version();
  }
  return $requirements;
}