Projet

Général

Profil

Paste
Télécharger (1,69 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / modules / comment / views_handler_argument_comment_user_uid.inc @ 5d12d676

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

    
16
  /**
17
   * {@inheritdoc}
18
   */
19
  public function title() {
20
    if (!$this->argument) {
21
      $title = variable_get('anonymous', t('Anonymous'));
22
    }
23
    else {
24
      $title = db_query('SELECT u.name FROM {users} u WHERE u.uid = :uid', array(':uid' => $this->argument))->fetchField();
25
    }
26
    if (empty($title)) {
27
      return t('No user');
28
    }
29

    
30
    return check_plain($title);
31
  }
32

    
33
  /**
34
   * {@inheritdoc}
35
   */
36
  public function default_actions($which = NULL) {
37
    // Disallow summary views on this argument.
38
    if (!$which) {
39
      $actions = parent::default_actions();
40
      unset($actions['summary asc']);
41
      unset($actions['summary desc']);
42
      return $actions;
43
    }
44

    
45
    if ($which != 'summary asc' && $which != 'summary desc') {
46
      return parent::default_actions($which);
47
    }
48
  }
49

    
50
  /**
51
   * {@inheritdoc}
52
   */
53
  public function query($group_by = FALSE) {
54
    $this->ensure_my_table();
55

    
56
    $subselect = db_select('comment', 'c');
57
    $subselect->addField('c', 'cid');
58
    $subselect->condition('c.uid', $this->argument);
59
    $subselect->where("c.nid = $this->table_alias.nid");
60

    
61
    $condition = db_or()
62
      ->condition("$this->table_alias.uid", $this->argument, '=')
63
      ->exists($subselect);
64

    
65
    $this->query->add_where(0, $condition);
66
  }
67

    
68
  /**
69
   * {@inheritdoc}
70
   */
71
  public function get_sort_name() {
72
    return t('Numerical', array(), array('context' => 'Sort order'));
73
  }
74

    
75
}