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
|
function admin_summary() { }
|
15
|
function operator_form(&$form, &$form_state) { }
|
16
|
function can_expose() {
|
17
|
return FALSE;
|
18
|
}
|
19
|
|
20
|
/**
|
21
|
* See _node_access_where_sql() for a non-views query based implementation.
|
22
|
*/
|
23
|
function query() {
|
24
|
if (!user_access('administer nodes') && module_implements('node_grants')) {
|
25
|
$table = $this->ensure_my_table();
|
26
|
$grants = db_or();
|
27
|
foreach (node_access_grants('view') as $realm => $gids) {
|
28
|
foreach ($gids as $gid) {
|
29
|
$grants->condition(db_and()
|
30
|
->condition($table . '.gid', $gid)
|
31
|
->condition($table . '.realm', $realm)
|
32
|
);
|
33
|
}
|
34
|
}
|
35
|
|
36
|
$this->query->add_where('AND', $grants);
|
37
|
$this->query->add_where('AND', $table . '.grant_view', 1, '>=');
|
38
|
}
|
39
|
}
|
40
|
}
|