You are here

function lingotek_get_change_workflow_form_submit in Lingotek Translation 7.6

Same name and namespace in other branches
  1. 7.7 lingotek.module \lingotek_get_change_workflow_form_submit()
  2. 7.4 lingotek.module \lingotek_get_change_workflow_form_submit()
  3. 7.5 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 1181

Code

function lingotek_get_change_workflow_form_submit($form, $form_state) {
  if (!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
    $entity_type = $form_state['entity_type'];
    $document_ids = LingotekSync::getDocIdsFromEntityIds($entity_type, $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_keystore($entity_type, $nid, 'workflow_id', $workflow_id);
      LingotekSync::setAllTargetStatus($entity_type, $nid, LingotekSync::STATUS_PENDING);
    }
  }
}