You are here

date.install in Date 8

Same filename and directory in other branches
  1. 5 date.install
  2. 7.3 date.install
  3. 7 date.install
  4. 7.2 date.install

Install, update and uninstall functions for the Date module.

File

date.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the Date module.
 */

/**
 * Implements hook_field_schema().
 */
function date_field_schema($field) {
  switch ($field['settings']['todate']) {
    case '':
      $db_columns = array(
        'value' => array(
          'description' => 'The date value',
          'type' => 'varchar',
          'length' => 20,
          'not null' => FALSE,
        ),
        'data' => array(
          'description' => 'A serialized array with more date info.',
          'type' => 'text',
          'not null' => FALSE,
        ),
      );
      $indexes = array(
        'value' => 'value',
      );
      break;
    default:
      $db_columns = array(
        'value' => array(
          'description' => 'The start date value',
          'type' => 'varchar',
          'length' => 20,
          'not null' => FALSE,
        ),
        'value2' => array(
          'description' => 'The end date value',
          'type' => 'varchar',
          'length' => 20,
          'not null' => FALSE,
        ),
        'data' => array(
          'description' => 'A serialized array with more date info.',
          'type' => 'text',
          'not null' => FALSE,
        ),
      );
      $indexes = array(
        'value' => 'value',
        'value2' => 'value2',
      );
      break;
  }

  // If a second date is needed for 'End date', make a copy of the first one.
  // Timezone and offset columns are used only if date-specific dates are used.
  if (isset($field['settings']['tz_handling']) && $field['settings']['tz_handling'] == 'date') {
    $db_columns['offset'] = array(
      'type' => 'int',
      'not null' => FALSE,
    );
    if (!empty($field['settings']['todate'])) {
      $db_columns['offset2'] = array(
        'type' => 'int',
        'not null' => FALSE,
      );
    }
  }
  return array(
    'columns' => $db_columns,
    'indexes' => $indexes,
  );
}

/**
 * Implements hook_update_last_removed().
 */
function date_update_last_removed() {
  return 7004;
}

// @TODO Write upgrade path for text widgets to combine them with Popup widgets as new 'Datetime' widgets.
// @TOTO Write upgrade path for select widgets convert them to new 'Datelist' widgets.
// @TODO Write upgrade path for 'input_format' widget settings to create 'date_date_format' and 'date_time_format', date_date_element, date_time_element.
// @TODO Write upgrade path to remove 'input_format_custom'.
// @TODO Write upgrade path to remove datetime and datestamp storage methods and make all into iso.
// @TODO Removing custom formats that won't work in datepicker for consistency.
// @TODO Write upgrade path adding indexes, if not already set.
// @TODO Write upgrade path to add timezone, rrule, and all_day into new data column and delete rrule and timezone columns.

Functions

Namesort descending Description
date_field_schema Implements hook_field_schema().
date_update_last_removed Implements hook_update_last_removed().