You are here

bat_api.module in Booking and Availability Management API 8

Same filename and directory in other branches
  1. 7.2 bat_api.module
  2. 7 bat_api.module

File

bat_api.module
View source
<?php

/**
 * Merge non blocking events so that we display them as a continuous single event.
 *
 * @param array $events
 *
 * @return array
 */
function bat_api_merge_non_blocking_events($events) {
  $prev_id = FALSE;
  foreach ($events as $id => $event) {
    if ($prev_id !== FALSE && isset($event['rendering']) && $event['rendering'] == 'background' && !$event['blocking']) {
      $last_event = $events[$prev_id];
      if (isset($last_event['rendering']) && $last_event['rendering'] == 'background' && !$last_event['blocking']) {
        if ($last_event['resourceId'] == $event['resourceId'] && $last_event['title'] == $event['title'] && $last_event['color'] == $event['color']) {
          $events[$prev_id]['end'] = $event['end'];
          unset($events[$id]);
          continue;
        }
      }
    }
    $prev_id = $id;
  }
  return $events;
}

Functions

Namesort descending Description
bat_api_merge_non_blocking_events Merge non blocking events so that we display them as a continuous single event.