You are here

public function SearchApiViewsQuery::options_form in Search API 7

Add settings for the UI.

Adds an option for bypassing access checks.

Overrides views_plugin_query::options_form

File

contrib/search_api_views/includes/query.inc, line 212
Contains SearchApiViewsQuery.

Class

SearchApiViewsQuery
Views query class using a Search API index as the data source.

Code

public function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $form['search_api_bypass_access'] = array(
    '#type' => 'checkbox',
    '#title' => t('Bypass access checks'),
    '#description' => t('If the underlying search index has access checks enabled, this option allows to disable them for this view.'),
    '#default_value' => $this->options['search_api_bypass_access'],
  );
  if ($this->index && $this->index
    ->getEntityType()) {
    $form['entity_access'] = array(
      '#type' => 'checkbox',
      '#title' => t('Additional access checks on result entities'),
      '#description' => t("Execute an access check for all result entities. This prevents users from seeing inappropriate content when the index contains stale data, or doesn't provide access checks. However, result counts, paging and other things won't work correctly if results are eliminated in this way, so only use this as a last ressort (and in addition to other checks, if possible)."),
      '#default_value' => $this->options['entity_access'],
    );
  }
  $form['parse_mode'] = array(
    '#type' => 'select',
    '#title' => t('Parse mode'),
    '#description' => t('Choose how the search keys will be parsed.'),
    '#options' => array(),
    '#default_value' => $this->options['parse_mode'],
  );
  foreach ($this->query
    ->parseModes() as $key => $mode) {
    $form['parse_mode']['#options'][$key] = $mode['name'];
    if (!empty($mode['description'])) {
      $states['visible'][':input[name="query[options][parse_mode]"]']['value'] = $key;
      $form["parse_mode_{$key}_description"] = array(
        '#type' => 'item',
        '#title' => $mode['name'],
        '#description' => $mode['description'],
        '#states' => $states,
      );
    }
  }
  if (module_exists('facetapi')) {
    $form['preserve_facet_query_args'] = array(
      '#type' => 'checkbox',
      '#title' => t('Preserve facets while using filters'),
      '#description' => t('By default, changing an exposed filter would reset all selected facets. This option allows you to prevent this behavior.'),
      '#default_value' => $this->options['preserve_facet_query_args'],
    );
  }
}