You are here

function lingotek_config_disassociate_form_submit in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.6 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 3328

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();
  $set_ids = LingotekSync::getSetIdsFromLids($lids);
  $doc_ids = LingotekSync::getConfigDocIdsFromSetIds($set_ids);

  // Update the translation_agent_id in the locales_target table
  LingotekSync::updateLingotekTranslationAgentId($lids, LingotekSync::TRANSLATION_AGENT_ID_DRUPAL);

  //Deletes document data from lingotek_config_metadata table and lingotek_config_metadata table
  LingotekConfigSet::deleteConfigSetMetadataBySetId($set_ids);
  LingotekConfigSet::deleteConfigSetMapDataBySetId($set_ids);
  if (!empty($lids)) {
    LingotekConfigSet::disassociateSegments($lids);
  }
  $disassociated_config = '(Config ID\'s: ';
  for ($i = 0; $i < count($lids); $i++) {
    if ($i == count($lids) - 1) {
      $disassociated_config .= $lids[$i] . ')';
    }
    else {
      $disassociated_config .= $lids[$i] . ', ';
    }
  }
  drupal_set_message(format_plural(count($lids), 'Translations disassociated for one config item. ' . $disassociated_config, 'Translations disassociated for @count config items. ' . $disassociated_config));
}