Projet

Général

Profil

Paste
Télécharger (628 octets) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / user_stats / views / views_handler_field_user_ip_count.inc @ 76df55b7

1
<?php
2

    
3
/**
4
 * @file
5
 * User Stats IP address count by user.
6
 */
7

    
8
/**
9
 * IP addresses by user count handler.
10
 */
11
class views_handler_field_user_ip_count extends views_handler_field_numeric {
12
  function query() {
13
    $this->table_alias = $this->ensure_my_table();
14
    // We need another subquery here to extract DISTINCT values
15
    $sql = "SELECT COUNT(usi.ip_address)
16
      FROM (SELECT DISTINCT(uid), ip_address FROM {user_stats_ips}) usi
17
      WHERE usi.uid = " . check_plain($this->table_alias) . ".uid";
18
    $this->field_alias = $this->query->add_field(NULL, "(" . $sql . ")", $this->table_alias . '_' . $this->field);
19
  }
20
}