1 translation.module translation_node_update(Node $node)

Implements hook_node_update().

File

core/modules/translation/translation.module, line 408
Manages content translations.

Code

function translation_node_update(Node $node) {
  // Only act if we are dealing with a content type supporting translations.
  if (translation_supported_type($node->type)) {
    if (isset($node->translation) && $node->translation && !empty($node->langcode) && $node->tnid) {
      // Update translation information.
      db_update('node')
        ->fields(array(
          'tnid' => $node->tnid,
          'translate' => $node->translation['status'],
        ))
        ->condition('nid', $node->nid)
        ->execute();

      if (!empty($node->translation['retranslate'])) {
        // This is the source node, asking to mark all translations outdated.
        $translations = db_select('node', 'n')
          ->fields('n', array('nid'))
          ->condition('nid', $node->nid, '<>')
          ->condition('tnid', $node->tnid)
          ->execute()
          ->fetchCol();

        db_update('node')
          ->fields(array('translate' => 1))
          ->condition('nid', $translations, 'IN')
          ->execute();

        // Flush the modified translation nodes from the load cache.
        entity_get_controller('node')->resetCache($translations);
      }
    }
  }
}