You are here

public function Sql::buildOptionsForm in Views (for Drupal 7) 8.3

Add settings for the ui.

Overrides PluginBase::buildOptionsForm

File

lib/Drupal/views/Plugin/views/query/Sql.php, line 214
Definition of Drupal\views\Plugin\views\query\Sql.

Class

Sql
@todo.

Namespace

Drupal\views\Plugin\views\query

Code

public function buildOptionsForm(&$form, &$form_state) {
  parent::buildOptionsForm($form, $form_state);
  $form['disable_sql_rewrite'] = array(
    '#title' => t('Disable SQL rewriting'),
    '#description' => t('Disabling SQL rewriting will disable node_access checks as well as other modules that implement hook_query_alter().'),
    '#type' => 'checkbox',
    '#default_value' => !empty($this->options['disable_sql_rewrite']),
    '#suffix' => '<div class="messages warning sql-rewrite-warning js-hide">' . t('WARNING: Disabling SQL rewriting means that node access 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.') . '</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['slave'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use Slave Server'),
    '#description' => t('This will make the query attempt to connect to a slave server if available.  If no slave server is defined or available, it will fall back to the default server.'),
    '#default_value' => !empty($this->options['slave']),
  );
  $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',
    ),
  );
  $form_state['build_info']['files']['foo'] = drupal_get_path('module', 'views') . '/lib/Drupal/views/Plugin/Query/SqlQuery.php';
}