public function UnitCalendar::eventBlocked in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7
Checks if an event is blocked, i.e. cannot be updated. This happens when the event id is in the rooms_booking_locks table and the new event_id is not the same as the one that is locked.
Parameters
BookingEventInterface $event: The event to check if it is blocked.
Return value
bool TRUE if blocked, FALSE otherwise.
Overrides UnitCalendarInterface::eventBlocked
1 call to UnitCalendar::eventBlocked()
- UnitCalendar::updateCalendar in modules/
rooms_availability/ includes/ rooms_availability.unit_calendar.inc - Given an array of RoomEvents the calendar is updated with regards to the events that are relevant to the Unit this calendar refers to
File
- modules/
rooms_availability/ includes/ rooms_availability.unit_calendar.inc, line 321 - Class UnitCalendar Handles querying and updating the availability information relative to a single bookable unit.
Class
- UnitCalendar
- @file Class UnitCalendar Handles querying and updating the availability information relative to a single bookable unit.
Code
public function eventBlocked(BookingEventInterface $event) {
$states = $this
->getStates($event->start_date, $event->end_date);
$blocked = FALSE;
// Query the locks table to see if event is blocked.
$query = db_select('rooms_booking_locks', 'l');
$query
->addField('l', 'unit_id');
$query
->addField('l', 'state');
$query
->addField('l', 'locked');
$query
->condition('l.unit_id', $this->unit_id);
$query
->condition('l.state', $states);
$query
->condition('l.locked', 1);
$result = $query
->execute()
->fetchAll(PDO::FETCH_ASSOC);
// Only block if we are trying to update an event that is not locked.
if (count($result) > 0 && $result[0]['state'] != $event->id) {
$blocked = TRUE;
}
return $blocked;
}