You are here

function apachesolr_access_apachesolr_query_alter in Apache Solr Search 8

Same name and namespace in other branches
  1. 6.3 apachesolr_access/apachesolr_access.module \apachesolr_access_apachesolr_query_alter()
  2. 7 apachesolr_access/apachesolr_access.module \apachesolr_access_apachesolr_query_alter()

Implements hook_apachesolr_query_alter().

Alter the query to include the access subquery

Parameters

DrupalSolrQueryInterface $query:

File

apachesolr_access/apachesolr_access.module, line 94

Code

function apachesolr_access_apachesolr_query_alter(DrupalSolrQueryInterface $query) {
  global $user;
  try {
    $subquery = apachesolr_access_build_subquery($user);
    $query
      ->addFilterSubQuery($subquery);
  } catch (Exception $e) {
    watchdog("apachesolr_access", 'User %name (UID:!uid) cannot search: @message', array(
      '%name' => $user->name,
      '!uid' => $user->uid,
      '@message' => $e
        ->getMessage(),
    ));
    $query->abort_search = TRUE;
  }
}