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