diff --git a/taxonomy_manager.admin.inc b/taxonomy_manager.admin.inc index d768cc9..af315a5 100644 --- a/taxonomy_manager.admin.inc +++ b/taxonomy_manager.admin.inc @@ -610,13 +610,30 @@ function taxonomy_manager_term_merge_form(&$form, $voc) { '#autocomplete_path' => 'taxonomy_manager/autocomplete/' . $voc->vid, ); - $form['term_merge']['options'] = array( - '#type' => 'checkboxes', - '#title' => t('Options'), - '#options' => array( - 'keep_merged' => t('Keep merged terms'), - ), - ); + // Due to an error in naming convensions in Term Merge repository there was a + // 7.x-2.0-beta2 release, which in fact was from early 7.x-1.x version and as + // time was going by that release has falled far behind the actual 7.x-1.x + // branch, however, still there are a lot of folks, that use that old release + // of the module. This is the reason we check module's version here. + // TODO: remove this version checking once 7.x-2.0-beta2 becomes less popular. + // See https://drupal.org/node/2075133 for more details. + $term_merge = system_get_info('module', 'term_merge'); + if ($term_merge['version'] != '7.x-2.0-beta2') { + // We delegate the generation of merge options to Term Merge module, since + // the latter has a specially designed function for those purposes. + $form['term_merge']['options'] = term_merge_merge_options_elements($voc); + } + else { + // In 7.x-2.0-beta2 the special function for merge options does not exist, + // so we just generate it here. + $form['term_merge']['options'] = array( + '#type' => 'checkboxes', + '#title' => t('Options'), + '#options' => array( + 'keep_merged' => t('Keep merged terms'), + ), + ); + } $form['term_merge']['submit'] = array( '#type' => 'submit', @@ -1605,7 +1622,24 @@ function taxonomy_manager_form_term_merge_submit($form, $form_state) { } $term_names = implode($term_names_array, ', '); if (module_exists('term_merge')) { - term_merge($selected_tids, $dest_term->tid, $form_state['values']['term_merge']['options']['keep_merged']); + // Due to an error in naming convensions in Term Merge repository there was + // a 7.x-2.0-beta2 release, which in fact was from early 7.x-1.x version and + // as time was going by that release has falled far behind the actual + // 7.x-1.x branch, however, still there are a lot of folks, that use that + // old release of the module. This is the reason we check module's version + // here. + // TODO: remove this version checking once 7.x-2.0-beta2 becomes less popular. + // See https://drupal.org/node/2075133 for more details. + $term_merge = system_get_info('module', 'term_merge'); + if ($term_merge['version'] != '7.x-2.0-beta2') { + // Using a new signature of term_merge() function. + $merge_settings = term_merge_merge_options_submit($form['term_merge']['options'], $form_state, $form); + term_merge($selected_tids, $dest_term->tid, $merge_settings); + } + else { + // Using old signature of term_merge() function. + term_merge($selected_tids, $dest_term->tid, $form_state['values']['term_merge']['options']['keep_merged']); + } drupal_set_message(t("Terms %term_names merged into %dest_term", array('%term_names' => $term_names, '%dest_term' => $dest_term->name))); } else {