You are here

function availability_calendars_form_alter in Availability Calendars 5

Same name and namespace in other branches
  1. 6.2 availability_calendars.module \availability_calendars_form_alter()
  2. 6 availability_calendars.module \availability_calendars_form_alter()

Implementation of hook_form_alter();

File

./availability_calendars.module, line 422
Availability Calendars Module

Code

function availability_calendars_form_alter($form_id, &$form) {
  global $user;

  // Alter node type form to allow availability support to be enabled/disabled
  if ($form_id == 'node_type_form') {
    $form['workflow']['availability_calendars'] = array(
      '#type' => 'radios',
      '#title' => t('Availability calendar support'),
      '#default_value' => variable_get('availability_calendars_' . $form['#node_type']->type, 0),
      '#options' => array(
        0 => t('Disabled'),
        1 => t('Enabled'),
      ),
      '#description' => t('Enable or disable availability support for this content type. If enabled, node owner will be able to specify node availability.'),
    );
  }
  elseif (isset($form['type']) && $form['type']['#value'] . '_node_form' == $form_id && availability_calendars_enabled($form['type']['#value'])) {
    $form['availability'] = array(
      '#type' => 'fieldset',
      '#title' => t('Availability calendar settings'),
    );
    $form['availability']['startofweek'] = array(
      '#type' => 'select',
      '#title' => t('First day of week'),
      '#default_value' => variable_get('availability_calendars_' . $form['nid']['#value'] . '_startofweek', 1),
      '#options' => array(
        6 => t('Monday'),
        5 => t('Tuesday'),
        4 => t('Wednesday'),
        3 => t('Thursday'),
        2 => t('Friday'),
        1 => t('Saturday'),
        0 => t('Sunday'),
      ),
    );
  }
}