views_handler_filter_comment_user_uid.inc

  1. 3.x modules/comment/views_handler_filter_comment_user_uid.inc
  2. 2.x modules/comment/views_handler_filter_comment_user_uid.inc

File

modules/comment/views_handler_filter_comment_user_uid.inc
View source
  1. <?php
  2. /**
  3. * Filter handler to accept a user id to check for nodes that user posted or
  4. * commented on.
  5. */
  6. class views_handler_filter_comment_user_uid extends views_handler_filter_user_name {
  7. function query() {
  8. $this->ensure_my_table();
  9. $replace = array_fill(0, sizeof($this->value), '%d');
  10. $condition = $this->operator . ' (' . implode(", ", $replace) . ')';
  11. // We include the WHERE condition twice in the query, so we need two
  12. // copies of these argument values.
  13. $args = array_values($this->value);
  14. $args = array_merge($args, $args);
  15. $this->query->add_where($this->options['group'], "$this->table_alias.uid " . $condition . " OR
  16. ((SELECT COUNT(*) FROM {comments} c WHERE c.uid " . $condition . " AND c.nid = $this->table_alias.nid) > 0)",
  17. $args);
  18. }
  19. }