Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

47 lines (40 sloc) 1.488 kB
<?php
class searchlight_handler_field_node_access extends views_handler_field {
function option_definition() {
$options = parent::option_definition();
$options['realm'] = array('default' => NULL);
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$options = array();
$result = db_query("SELECT realm FROM {node_access} GROUP BY realm");
while ($row = db_fetch_object($result)) {
$options[$row->realm] = check_plain($row->realm);
}
$form['realm'] = array('#type' => 'select', '#options' => $options);
}
function construct() {
parent::construct();
$this->additional_fields[] = 'gid';
}
function query() {
parent::query();
$table = $this->ensure_my_table();
if (!empty($this->options['realm'])) {
$this->query->add_where('AND', "$table.realm = '%s'", $this->options['realm']);
$this->query->add_where('AND', "$table.grant_view >= 1");
}
}
/**
* Override of add_additional_fields().
* Use field aliases specific to the realm specified in this view.
*/
function add_additional_fields($fields = NULL) {
$fields = !isset($fields) ? $this->additional_fields : $fields;
foreach ($fields as $identifier => $info) {
$this->aliases[$info] = $this->query->add_field($this->table_alias, $info, "{$this->table_alias}_{$info}_{$this->options['realm']}");
}
}
function allow_advanced_render() { return FALSE; }
}
Jump to Line
Something went wrong with that request. Please try again.