You are here

function lingotek_workbench_moderation_transition in Lingotek Translation 7.4

Same name and namespace in other branches
  1. 7.3 lingotek.module \lingotek_workbench_moderation_transition()

Implements hook_workbench_moderation_transition()

Upload content automatically only if new state corresponds auto-upload workbench_moderation variables Otherwise override upload

1 call to lingotek_workbench_moderation_transition()
lingotek_node_update in ./lingotek.module
Implements hook_node_update().

File

./lingotek.module, line 1836

Code

function lingotek_workbench_moderation_transition($node, $old_state, $new_state) {

  //Do not run unless this node has been properly loaded.
  if (!isset($node->lingotek) || !array_key_exists('document_id', $node->lingotek)) {
    return;
  }

  // Check global and node-specific settings
  // if this node is managed by lingotek, add lingotek wb variables
  if (isset($node->lingotek_push_once) && $node->lingotek_push_once || lingotek_node_pushed($node) || isset($node->is_new) || !lingotek_managed_by_entity_translation($node->type)) {
    $def_state = $node->lingotek['create_lingotek_document_workbench_moderation'];
    $states = lingotek_get_workbench_moderation_states();

    // do not change status updates if only moderated (no node_save called)
    if (!isset($node->workbench_moderation_state_new)) {
      $node->skip_status_updates = TRUE;
    }

    //    // set lingonode variable for workbench moderation auto-upload
    //    if (isset($node->create_lingotek_document_workbench_moderation)) {
    //      lingotek_lingonode($node->nid, 'create_lingotek_document_workbench_moderation', $node->create_lingotek_document_workbench_moderation);
    //      $def_state = $node->create_lingotek_document_workbench_moderation;
    //    }
    //    // set lingonode variable for workbench moderation auto-download setting
    //    if (isset($node->syncMethod_wb)) {
    //      lingotek_lingonode($node->nid, 'sync_method_workbench_moderation', $node->syncMethod_wb);
    //    }
    if ($old_state == workbench_moderation_state_published() && $new_state != workbench_moderation_state_published()) {

      // if changing from published
      $node->status = 0;

      // unpublish
      node_save($node);
    }

    // Check new state against settings
    if ($new_state != $states[$def_state]) {

      // && !isset($node->is_new)) {
      $node->lingotek_upload_override = 0;
    }
  }
  lingotek_upload_document($node);
}