View source
<?php
function acquia_search_requirements($phase) {
$requirements = array();
$t = get_t();
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') {
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'] = '';
$environments = apachesolr_load_all_environments();
foreach ($environments as $env_id => $environment) {
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;
}
}
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',
));
}
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');
}
}
if ($phase == 'runtime' || $phase == 'update') {
_acquia_search_set_version();
}
return $requirements;
}
function acquia_search_install() {
return;
$facets = _acquia_search_get_default_facets();
$theme_key = variable_get('theme_default', 'bartik');
$block_regions = array_keys(system_region_list($theme_key));
$region = _acquia_search_find_block_region($block_regions);
if (empty($region)) {
drupal_set_message(t('We were unable to auto-detect where to put the filter blocks for your faceted search engine. To get started adding blocks, go to the <a href="@active_filter_config_form">filter configuration screen</a>.', array(
'@active_filter_config_form' => url('admin/config/apachesolr/active_filters'),
)));
return;
}
foreach ($facets['apachesolr_search'] as $delta => $facet_field) {
$blocks[] = array(
'module' => 'apachesolr_search',
'delta' => $delta,
);
}
$blocks[] = array(
'module' => 'apachesolr',
'delta' => 'sort',
'weight' => -1,
);
foreach ($blocks as $block) {
$block['cache'] = DRUPAL_CACHE_PER_PAGE;
$block['theme'] = $theme_key;
$block['region'] = $region;
$block['status'] = 1;
$block['pages'] = '';
if (!db_query("SELECT 1 FROM {block} WHERE theme = ':theme' AND module = ':module' AND delta = ':delta'", array(
':theme' => $block['theme'],
':module' => $block['module'],
':delta' => $block['delta'],
))
->fetchField()) {
drupal_write_record('blocks', $block);
}
}
}
function _acquia_search_find_block_region($block_regions = array()) {
$regions_to_look_for = array(
'left',
'sidebar_first',
);
if ($matches = array_intersect($block_regions, $regions_to_look_for)) {
return array_shift($matches);
}
}
function _acquia_search_get_default_facets() {
$default_enabled_facets['apachesolr_search']['bundle'] = 'bundle';
$default_enabled_facets['apachesolr_search']['is_uid'] = 'is_uid';
return $default_enabled_facets;
}
function acquia_search_uninstall() {
variable_del('acquia_search_path');
variable_del('acquia_search_base_url');
variable_del('acquia_search_derived_key_salt');
variable_del('acquia_search_disable_auto_switch');
variable_del('acquia_search_disable_auto_read_only');
}
function acquia_search_update_7000() {
variable_del('acquia_search_host');
variable_del('acquia_search_port');
variable_del('acquia_search_path');
}
function acquia_search_update_7001() {
variable_del('acquia_search_url');
}
function acquia_search_update_7002() {
$class = variable_get('apachesolr_service_class', '');
if ($class && strpos($class, 'Acquia') === 0) {
variable_del('apachesolr_service_class');
}
}