You are here

function apachesolr_access_apachesolr_query_alter in Apache Solr Search 6.3

Same name and namespace in other branches
  1. 8 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().

File

apachesolr_access/apachesolr_access.module, line 66

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;
  }
}