1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Definition of views_handler_filter_node_access.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Filter by node_access records.
|
10
|
*
|
11
|
* @ingroup views_filter_handlers
|
12
|
*/
|
13
|
class views_handler_filter_node_access extends views_handler_filter {
|
14
|
|
15
|
/**
|
16
|
* {@inheritdoc}
|
17
|
*/
|
18
|
public function admin_summary() {
|
19
|
}
|
20
|
|
21
|
/**
|
22
|
* {@inheritdoc}
|
23
|
*/
|
24
|
public function operator_form(&$form, &$form_state) {
|
25
|
}
|
26
|
|
27
|
/**
|
28
|
* {@inheritdoc}
|
29
|
*/
|
30
|
public function can_expose() {
|
31
|
return FALSE;
|
32
|
}
|
33
|
|
34
|
/**
|
35
|
* See _node_access_where_sql() for a non-views query based implementation.
|
36
|
*/
|
37
|
public function query() {
|
38
|
if (!user_access('administer nodes') && module_implements('node_grants')) {
|
39
|
$table = $this->ensure_my_table();
|
40
|
$grants = db_or();
|
41
|
foreach (node_access_grants('view') as $realm => $gids) {
|
42
|
foreach ($gids as $gid) {
|
43
|
$grants->condition(db_and()
|
44
|
->condition($table . '.gid', $gid)
|
45
|
->condition($table . '.realm', $realm)
|
46
|
);
|
47
|
}
|
48
|
}
|
49
|
|
50
|
$this->query->add_where('AND', $grants);
|
51
|
$this->query->add_where('AND', $table . '.grant_view', 1, '>=');
|
52
|
}
|
53
|
}
|
54
|
|
55
|
}
|