You are here

function lingotek_delete_node_translations in Lingotek Translation 7.7

Delete translations for node based entities

Parameters

$nid The id of the source node:

1 call to lingotek_delete_node_translations()
lingotek_entity_delete_translations_form_submit in ./lingotek.bulk_grid.inc
Submit handler for the lingotek_entity_delete_translations form.

File

./lingotek.util.inc, line 2828
Utility functions.

Code

function lingotek_delete_node_translations($nid) {

  // Get the source node
  $source_node = lingotek_node_load_default($nid);
  $target_nids = lingotek_get_target_node_ids($nid);
  $target_statuses = LingotekSync::getAllTargetStatusForEntity('node', $nid);
  foreach ($target_nids as $target_nid) {
    entity_delete('node', $target_nid);
  }

  // If the status is current and the translations haven't been disassociated, set status to READY see INT-563
  foreach ($target_statuses as $langcode => $status) {
    if ($status == LingotekSync::STATUS_CURRENT && isset($source_node->lingotek['document_id'])) {
      LingotekSync::setTargetStatus('node', $nid, $langcode, LingotekSync::STATUS_READY);
    }
    else {
      LingotekSync::setTargetStatus('node', $nid, $langcode, LingotekSync::STATUS_DELETED);
    }
  }
}