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); } }