/[drupal]/contributions/modules/user_stats/views/views_handler_sort_is_online.inc
ViewVC logotype

Diff of /contributions/modules/user_stats/views/views_handler_sort_is_online.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.3, Fri Feb 13 03:18:36 2009 UTC revision 1.1.2.4, Wed Jul 1 07:08:23 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: views_handler_sort_is_online.inc,v 1.1.2.2 2009/02/12 20:02:26 liammcdermott Exp $  // $Id: views_handler_sort_is_online.inc,v 1.1.2.3 2009/02/13 03:18:36 liammcdermott Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 7  Line 7 
7   */   */
8    
9  /**  /**
10   * Is user online sort handler. Useful for newbies who don't know how to do this   * Is user online sort handler.
  * using filters.  
11   */   */
12  class views_handler_sort_is_online extends views_handler_sort {  class views_handler_sort_is_online extends views_handler_sort {
13    function query() {    function query() {
     $sql = "(". time() ." - users.access) < 900";  
14      $this->ensure_my_table();      $this->ensure_my_table();
15        // Currently Views has no support for/information on the {sessions} table.
16        $join = new views_join;
17        $join->construct('sessions', $this->table_alias, 'uid', 'uid', array());
18        $session = $this->query->ensure_table('sessions', NULL, $join);
19    
20        $this->query->distinct = TRUE;
21        // We use an IF for MySQL/PostgreSQL compatibility. Otherwise PostgreSQL
22        // would return 'f' and 't'.
23        $sql = "(". time() ." - MAX($session.timestamp)) < ". variable_get('user_block_seconds_online', 900);
24      $this->query->add_orderby(NULL, $sql, $this->options['order'], $this->table_alias .'_'. $this->field);      $this->query->add_orderby(NULL, $sql, $this->options['order'], $this->table_alias .'_'. $this->field);
25    }    }
26  }  }

Legend:
Removed from v.1.1.2.3  
changed lines
  Added in v.1.1.2.4

  ViewVC Help
Powered by ViewVC 1.1.2