You are here

function taxonomy_manager_add_translation in Taxonomy Manager 6.2

Same name and namespace in other branches
  1. 7 taxonomy_manager.admin.inc \taxonomy_manager_add_translation()

adds translation between two terms

2 calls to taxonomy_manager_add_translation()
taxonomy_manager_doube_tree_edit_translate in ./taxonomy_manager.admin.inc
taxonomy_manager_term_data_edit in ./taxonomy_manager.admin.inc
callback handler for updating term data

File

./taxonomy_manager.admin.inc, line 1978
Taxonomy Manager Admin

Code

function taxonomy_manager_add_translation($tid1, $tid2) {
  $trid1 = db_result(db_query("SELECT trid FROM {term_data} WHERE tid = %d", $tid1));
  $trid2 = db_result(db_query("SELECT trid FROM {term_data} WHERE tid = %d", $tid2));
  if ($trid1 == 0 && $trid2 == 0) {
    $trid = (int) db_result(db_query('SELECT max(trid) FROM {term_data}')) + 1;
    db_query('UPDATE {term_data} SET trid = %d WHERE tid = %d OR tid = %d', $trid, $tid1, $tid2);
  }
  else {
    if ($trid1 != 0 && $trid2 == 0) {
      db_query('UPDATE {term_data} SET trid = %d WHERE tid = %d', $trid1, $tid2);
    }
    else {
      if ($trid2 != 0 && $trid1 == 0) {
        db_query('UPDATE {term_data} SET trid = %d WHERE tid = %d', $trid2, $tid1);
      }
      else {
        $trid = max($trid1, $trid2);
        db_query('UPDATE {term_data} SET trid = %d WHERE trid = %d OR trid = %d', $trid, $trid1, $trid2);
      }
    }
  }
}