--- taxonomy_manager.admin.inc 2009-09-05 16:09:41.000000000 +0600 +++ taxonomy_manager.admin.inc 2009-12-19 00:57:40.000000000 +0500 @@ -2127,6 +2136,41 @@ //TODO: add hook, so that other modules can consider changes foreach ($merging_terms as $merge_term) { if ($merge_term != $main_term) { + // If path_redirect is installed and 'merge_redirect' option is set, + // create redirects for the old URL. + if (module_exists('path_redirect') && $options['merge_redirect']) { + // Redirect the old base URL. + $redirect = array( + 'source' => 'taxonomy/term/' . $merge_term, + 'redirect' => 'taxonomy/term/' . $main_term, + ); + path_redirect_save($redirect); + // Redirect any optional URL aliases. + $aliases = db_query("SELECT dst FROM {url_alias} WHERE src='%s'", $redirect['source']); + while ($alias = db_fetch_object($aliases)) { + // Want to make sure we're inserting a new record. + unset($redirect['rid']); + // The old destination is the new source path. + $redirect['source'] = $alias->dst; + // Save the new redirect. + path_redirect_save($redirect); + } + // Cleanup any old path_redirect recordss + $aliases = db_query("SELECT rid, source FROM {path_redirect} WHERE redirect='%s'", $redirect['source']); + while ($alias = db_fetch_object($aliases)) { + // Make sure we're updating the correct record. + $redirect['rid'] = $alias->rid; + // The old path is the new source path. + $redirect['source'] = $alias->source; + // Save the new redirect. + path_redirect_save($redirect); + } + // Cleanup. + unset($alias); + unset($aliases); + unset($redirect); + } + //update node-relations $sql = db_query("SELECT * FROM {term_node} WHERE tid = %d", $merge_term); while ($obj = db_fetch_object($sql)) {