You are here

function merci_load_hours_of_operation in MERCI (Manage Equipment Reservations, Checkout and Inventory) 6

Same name and namespace in other branches
  1. 6.2 includes/api.inc \merci_load_hours_of_operation()
  2. 7.2 includes/api.inc \merci_load_hours_of_operation()

Builds an array representing the hours of operation for the facility.

Return value

An associative array with the following key/value pairs: [php_day_of_week_number_as_in_date_function] => An associative array with the following key/values pairs: 'open' => Opening time (military). 'close' => Closing time (military). 'closed_days' => An array of closed dates in mm-dd format.

2 calls to merci_load_hours_of_operation()
merci_check_content_type_restrictions in ./merci.module
merci_node_validate in ./merci.module
Implementation of hook_validate().

File

./merci.module, line 2575
MERCI - Managed Equipment Reservation Checkout and Inventory

Code

function merci_load_hours_of_operation($content_type = '') {
  $days_of_the_week = array(
    'sun',
    'mon',
    'tue',
    'wed',
    'thu',
    'fri',
    'sat',
  );
  if (!empty($content_type)) {
    $rules = merci_content_type_rules($content_type);
  }
  $hours_of_operation = array();
  foreach ($days_of_the_week as $num => $day) {
    $hours = variable_get("merci_hours_{$day}", '');
    if (drupal_strlen($hours) == 11) {
      $parts = explode('-', $hours);
      if (count($parts == 2)) {
        $hours_of_operation[$num] = array(
          'open' => $parts[0],
          'close' => $parts[1],
        );
      }
      else {
        $hours_of_operation[$num] = FALSE;
      }
    }
    else {
      $hours_of_operation[$num] = FALSE;
    }
  }
  $closed_days_raw = variable_get('merci_closed_dates', '');
  $hours_of_operation['closed_days'] = array();
  $parts = explode("\n", $closed_days_raw);
  foreach ($parts as $date) {
    $date = trim($date);
    if (drupal_strlen($date) == 5) {
      $hours_of_operation['closed_days'][] = $date;
    }
  }
  return $hours_of_operation;
}