You are here

public function availability_calendar_handler_filter_availability::accept_exposed_input in Availability Calendars 7.5

Same name and namespace in other branches
  1. 7.3 availability_calendar_handler_filter_availability.inc \availability_calendar_handler_filter_availability::accept_exposed_input()
  2. 7.4 views/availability_calendar_handler_filter_availability.inc \availability_calendar_handler_filter_availability::accept_exposed_input()

Check to see if input from the exposed filters should be accepted.

For non auto-submit forms:

  • from and to/to1/duration should both be filled in.

For auto-submit forms:

  • if only from is filled in and to/to1/duration is empty, the duration is taken as 1; to is taken as from; or to1 is taken as from + 1.
  • if only to is filled in, from is taken as to
  • if only to1 is filled in, from is taken as to1 - 1
  • if only duration is filled in, we validated as correct but do not accept the exposed input.

Parameters

array $input:

Return value

bool

Overrides views_handler_filter::accept_exposed_input

File

views/availability_calendar_handler_filter_availability.inc, line 537

Class

availability_calendar_handler_filter_availability
Views handler to filter on availability.

Code

public function accept_exposed_input($input) {
  if (empty($this->options['exposed'])) {
    return TRUE;
  }
  if (!empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id']) && isset($input[$this->options['expose']['operator_id']])) {

    // Fetch operator from form (instead of from $this object)
    $this->operator = $input[$this->options['expose']['operator_id']];
  }
  if (!empty($this->options['expose']['identifier'])) {

    // Fetch values from form (instead of from $this object).
    $this->value = $input[$this->options['expose']['identifier']];
    $operators = $this
      ->operators();
    $values = $operators[$this->operator]['values'];

    // Get valid or emptied value for from.
    $from =& $this
      ->getValidOrEmptyValue($this->value[$values[0]], $values[0]);
    if (count($values) === 1) {
      return !empty($from);
    }
    else {

      // Get valid or emptied value for other value (to/to1/duration).
      $other =& $this
        ->getValidOrEmptyValue($this->value[$values[1]], $values[1]);

      // Try to fill an empty value based on the value of the other operand.
      if ($this->autoSubmit) {
        $this
          ->fillEmptyValueFromOther($from, $other, $values[1]);
      }

      // We can now accept the exposed input if both values are not empty.
      return !empty($from) && !empty($other);
    }
  }
  return TRUE;
}