You are here

function lingotek_get_change_workflow_form_submit in Lingotek Translation 7.4

Same name and namespace in other branches
  1. 7.7 lingotek.module \lingotek_get_change_workflow_form_submit()
  2. 7.5 lingotek.module \lingotek_get_change_workflow_form_submit()
  3. 7.6 lingotek.module \lingotek_get_change_workflow_form_submit()
1 string reference to 'lingotek_get_change_workflow_form_submit'
lingotek_get_change_workflow_form in ./lingotek.module

File

./lingotek.module, line 1054

Code

function lingotek_get_change_workflow_form_submit($form, $form_state) {
  if (isset($form_state['nids']) && !empty($form_state['nids'])) {
    $nids = $form_state['nids'];
    $workflow_id = $form_state['values']['lingotek']['workflow_id'];
    if (isset($form_state['values']['lingotek']['prefill_phases_checkbox']) && $form_state['values']['lingotek']['prefill_phases_checkbox']) {
      $prefill_phase = $form_state['values']['lingotek']['prefill_phase_select'];
    }
    else {
      $prefill_phase = NULL;
    }

    // SUBMIT THE WORKFLOW CHANGES TO TMS
    $document_ids = LingotekSync::getDocIdsFromNodeIds($nids);
    if (!$document_ids) {
      return;
    }
    $api = LingotekApi::instance();
    $api
      ->changeWorkflow($document_ids, $workflow_id, $prefill_phase);

    // CREATE/UPDATE WORKFLOW ENTRIES IN THE LINGOTEK METADATA TABLE
    foreach ($nids as $nid) {
      lingotek_lingonode($nid, 'workflow_id', $workflow_id);
      LingotekSync::setAllTargetStatus($nid, LingotekSync::STATUS_PENDING);
    }
  }
}