You are here

function party_log_install in Party 7

Implements hook_install().

File

modules/party_log/party_log.install, line 10
Install hooks for the Party Logging module.

Code

function party_log_install() {
  $t = get_t();
  if (!field_info_instance('message_type', MESSAGE_FIELD_MESSAGE_TEXT, 'party_log')) {
    $instance = array(
      'field_name' => MESSAGE_FIELD_MESSAGE_TEXT,
      'bundle' => 'party_log',
      'entity_type' => 'message_type',
      'label' => $t('Message text'),
      'description' => $t('This is the text of all messages of this type.'),
      'required' => TRUE,
      'settings' => array(
        'text_processing' => 1,
      ),
    );
    field_create_instance($instance);
  }

  // Add a field for the other parties.
  if (!field_info_field('other_party')) {
    $field = array(
      'field_name' => 'other_party',
      'type' => 'entityreference',
      'cardinality' => 1,
      'settings' => array(
        'target_type' => 'party',
        'handler' => 'base',
        'handler_settings' => array(
          'sort' => array(
            'type' => 'none',
          ),
        ),
      ),
    );
    field_create_field($field);
  }
  foreach (array(
    'party_merged_into',
    'party_had_other_merged_in',
  ) as $bundle) {
    if (!field_info_instance('message', 'other_party', $bundle)) {
      $instance = array(
        'field_name' => 'other_party',
        'entity_type' => 'message',
        'bundle' => $bundle,
        'label' => t('Other Party'),
        'required' => TRUE,
        'settings' => array(
          'default_value' => '',
        ),
        'widget' => array(
          'type' => 'entityreference_autocomplete',
          'settings' => array(
            'size' => '60',
            'match_operator' => 'CONTAINS',
          ),
        ),
      );
      field_create_instance($instance);
    }
  }
}