translation_remove_from_set

Versions
6 – 7
translation_remove_from_set($node)

Remove a node from its translation set (if any) and update the set accordingly.

Code

modules/translation/translation.module, line 253

<?php
function translation_remove_from_set($node) {
  if (isset($node->tnid)) {
    if (db_result(db_query('SELECT COUNT(*) FROM {node} WHERE tnid = %d', $node->tnid)) == 1) {
      // There is only one node left in the set: remove the set altogether.
      db_query('UPDATE {node} SET tnid = 0, translate = 0 WHERE tnid = %d', $node->tnid);
    }
    else {
      db_query('UPDATE {node} SET tnid = 0, translate = 0 WHERE nid = %d', $node->nid);

      // If the node being removed was the source of the translation set,
      // we pick a new source - preferably one that is up to date.
      if ($node->tnid == $node->nid) {
        $new_tnid = db_result(db_query('SELECT nid FROM {node} WHERE tnid = %d ORDER BY translate ASC, nid ASC', $node->tnid));
        db_query('UPDATE {node} SET tnid = %d WHERE tnid = %d', $new_tnid, $node->tnid);
      }
    }
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.