UidRevision.php 788 Bytes
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Definition of Drupal\node\Plugin\views\argument\UidRevision.
6 7
 */

8
namespace Drupal\node\Plugin\views\argument;
9

10
use Drupal\user\Plugin\views\argument\Uid;
11 12
use Drupal\Core\Annotation\Plugin;

13 14 15
/**
 * Filter handler to accept a user id to check for nodes that
 * user posted or created a revision on.
16
 *
17
 * @Plugin(
18 19
 *   id = "node_uid_revision",
 *   module = "node"
20 21
 * )
 */
dawehner's avatar
dawehner committed
22
class UidRevision extends Uid {
23

24
  public function query($group_by = FALSE) {
25
    $this->ensureMyTable();
26
    $placeholder = $this->placeholder();
27
    $this->query->add_where_expression(0, "$this->tableAlias.uid = $placeholder OR ((SELECT COUNT(*) FROM {node_revision} nr WHERE nr.uid = $placeholder AND nr.nid = $this->tableAlias.nid) > 0)", array($placeholder => $this->argument));
28
  }
29

30
}