translation_node_insert
function translation_node_insert
translation_node_insert($node)
Implements hook_node_insert().
File
- modules/translation/translation.module, line 323
- Manages content translations.
Code
function translation_node_insert($node) { // Only act if we are dealing with a content type supporting translations. if (translation_supported_type($node->type)) { if (!empty($node->translation_source)) { if ($node->translation_source->tnid) { // Add node to existing translation set. $tnid = $node->translation_source->tnid; } else { // Create new translation set, using nid from the source node. $tnid = $node->translation_source->nid; db_update('node') ->fields(array( 'tnid' => $tnid, 'translate' => 0, )) ->condition('nid', $tnid) ->execute(); // Flush the (untranslated) source node from the load cache. entity_get_controller('node')->resetCache(array($tnid)); } db_update('node') ->fields(array( 'tnid' => $tnid, 'translate' => 0, )) ->condition('nid', $node->nid) ->execute(); // Save tnid to avoid loss in case of resave. $node->tnid = $tnid; } } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!translation!translation.module/function/translation_node_insert/7.x