function activity_views_handler_filter_access::query in Activity 6.2
Same name and namespace in other branches
- 7 views/views_handler_filters.inc \activity_views_handler_filter_access::query()
override query
File
- views/
activity_views_handler_filter_access.inc, line 54 - generic handler that provides access control on where
Class
- activity_views_handler_filter_access
- @file generic handler that provides access control on where
Code
function query() {
$this
->ensure_my_table();
$group = activity_views_group();
$placeholder = '%d';
// ensure the file is included for this module
activity_get_module_info($this->definition['module']);
// go through each grant that this user has
$realms = module_invoke($this->definition['module'], 'activity_access_grants', activity_views_access_user());
// All the valid realms according to the options form.
$valid_realms = array_intersect(array_keys($this->options['realms']), array_keys($realms));
if (empty($valid_realms)) {
// The user hasn't done anything that $this->definition['module'] realms
// keep track of, use a dummy realm.
$realms = array(
'activity_none' => array(
-1,
),
);
$valid_realms = array(
'activity_none',
);
}
foreach ($valid_realms as $realm) {
if (is_null($group)) {
// Static cache the where group for other access handlers to use.
$group = activity_views_group($this->query
->set_where_group('OR'));
}
$values = $realms[$realm];
$replace = array_fill(0, sizeof($values), $placeholder);
$in = ' (' . implode(", ", $replace) . ')';
// Use the group to keep all access handlers in the same OR query.
$this->query
->add_where($group, "({$this->table_alias}.realm = '%s' AND {$this->table_alias}.{$this->real_field} IN {$in})", array_merge(array(
$realm,
), $values));
}
}