You are here

function party_log_update_7002 in Party 7

Add a field for the storing of the other party.

File

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

Code

function party_log_update_7002() {

  // 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);
    }
  }
}