You are here

function tmgmt_local_enable in Translation Management Tool 7

Implements hook_enable().

File

translators/tmgmt_local/tmgmt_local.install, line 229
Installation hooks for tmgmt_local module.

Code

function tmgmt_local_enable() {

  // If our field type is not found rebuild the cache.
  if (!field_info_field_types('tmgmt_language_combination')) {
    field_cache_clear();
  }

  // Create the language combination field if it doesn't exist yet.
  if (!field_info_field('tmgmt_translation_skills')) {
    $field = array(
      'type' => 'tmgmt_language_combination',
      'field_name' => 'tmgmt_translation_skills',
      'translatable' => FALSE,
      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
      'locked' => FALSE,
    );
    field_create_field($field);
  }

  // Attach the language skills field collection to the user entity.
  if (!field_info_instance('user', 'tmgmt_translation_skills', 'user')) {
    $instance = array(
      'field_name' => 'tmgmt_translation_skills',
      'entity_type' => 'user',
      'bundle' => 'user',
      'label' => t('Translation skills'),
    );
    field_create_instance($instance);
  }
}