You are here

function lingotek_node_delete in Lingotek Translation 6

Same name and namespace in other branches
  1. 7.7 lingotek.module \lingotek_node_delete()
  2. 7.2 lingotek.module \lingotek_node_delete()
  3. 7.3 lingotek.module \lingotek_node_delete()
  4. 7.4 lingotek.module \lingotek_node_delete()
1 call to lingotek_node_delete()
lingotek_nodeapi in ./lingotek.module

File

./lingotek.module, line 254

Code

function lingotek_node_delete($node) {
  global $_lingotek_client, $_lingotek_locale;

  //Handle cleanup of target languages

  //Node is the source language, so no need to remove a target language.
  $tnid = lingotek_lingonode($node->nid, 'tnid');
  if ($tnid) {
    $doc_id = lingotek_lingonode($tnid, 'document_id');
    $output = $_lingotek_client
      ->request('getDocument', array(
      'documentId' => $doc_id,
    ));
    if ($output->results == "success") {
      foreach ($output->translationTargets as $target) {
        if ($target->language == $_lingotek_locale[$node->language]) {
          $_lingotek_client
            ->request('removeTranslationTarget', array(
            'translationTargetId' => $target->id,
          ));
        }
      }
    }
  }
}