You are here

function add_cost_fields_and_group_taxonomy in MERCI (Manage Equipment Reservations, Checkout and Inventory) 6

2 calls to add_cost_fields_and_group_taxonomy()
merci_enable in ./merci.install
Implementation of hook_enable().
merci_update_5 in ./merci.install

File

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

Code

function add_cost_fields_and_group_taxonomy() {
  $member_cost_field = array(
    'label' => 'Member Cost',
    'field_name' => 'field_merci_member_cost',
    'type_name' => 'merci_reservation',
    'type' => 'number_integer',
    'widget_type' => 'number',
    'change' => 'Change basic information',
    'weight' => 0,
    'locked' => '1',
    'description' => '',
    'default_value' => array(
      0 => array(
        'value' => '',
        '_error_element' => 'default_value_widget][field_merci_member_cost][0][value',
      ),
    ),
    'default_value_php' => '',
    'default_value_widget' => NULL,
    'group' => false,
    'required' => 0,
    'multiple' => '0',
    'min' => '',
    'max' => '',
    'prefix' => '',
    'suffix' => '',
    'allowed_values' => '',
    'allowed_values_php' => '',
    'op' => 'Save field settings',
    'module' => 'number',
    'widget_module' => 'number',
    'columns' => array(
      'value' => array(
        'type' => 'int',
        'not null' => false,
        'sortable' => true,
      ),
    ),
    'display_settings' => array(
      'weight' => 0,
      'parent' => '',
      'label' => array(
        'format' => 'above',
      ),
      'teaser' => array(
        'format' => 'default',
        'exclude' => 1,
      ),
      'full' => array(
        'format' => 'default',
        'exclude' => 1,
      ),
      4 => array(
        'format' => 'default',
        'exclude' => 0,
      ),
      'token' => array(
        'format' => 'default',
        'exclude' => 0,
      ),
    ),
  );
  $commerical_cost_field = array(
    'label' => 'Commercial Cost',
    'field_name' => 'field_merci_commercial_cost',
    'type_name' => 'merci_reservation',
    'type' => 'number_integer',
    'widget_type' => 'number',
    'change' => 'Change basic information',
    'weight' => '1',
    'locked' => '1',
    'description' => '',
    'default_value' => array(
      0 => array(
        'value' => '',
        '_error_element' => 'default_value_widget][field_merci_commercial_cost][0][value',
      ),
    ),
    'default_value_php' => '',
    'default_value_widget' => NULL,
    'group' => false,
    'required' => 0,
    'multiple' => '0',
    'min' => '',
    'max' => '',
    'prefix' => '',
    'suffix' => '',
    'allowed_values' => '',
    'allowed_values_php' => '',
    'op' => 'Save field settings',
    'module' => 'number',
    'widget_module' => 'number',
    'columns' => array(
      'value' => array(
        'type' => 'int',
        'not null' => false,
        'sortable' => true,
      ),
    ),
    'display_settings' => array(
      'weight' => '1',
      'parent' => '',
      'label' => array(
        'format' => 'above',
      ),
      'teaser' => array(
        'format' => 'default',
        'exclude' => 1,
      ),
      'full' => array(
        'format' => 'default',
        'exclude' => 1,
      ),
      4 => array(
        'format' => 'default',
        'exclude' => 0,
      ),
      'token' => array(
        'format' => 'default',
        'exclude' => 0,
      ),
    ),
  );

  // Need to load the CCK include file where content_field_instance_create() is defined.
  module_load_include('inc', 'content', 'includes/content.crud');

  // Create the field.
  content_field_instance_create($commerical_cost_field);
  content_field_instance_create($member_cost_field);

  // borrowed from Forum module
  // Create the forum vocabulary if it does not exist. Assign the vocabulary
  // a low weight so it will appear first in forum topic create and edit
  // forms.
  $vocabulary = array(
    'name' => t('MERCI Equipment Grouping'),
    'multiple' => 0,
    'required' => 0,
    'hierarchy' => 0,
    'relations' => 0,
    'module' => 'merci',
    'weight' => -10,
  );
  taxonomy_save_vocabulary($vocabulary);
  variable_set('merci_equipment_grouping_vid', $vocabulary['vid']);
}