You are here

function views_handler_filter_is_online::query in User Stats 7

Same name and namespace in other branches
  1. 6 views/views_handler_filter_is_online.inc \views_handler_filter_is_online::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_boolean_operator::query

File

views/views_handler_filter_is_online.inc, line 12
User Stats is user online sort handler.

Class

views_handler_filter_is_online
Is user online sort handler.

Code

function query() {
  $this
    ->ensure_my_table();
  $join = new views_join();
  $join
    ->construct('sessions', $this->table_alias, 'uid', 'uid', array());
  $session = $this->query
    ->ensure_table('sessions', NULL, $join);

  // We have to make sure this field is in the query, and Views knows to
  // create GROUP BY's.
  $sql_if_part = "IF((" . REQUEST_TIME . " - {$session}.timestamp) < " . variable_get('user_block_seconds_online', 900) . ", 1, 0)";
  $sql = $sql_if_part . " = :value";
  $this->query
    ->add_where_expression($this->options['group'], $sql, array(
    ':value' => $this->value,
  ));
}