You are here

function lingotek_entity_upload_triggered in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.5 lingotek.module \lingotek_entity_upload_triggered()
  2. 7.6 lingotek.module \lingotek_entity_upload_triggered()
1 call to lingotek_entity_upload_triggered()
lingotek_entity_save in ./lingotek.module

File

./lingotek.module, line 1673

Code

function lingotek_entity_upload_triggered($entity, $entity_type, $changed = TRUE, &$context = array()) {
  if ($entity->lingotek['profile'] == LingotekSync::PROFILE_DISABLED) {
    return;
  }
  if (isset($entity->lingotek_upload_override)) {
    if ($entity->lingotek_upload_override) {
      lingotek_entity_upload($entity, $entity_type);
    }
    return;
  }
  list($id, $vid, $bundle) = lingotek_entity_extract_ids($entity_type, $entity);
  if (!isset($entity->language) || !Lingotek::isSupportedLanguage($entity->language) && !($entity->language == LANGUAGE_NONE && $entity_type == 'taxonomy_term')) {
    return;
  }
  if (isset($entity->lingotek['upload_status']) && in_array($entity->lingotek['upload_status'], array(
    LingotekSync::STATUS_TARGET,
    LingotekSync::STATUS_DELETED,
  ))) {
    return;
  }
  if ($entity_type == 'node' && !empty($entity->tnid) && $entity->nid != $entity->tnid) {

    //check to make sure it is not a target node
    return;
  }
  if (!$changed && isset($entity->lingotek['upload_status']) && is_already_uploaded($entity)) {
    return;

    //entity has no changes.
  }
  if ($changed && isset($entity->lingotek['document_id'])) {
    LingotekSync::setUploadStatus($entity_type, $id, LingotekSync::STATUS_EDITED);
  }
  if (!isset($entity->lingotek['document_id']) && isset($entity->lingotek['upload_status']) && $entity->lingotek['upload_status'] !== LingotekSync::STATUS_ERROR) {
    LingotekSync::setUploadStatus($entity_type, $id, LingotekSync::STATUS_NONE);
  }
  if (isset($entity->lingotek['auto_upload']) && $entity->lingotek['auto_upload']) {
    lingotek_entity_upload($entity, $entity_type, $context);
  }
}