You are here

function views_handler_filter_node_uid_revision::query in Views (for Drupal 7) 6.3

Same name and namespace in other branches
  1. 7.3 modules/node/views_handler_filter_node_uid_revision.inc \views_handler_filter_node_uid_revision::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_in_operator::query

File

modules/node/views_handler_filter_node_uid_revision.inc, line 13
Contains handler views_handler_filter_node_uid_revision.

Class

views_handler_filter_node_uid_revision
Filter handler to check for revisions a certain user has created.

Code

function query($group_by = FALSE) {
  $this
    ->ensure_my_table();
  $replace = array_fill(0, sizeof($this->value), '%d');
  $this->operator = strtoupper($this->operator);
  $condition = $this->operator . ' (' . implode(", ", $replace) . ')';

  // We include the WHERE condition twice in the query, so we need two
  // copies of these argument values.
  $args = array_values($this->value);
  $args = array_merge($args, $args);
  $this->query
    ->add_where($this->options['group'], "{$this->table_alias}.uid " . $condition . " OR\n      ((SELECT COUNT(*) FROM {node_revisions} nr WHERE nr.uid " . $condition . " AND nr.nid = {$this->table_alias}.nid) > 0)", $args);
}