You are here

class views_handler_sort_is_online in User Stats 6

Same name and namespace in other branches
  1. 7 views/views_handler_sort_is_online.inc \views_handler_sort_is_online

Is user online sort handler.

Hierarchy

Expanded class hierarchy of views_handler_sort_is_online

1 string reference to 'views_handler_sort_is_online'
user_stats_views_data in views/user_stats.views.inc
Implementation of hook_views_data().

File

views/views_handler_sort_is_online.inc, line 11
User Stats is user online sort handler.

View source
class views_handler_sort_is_online extends views_handler_sort {
  function query() {
    $this
      ->ensure_my_table();

    // Currently Views has no support for/information on the {sessions} table.
    $join = new views_join();
    $join
      ->construct('sessions', $this->table_alias, 'uid', 'uid', array());
    $session = $this->query
      ->ensure_table('sessions', NULL, $join);
    $this->query->distinct = TRUE;

    // We use an IF for MySQL/PostgreSQL compatibility. Otherwise PostgreSQL
    // would return 'f' and 't'.
    $sql = "(" . time() . " - MAX({$session}.timestamp)) < " . variable_get('user_block_seconds_online', 900);
    $this->query
      ->add_orderby(NULL, $sql, $this->options['order'], $this->table_alias . '_' . $this->field);
  }

}

Members