You are here

function lingotek_notifications in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.2 lingotek.sync.inc \lingotek_notifications()
  2. 7.3 lingotek.sync.inc \lingotek_notifications()
  3. 7.4 lingotek.sync.inc \lingotek_notifications()
  4. 7.5 lingotek.sync.inc \lingotek_notifications()
  5. 7.6 lingotek.sync.inc \lingotek_notifications()

Registers the site translation notfication callback.

1 string reference to 'lingotek_notifications'
lingotek_menu in ./lingotek.module
Implements hook_menu().

File

./lingotek.sync.inc, line 193
Sync and management

Code

function lingotek_notifications() {
  drupal_page_is_cacheable(FALSE);
  LingotekLog::trace('Received <pre>@data</pre>', array(
    '@data' => check_plain(var_export($_GET, TRUE)),
  ), 'callback');
  $callback_type = isset($_GET['type']) ? $_GET['type'] : 'phase_integration';
  $locale = isset($_GET['locale']) ? $_GET['locale'] : null;
  $document_id = NULL;
  if (isset($_GET['document_id'])) {
    $document_id = $_GET['document_id'];

    // Project Callback
  }
  else {
    if (isset($_GET['doc_id'])) {
      $document_id = $_GET['doc_id'];

      // Integration Callback
    }
  }
  $document_idx = NULL;
  if (isset($_GET['documentId'])) {
    $document_idx = $_GET['documentId'];

    // Project Callback
  }
  else {
    if (isset($_GET['doc_idx'])) {
      $document_idx = $_GET['doc_idx'];

      // Integration Callback
    }
  }
  LingotekLog::trace("Received callback of type {$callback_type}\n");
  if (!$document_id && !$document_idx) {
    return _lingotek_notification_output("No document id or document idx");
  }
  $trans_obj = lingotek_get_trans_obj($document_id, $document_idx);
  if (!$trans_obj) {
    return _lingotek_notification_output("Document not found. document_id " . $document_id . ", document_idx " . $document_idx);
  }
  switch ($callback_type) {
    case 'phase_integration':
    case 'target':
    case 'phase':
      LingotekLog::trace("Handling target or phase\n");
      _lingotek_notification_handle_target_or_phase($trans_obj, $document_id);
      break;
    case 'download_interim_translation':
      LingotekLog::trace("Handling interim download\n");
      _lingotek_notification_handle_interim_download($trans_obj, $document_id);
      break;
    case 'document_uploaded':
    case 'document_updated':
      LingotekLog::trace("Handling uploaded or updated\n");
      _lingotek_notification_handle_document_uploaded_or_updated($trans_obj);
      break;
    case 'import_failure':
      LingotekLog::trace("Handling import failure\n");
      _lingotek_notification_handle_import_failure($trans_obj, $document_id);
      break;
    case 'document_archived':
      LingotekLog::trace("Handling document archived\n");
      _lingotek_notification_handle_document_archived($trans_obj);
      break;
    case 'document_deleted':
      LingotekLog::trace("Handling document deleted\n");
      _lingotek_notification_handle_document_deleted($trans_obj);
      break;
    case 'target_deleted':
      LingotekLog::trace("Handling target deleted\n");
      _lingotek_notification_handle_target_deleted($trans_obj, $locale);
      break;
    default:
      LingotekLog::trace("Unknown callback\n");
      _lingotek_notification_output("Callback received, no handle for type: " . $callback_type);
  }
}