You are here

function party_search_api_query_alter in Party 7

Implements hook_search_api_query_alter().

File

./party.module, line 1510
Provides a generic CRM party entity.

Code

function party_search_api_query_alter(SearchApiQueryInterface $query) {

  // Check if this is a party index.
  $index = $query
    ->getIndex();
  if ($index->item_type == 'party') {

    // See whether we're explicitly bypassing party access.
    if (!$query
      ->getOption('party_access_bypass', FALSE)) {

      // Check whether we have access to archived parties.
      if (!(user_access('administer parties') || user_access('view archived parties'))) {

        // Check whether the archived field is indexed.
        $fields = $index
          ->getFields();
        if (isset($fields['archived'])) {
          $query
            ->condition('archived', 0);
        }
      }
    }
  }
}