You are here

function panelizer_handler_filter_panelizer_status::op_simple in Panelizer 7.3

Same name and namespace in other branches
  1. 7.2 plugins/views/panelizer_handler_filter_panelizer_status.inc \panelizer_handler_filter_panelizer_status::op_simple()

Overrides views_handler_filter_in_operator::op_simple

File

plugins/views/panelizer_handler_filter_panelizer_status.inc, line 38

Class

panelizer_handler_filter_panelizer_status
Filter by node type

Code

function op_simple() {
  if (empty($this->value)) {
    return;
  }
  $this
    ->ensure_my_table();
  $or = db_or();
  $values = $this->value;

  // @todo -- see if we need to use in_array() when a select is used.
  if (in_array('not', $values)) {
    if ($this->operator == 'in') {
      $or
        ->condition(db_and()
        ->condition("{$this->table_alias}.{$this->real_field}", NULL)
        ->condition("{$this->table_alias}.did", 0));
    }
    else {
      $or
        ->condition(db_or()
        ->isNotNull("{$this->table_alias}.{$this->real_field}")
        ->condition(db_and()
        ->isNull("{$this->table_alias}.{$this->real_field}")
        ->condition("{$this->table_alias}.did", 0, '!=')));
    }
    unset($values['not']);
  }
  if (in_array('custom', $values)) {
    if ($this->operator == 'in') {
      $or
        ->condition(db_and()
        ->condition("{$this->table_alias}.{$this->real_field}", NULL)
        ->condition("{$this->table_alias}.did", 0, '!='));
    }
    else {
      $or
        ->condition(db_or()
        ->isNotNull("{$this->table_alias}.{$this->real_field}")
        ->condition(db_and()
        ->isNull("{$this->table_alias}.{$this->real_field}")
        ->condition("{$this->table_alias}.did", 0, '=')));
    }
    unset($values['custom']);
  }
  if ($values) {
    $or
      ->condition("{$this->table_alias}.{$this->real_field}", array_values($values), $this->operator);
  }

  // We use array_values() because the checkboxes keep keys and that can cause
  // array addition problems.
  $this->query
    ->add_where($this->options['group'], $or);
}