You are here

public function AvailabilityAgentSingleUnitFilter::applyFilter in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

Applies the filter operation to the units in the filter.

Return value

array|int Rooms remaining after the filter, error code otherwise.

Overrides AvailabilityAgentFilterInterface::applyFilter

File

modules/rooms_booking/includes/rooms_booking.availability_agent_filter.inc, line 279
Rooms Booking agent filter interfaces and base implementations.

Class

AvailabilityAgentSingleUnitFilter
Filter units by unit id.

Code

public function applyFilter() {
  if (variable_get('rooms_presentation_style') == ROOMS_INDIVIDUAL && isset($_GET['rooms_id']) && ($requested_unit = rooms_unit_load($_GET['rooms_id']))) {
    foreach ($this->units as $unit) {
      if ($unit->unit_id != $requested_unit->unit_id) {
        unset($this->units[$unit->unit_id]);
      }
    }
    if (empty($this->units)) {
      drupal_set_message(t('Unfortunately @unit_name is not available - try other dates if possible', array(
        '@unit_name' => $requested_unit->name,
      )), 'warning');
    }
  }
  return $this->units;
}