diff --git a/i18n_taxonomy/i18n_taxonomy.install b/i18n_taxonomy/i18n_taxonomy.install index d8b7894fe2c507cfe74009bd94a31810c915a714..75d55df9d9ec8368323839d5509ea5ae1ac39fdc 100644 --- a/i18n_taxonomy/i18n_taxonomy.install +++ b/i18n_taxonomy/i18n_taxonomy.install @@ -51,6 +51,39 @@ function i18n_taxonomy_schema_alter(&$schema) { $schema['taxonomy_term_data']['fields']['i18n_tsid'] = array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0); } +/** + * Implements hook_enable() + */ +function i18n_taxonomy_enable() { + // Change module assignment for fields in {field_config} table + // from 'taxonomy' to 'i18n_taxonomy', so i18n_taxonomy.module is + // handling all term reference fields + // (added to solve issue http://drupal.org/node/1078422) + foreach (field_info_fields() as $fieldname => $field) { + if (($field['type'] == 'taxonomy_term_reference') && ($field['module'] == 'taxonomy') && ($field['deleted'] == 0)) { + $field['module'] = 'i18n_taxonomy'; + field_update_field($field); + } + } +} + +/** + * Implements hook_disable() + */ +function i18n_taxonomy_disable() { + // Change module assignment for fields in {field_config} table + // from 'i18n_taxonomy' back to 'taxonomy', so taxonomy.module is + // handling all term reference fields again, and no such field is + // de-activated when i18n_taxonomy.module is disabled. + // (added to solve issue http://drupal.org/node/1078422) + foreach (field_info_fields() as $fieldname => $field) { + if (($field['type'] == 'taxonomy_term_reference') && ($field['module'] == 'i18n_taxonomy') && ($field['deleted'] == 0)) { + $field['module'] = 'taxonomy'; + field_update_field($field); + } + } +} + /** * Set vocabulary modes from D6 variable */