You are here

function lingotek_config_disassociate_form_submit in Lingotek Translation 7.6

Same name and namespace in other branches
  1. 7.7 lingotek.bulk_grid.inc \lingotek_config_disassociate_form_submit()
1 string reference to 'lingotek_config_disassociate_form_submit'
lingotek_entity_disassociate_form in ./lingotek.bulk_grid.inc
Form constructor for the entity disassociate form. (Formerly "Reset Translations")

File

./lingotek.bulk_grid.inc, line 2250

Code

function lingotek_config_disassociate_form_submit($form, $form_state) {
  if (isset($form_state['values']['entity_ids'])) {
    $lids = json_decode($form_state['values']['entity_ids']);
  }
  elseif (isset($form_state['lids'])) {
    $lids = json_decode($form_state['entity_ids']);
  }
  $api = LingotekApi::instance();
  $remove_from_tms = $form_state['values']['confirm'];
  $set_ids = LingotekSync::getSetIdsFromLids($lids);
  $doc_ids = LingotekSync::getConfigDocIdsFromSetIds($set_ids);
  if ($remove_from_tms) {

    //disassociate on TMS
    $result = lingotek_batch_disassociate_content_worker($api, $doc_ids);

    //Deletes document data from lingotek_config_metadata table
    $query1 = db_delete('lingotek_config_metadata')
      ->condition('id', $set_ids)
      ->execute();
    $query2 = db_delete('lingotek_config_map')
      ->condition('set_id', $set_ids)
      ->execute();
    if (!$result) {
      drupal_set_message(t('Failed to remove documents from Lingotek TMS.'), 'warning', FALSE);
      return;
    }
  }
  if (!empty($lids)) {
    LingotekConfigSet::disassociateSegments($lids);
  }
}