You are here

function merci_create_cck_fields in MERCI (Manage Equipment Reservations, Checkout and Inventory) 6.2

Same name and namespace in other branches
  1. 7.2 merci.install \merci_create_cck_fields()
3 calls to merci_create_cck_fields()
merci_enable in ./merci.install
Implementation of hook_enable().
merci_update_5 in ./merci.install
merci_update_6201 in ./merci.install

File

./merci.install, line 813
merci Installer / Uninstaller

Code

function merci_create_cck_fields() {

  // Create the date, commercial_total, and member_total fields for the reservation.
  $short_date_format = variable_get('date_format_short', 'm/d/Y - H:i');
  $date_only_format = substr($short_date_format, 0, 5);

  // Create the date, commercial_total, and member_total fields for the reservation.
  $merci_reservation_fields = array(
    array(
      'field_name' => 'field_merci_date',
      'type_name' => 'merci_reservation',
      'display_settings' => array(
        'label' => array(
          'format' => 'above',
          'exclude' => 0,
        ),
        'teaser' => array(
          'format' => 'default',
          'exclude' => 0,
        ),
        'full' => array(
          'format' => 'default',
          'exclude' => 0,
        ),
        4 => array(
          'format' => 'default',
          'exclude' => 0,
        ),
      ),
      'widget_active' => '1',
      'type' => 'datetime',
      'required' => '1',
      'multiple' => '0',
      'db_storage' => '1',
      'module' => 'date',
      'active' => '1',
      'locked' => '1',
      'columns' => array(
        'value' => array(
          'type' => 'datetime',
          'not null' => FALSE,
          'sortable' => TRUE,
        ),
        'value2' => array(
          'type' => 'datetime',
          'not null' => FALSE,
          'sortable' => TRUE,
        ),
      ),
      'granularity' => array(
        'year' => 'year',
        'month' => 'month',
        'day' => 'day',
        'hour' => 'hour',
        'minute' => 'minute',
      ),
      'timezone_db' => 'UTC',
      'tz_handling' => 'site',
      'todate' => 'required',
      'repeat' => 0,
      'repeat_collapsed' => '',
      'output_format_date' => $short_date_format,
      'output_format_custom' => '',
      'output_format_date_long' => $date_only_format,
      'output_format_custom_long' => '',
      'output_format_date_medium' => $date_only_format,
      'output_format_custom_medium' => '',
      'output_format_date_short' => $date_only_format,
      'output_format_custom_short' => '',
      'widget' => array(
        'default_value' => 'blank',
        'default_value_code' => '',
        'default_value2' => 'same',
        'default_value_code2' => '',
        'input_format' => $short_date_format,
        'input_format_custom' => '',
        'increment' => '15',
        'text_parts' => array(),
        'year_range' => '-3:+3',
        'label_position' => 'above',
        'label' => 'Reservation',
        'weight' => '-1',
        'description' => 'Select the start and end times for your reservation.',
        'type' => 'date_popup',
        'module' => 'date',
      ),
    ),
  );

  // Need to load the CCK include file where content_field_instance_create() is defined.
  module_load_include('inc', 'content', 'includes/content.crud');
  foreach ($merci_reservation_fields as $field) {

    // Create the fields
    if (!content_field_instance_read(array(
      'field_name' => $field['field_name'],
    ), TRUE)) {
      content_field_instance_create($field, FALSE);
      if (array_key_exists('group', $field)) {
        fieldgroup_update_fields($field);
      }
    }
  }

  // Clear caches and rebuild menu.
  content_clear_type_cache(TRUE);
  menu_rebuild();
}