You are here

rooms_ui.module in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

Interface support to the Rooms family of modules.

File

rooms_ui.module
View source
<?php

/**
 * @file
 * Interface support to the Rooms family of modules.
 */

/**
 * Implements hook_menu().
 */
function rooms_ui_menu() {
  $items = array();

  // Top level "Rooms" container.
  $items['admin/rooms'] = array(
    'title' => 'Rooms',
    'description' => 'Administer Rooms.',
    'page callback' => 'system_admin_menu_block_page',
    'access arguments' => array(
      'access administration pages',
    ),
    'file path' => drupal_get_path('module', 'system'),
    'file' => 'system.admin.inc',
    'weight' => -7,
  );
  $items['admin/rooms/config'] = array(
    'title' => 'Configuration',
    'description' => 'Configure settings and business rules for Rooms management.',
    'page callback' => 'system_admin_menu_block_page',
    'access arguments' => array(
      'configure room settings',
    ),
    'type' => MENU_NORMAL_ITEM,
    'weight' => 10,
    'file path' => drupal_get_path('module', 'system'),
    'file' => 'system.admin.inc',
  );
  $items['admin/rooms/config/bookings'] = array(
    'title' => 'Booking Settings',
    'description' => 'Configure settings and business rules for Bookings.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'rooms_booking_settings',
    ),
    'access arguments' => array(
      'configure room settings',
    ),
    'type' => MENU_NORMAL_ITEM,
  );
  $items['admin/rooms/config/terminology'] = array(
    'title' => 'Rooms Terminology',
    'description' => 'Change Rooms Terminology',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'variable_group_form',
      'rooms',
    ),
    'access arguments' => array(
      'configure room settings',
    ),
  );
  return $items;
}

/**
 * Implements hook_page_build().
 */
function rooms_ui_page_build(&$page) {
  drupal_add_css(drupal_get_path('module', 'rooms_ui') . '/css/rooms_ui.css');
}

/**
 * Main booking settings form.
 */
function rooms_booking_settings($form, &$form_state) {

  // Management vertical tabs.
  $form['rooms_settings'] = array(
    '#type' => 'vertical_tabs',
    '#weight' => 99,
    '#attached' => array(
      'css' => array(
        array(
          'data' => '#rooms-booking-settings .vertical-tabs .form-type-textfield input { width: auto; }',
          'type' => 'inline',
        ),
      ),
    ),
  );
  $form['rooms_booking_settings'] = array(
    '#type' => 'fieldset',
    '#group' => 'rooms_settings',
    '#title' => t('Rooms booking settings'),
  );
  $form['rooms_booking_settings']['rooms_booking_start_date'] = array(
    '#type' => 'select',
    '#title' => t('How soon a booking can start'),
    '#description' => t('Users with the "Make same-day bookings" permission will not be affected by this setting.'),
    '#options' => array(
      '0' => t('Same day bookings'),
      '1' => t('1 day in advance'),
      '2' => t('@count days in advance', array(
        '@count' => 2,
      )),
      '3' => t('@count days in advance', array(
        '@count' => 3,
      )),
      '4' => t('@count days in advance', array(
        '@count' => 4,
      )),
      '5' => t('@count days in advance', array(
        '@count' => 5,
      )),
      '6' => t('@count days in advance', array(
        '@count' => 6,
      )),
      '7' => t('@count days in advance', array(
        '@count' => 7,
      )),
    ),
    '#default_value' => variable_get('rooms_booking_start_date', 1),
  );
  return system_settings_form($form);
}

/**
 * Implements hook_variable_info_alter().
 *
 * Group all rooms-related variables under a single 'rooms' group.
 * This simplifies access control and the Rooms Terminology form.
 */
function rooms_ui_variable_info_alter(&$info) {
  foreach ($info as $name => $variable) {
    if (0 === strpos($name, 'rooms_')) {
      $info[$name]['group'] = 'rooms';
    }
  }
}

Functions

Namesort descending Description
rooms_booking_settings Main booking settings form.
rooms_ui_menu Implements hook_menu().
rooms_ui_page_build Implements hook_page_build().
rooms_ui_variable_info_alter Implements hook_variable_info_alter().