function views_plugin_query_default::options_form
Add settings for the ui.
Overrides views_plugin_query::options_form
File
-
plugins/
views_plugin_query_default.inc, line 247
Class
- views_plugin_query_default
- Object used to create a SELECT query.
Code
public function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
// Establish which query tag will be affected by disable_sql_rewrite.
// This 'access query tag' is defined by hook_views_data() for the base table.
// e.g. node_views_data()
if (!empty($form_state['view']->base_table)) {
$base_table = $form_state['view']->base_table;
$base_table_data = views_fetch_data($base_table);
if (!empty($base_table_data['table']['base']['access query tag'])) {
$access_tag = $base_table_data['table']['base']['access query tag'];
$disable_rewrite = !empty($this->options['disable_sql_rewrite']);
$form['disable_sql_rewrite'] = array(
'#title' => t('Disable access checks'),
'#description' => t('Do not apply %access_tag checks to this query. Selecting this option omits that tag from the alterable query.', array(
'%access_tag' => $access_tag,
)),
'#type' => 'checkbox',
'#default_value' => $disable_rewrite,
'#suffix' => '<div class="messages warning sql-rewrite-warning' . ($disable_rewrite ? '' : ' js-hide') . '">' . t('WARNING: Disabling access checks means that %access_tag security is disabled. This may allow users to see data they should not be able to see if your view is misconfigured. Please use this option only if you understand and accept this security risk.', array(
'%access_tag' => $access_tag,
)) . '</div>',
);
}
}
$form['distinct'] = array(
'#type' => 'checkbox',
'#title' => t('Distinct'),
'#description' => t('This will make the view display only distinct items. If there are multiple identical items, each will be displayed only once. You can use this to try and remove duplicates from a view, though it does not always work. Note that this can slow queries down, so use it with caution.'),
'#default_value' => !empty($this->options['distinct']),
);
$form['pure_distinct'] = array(
'#type' => 'checkbox',
'#title' => t('Pure Distinct'),
'#description' => t('This will prevent views from adding the base column to the distinct field. If this is not selected and the base column is a primary key, then a non-pure distinct will not function properly because the primary key is always unique.'),
'#default_value' => !empty($this->options['pure_distinct']),
'#dependency' => array(
'edit-query-options-distinct' => '1',
),
);
$form['slave'] = array(
'#type' => 'checkbox',
'#default_value' => !empty($this->options['slave']),
'#title' => t('Use Replica Server'),
'#description' => t('This will make the query attempt to connect to a replica server if available. If no replica server is defined or available, it will fall back to the default server.'),
);
$form['query_comment'] = array(
'#type' => 'textfield',
'#title' => t('Query Comment'),
'#description' => t('If set, this comment will be embedded in the query and passed to the SQL server. This can be helpful for logging or debugging.'),
'#default_value' => $this->options['query_comment'],
);
$form['query_tags'] = array(
'#type' => 'textfield',
'#title' => t('Query Tags'),
'#description' => t('If set, these tags will be appended to the query and can be used to identify the query in a module. This can be helpful for altering queries.'),
'#default_value' => implode(', ', $this->options['query_tags']),
'#element_validate' => array(
'views_element_validate_tags',
),
);
}