views_handler_argument_comment_user_uid.inc

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

Definition of views_handler_argument_comment_user_uid.

File

modules/comment/views_handler_argument_comment_user_uid.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_handler_argument_comment_user_uid.
  5. */
  6. /**
  7. * Argument handler to accept a user id to check for nodes that
  8. * user posted or commented on.
  9. *
  10. * @ingroup views_argument_handlers
  11. */
  12. class views_handler_argument_comment_user_uid extends views_handler_argument {
  13. function title() {
  14. if (!$this->argument) {
  15. $title = variable_get('anonymous', t('Anonymous'));
  16. }
  17. else {
  18. $title = db_query('SELECT u.name FROM {users} u WHERE u.uid = :uid', array(':uid' => $this->argument))->fetchField();
  19. }
  20. if (empty($title)) {
  21. return t('No user');
  22. }
  23. return check_plain($title);
  24. }
  25. function default_actions($which = NULL) {
  26. // Disallow summary views on this argument.
  27. if (!$which) {
  28. $actions = parent::default_actions();
  29. unset($actions['summary asc']);
  30. unset($actions['summary desc']);
  31. return $actions;
  32. }
  33. if ($which != 'summary asc' && $which != 'summary desc') {
  34. return parent::default_actions($which);
  35. }
  36. }
  37. function query($group_by = FALSE) {
  38. $this->ensure_my_table();
  39. $subselect = db_select('comment', 'c');
  40. $subselect->addField('c', 'cid');
  41. $subselect->condition('c.uid', $this->argument);
  42. $subselect->where("c.nid = $this->table_alias.nid");
  43. $condition = db_or()
  44. ->condition("$this->table_alias.uid", $this->argument, '=')
  45. ->exists($subselect);
  46. $this->query->add_where(0, $condition);
  47. }
  48. function get_sort_name() {
  49. return t('Numerical', array(), array('context' => 'Sort order'));
  50. }
  51. }