1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* User Stats is user online sort handler.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Is user online sort handler.
|
10
|
*/
|
11
|
class views_handler_sort_is_online extends views_handler_sort {
|
12
|
function query() {
|
13
|
$this->ensure_my_table();
|
14
|
// Currently Views has no support for/information on the {sessions} table.
|
15
|
$join = new views_join;
|
16
|
$join->construct('sessions', $this->table_alias, 'uid', 'uid', array());
|
17
|
$session = $this->query->ensure_table('sessions', NULL, $join);
|
18
|
|
19
|
// We use an IF for MySQL/PostgreSQL compatibility. Otherwise PostgreSQL
|
20
|
// would return 'f' and 't'.
|
21
|
$sql_if_part = "IF((" . REQUEST_TIME . " - $session.timestamp) < " . variable_get('user_block_seconds_online', 900) . ", 1, 0)";
|
22
|
$this->query->add_orderby(NULL, $sql_if_part, $this->options['order'], $this->table_alias . '_' . $this->field, array('function' => 'max'));
|
23
|
}
|
24
|
}
|