views_handler_field_user_ip_count.inc 628 B

1234567891011121314151617181920
  1. <?php
  2. /**
  3. * @file
  4. * User Stats IP address count by user.
  5. */
  6. /**
  7. * IP addresses by user count handler.
  8. */
  9. class views_handler_field_user_ip_count extends views_handler_field_numeric {
  10. function query() {
  11. $this->table_alias = $this->ensure_my_table();
  12. // We need another subquery here to extract DISTINCT values
  13. $sql = "SELECT COUNT(usi.ip_address)
  14. FROM (SELECT DISTINCT(uid), ip_address FROM {user_stats_ips}) usi
  15. WHERE usi.uid = " . check_plain($this->table_alias) . ".uid";
  16. $this->field_alias = $this->query->add_field(NULL, "(" . $sql . ")", $this->table_alias . '_' . $this->field);
  17. }
  18. }