You are here

function availability_calendar_install in Availability Calendars 7.5

Same name and namespace in other branches
  1. 7.3 availability_calendar.install \availability_calendar_install()
  2. 7.4 availability_calendar.install \availability_calendar_install()

Implements hook_install(). @link http://api.drupal.org/api/drupal/modules--system--system.api.php/functio...

File

./availability_calendar.install, line 136

Code

function availability_calendar_install() {
  $t = get_t();

  // Fill schema: add a default set of states to the database.
  $states = array(
    array(
      'sid' => 1,
      'css_class' => 'cal-nc',
      'label' => 'Not communicated',
      'weight' => 1,
      'is_available' => 0,
    ),
    array(
      'sid' => 2,
      'css_class' => 'cal-av',
      'label' => 'Available',
      'weight' => 2,
      'is_available' => 1,
    ),
    array(
      'sid' => 3,
      'css_class' => 'cal-na',
      'label' => 'Fully booked',
      'weight' => 3,
      'is_available' => 0,
    ),
    array(
      'sid' => 4,
      'css_class' => 'cal-opt',
      'label' => 'Provisionally booked',
      'weight' => 4,
      'is_available' => 0,
    ),
  );

  // Keep localize.drupal.org satisfied.
  if (FALSE) {
    t('Not Communicated');
    t('Available');
    t('Fully booked');
    t('Provisionally booked');
  }
  foreach ($states as $state) {
    db_insert('availability_calendar_state')
      ->fields($state)
      ->execute();
  }

  // Define a set of default style settings.
  variable_set('availability_calendar_styles_generate', 1);
  $styles = array(
    'table' => array(
      'font-size' => 'smaller',
      'color' => '#000000',
      'background-color' => '',
      'border-width' => '1px',
      'border-color' => '#000000',
    ),
    'caption' => array(
      'font-weight' => 'bold',
      'font-style' => 'inherit',
      'font-size' => 'smaller',
    ),
    'header' => array(
      'height' => '',
      'font-weight' => 'bold',
      'font-style' => 'inherit',
      'font-size' => 'inherit',
      'text-align' => 'center',
    ),
    'week_notes' => array(
      'width' => '90px',
    ),
    'days' => array(
      'width' => '28px',
      'height' => '28px',
      'text-align' => 'center',
      'vertical-align' => 'middle',
    ),
    'states' => array(
      'split-day' => '/',
    ),
  );

  // Fill default states
  $styles['states']['cal-nc'] = '#909090';
  $styles['states']['cal-av'] = '#90ee90';
  $styles['states']['cal-na'] = '#ffb6c1';
  $styles['states']['cal-opt'] = '#ffffe0';
  variable_set('availability_calendar_styles', $styles);
  module_load_include('inc', 'availability_calendar', 'availability_calendar.styles');
  availability_calendar_styles_generate();
  $link = l($t('Availability Calendar') . ' ' . $t('Settings'), 'admin/config/content/availability-calendar/settings');
  drupal_set_message($t("Please visit the '!link' page to define the set of availability states.", array(
    '!link' => $link,
  )), 'warning');
  $link = l($t('Availability Calendar') . ' ' . $t('Styling'), 'admin/config/content/availability-calendar/styling');
  drupal_set_message($t("Please visit the '!link' page to generate your own custom CSS file for Availability Calendar.", array(
    '!link' => $link,
  )), 'warning');
  $link1 = l($t('Date and time'), 'admin/config/regional/date-time');
  $link2 = l($t('Date and time') . ' - ' . $t('Localize'), 'admin/config/regional/date-time/locale');
  drupal_set_message($t("Please visit the '!link1' and !link2 pages to define date formats for Availability Calendar.", array(
    '!link1' => $link1,
    '!link2' => $link2,
  )), 'warning');
}