You are here

function lingotek_entity_change_workflow in Lingotek Translation 7.7

Changes an entity's workflow locally and on the TMS

Parameters

string $entity_type: The entity type

array $entity_ids: The entity id

2 calls to lingotek_entity_change_workflow()
lingotek_get_change_workflow_form_submit in ./lingotek.module
lingotek_rules_entity_change_workflow in ./lingotek.rules.inc

File

./lingotek.module, line 1265

Code

function lingotek_entity_change_workflow($entity_type, $entity_ids, $workflow_id, $prefill_phase = NULL) {
  $document_ids = $entity_type !== 'config' ? LingotekSync::getDocIdsFromEntityIds($entity_type, $entity_ids) : LingotekSync::getConfigDocIdsFromSetIds($entity_ids);
  if ($entity_type === 'config') {
    foreach ($entity_ids as $id) {
      LingotekSync::updateConfigSetWorkflow($id, $workflow_id);
    }
  }
  if (!$document_ids) {
    return;
  }

  // TODO: this should really be a batch that runs after the modal screen closes.
  drupal_set_time_limit(0);
  $api = LingotekApi::instance();
  $api
    ->changeWorkflow($document_ids, $workflow_id, $prefill_phase);

  // CREATE/UPDATE WORKFLOW ENTRIES IN THE LINGOTEK METADATA TABLE
  if ($entity_type === 'config') {
    LingotekSync::bulkSetAllTargetStatus($entity_type, $entity_ids, LingotekSync::STATUS_PENDING);
    return;
  }
  LingotekSync::bulkSetAllTargetStatus($entity_type, $entity_ids, LingotekSync::STATUS_PENDING);
  foreach ($entity_ids as $id) {
    lingotek_keystore($entity_type, $id, 'workflow_id', $workflow_id);
  }
}