You are here

public function SearchApiMultiViewsQuery::options_form in Search API Multi-Index Searches 7

Adds settings for the UI.

Adds an option for bypassing access checks.

Overrides SearchApiViewsQuery::options_form

File

views/query.inc, line 33

Class

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

Code

public function 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'],
  );
  $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,
      );
    }
  }
}