You are here

function lingotek_workbench_redirect in Lingotek Translation 7.6

Same name and namespace in other branches
  1. 7.4 lingotek.page.inc \lingotek_workbench_redirect()
  2. 7.5 lingotek.page.inc \lingotek_workbench_redirect()
1 string reference to 'lingotek_workbench_redirect'
lingotek_menu in ./lingotek.module
Implements hook_menu().

File

./lingotek.page.inc, line 646
Lingotek Tab for Nodes

Code

function lingotek_workbench_redirect($entity_type, $entity_id, $lingotek_locale) {
  $drupal_language_code = Lingotek::convertLingotek2Drupal($lingotek_locale);
  if (module_exists('entitycache')) {
    cache_clear_all($entity_id, "cache_entity_{$entity_type}");
  }
  if ($entity_type == 'config') {

    // special-case handling of non-entity redirect
    $set_id = LingotekConfigSet::getSetId($entity_id);
    $doc_id = LingotekConfigSet::getDocId($set_id);
    $entity = (object) array(
      'id' => $entity_id,
      'lingotek' => array(
        'document_id' => $doc_id,
      ),
      'language' => 'placeholder for the config language',
    );
  }
  else {
    $entity = lingotek_entity_load_single($entity_type, $entity_id);
  }
  $ln = LingotekEntity::load($entity, $entity_type);
  if ($ln->language == $drupal_language_code && empty($entity->lingotek['allow_source_overwriting'])) {
    drupal_goto($entity_type . '/' . $entity_id . '/edit');
  }
  else {
    $translation_edit_link = lingotek_get_workbench_url($entity->lingotek['document_id'], $lingotek_locale);
    drupal_goto($translation_edit_link);
  }
}