You are here

function custom_search_query_alter in Custom Search 7

File

./custom_search.module, line 628
Bring customizations to the default search box

Code

function custom_search_query_alter(QueryAlterableInterface $query) {
  if (!$query
    ->hasTag('custom_search_ignore') && $query
    ->hasTag('node_access') && $query
    ->hasTag('pager')) {
    $excluded_types = array_filter(variable_get('custom_search_' . variable_get('custom_search_delta', '') . 'node_types_excluded', array()));
    if (!empty($excluded_types)) {
      $tables = $query
        ->getTables();
      foreach ($tables as $table) {
        if ($table['table'] == 'search_index') {
          $query
            ->condition('n.type', $excluded_types, 'NOT IN');
        }
      }
    }
  }
}