You are here

function views_handler_filter_block_cache::query in Views Hacks 7

Same name and namespace in other branches
  1. 6 views_block/handlers/views_handler_filter_block_cache.inc \views_handler_filter_block_cache::query()

Add this filter to the query.

Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.

Overrides views_handler_filter::query

File

views_block/handlers/views_handler_filter_block_cache.inc, line 30

Class

views_handler_filter_block_cache
Filter based on block cache settings.

Code

function query() {
  $this
    ->ensure_my_table();
  if (in_array(DRUPAL_NO_CACHE, $this->value)) {
    $this->query
      ->add_where($this->options['group'], "{$this->table_alias}.{$this->real_field} = %d", DRUPAL_NO_CACHE);
  }
  else {
    $val = 0;
    if (!empty($this->value)) {
      foreach ($this->value as $bit) {
        $val |= $bit;
      }
    }
    $this->query
      ->add_where($this->options['group'], "{$this->table_alias}.{$this->real_field} & %d = %d", $val, $val);
    $this->query
      ->add_where($this->options['group'], "{$this->table_alias}.{$this->real_field} != %d", DRUPAL_NO_CACHE);
  }
}