You are here

public static function LingotekWorkbenchController::generateWorkbenchLink in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/Controller/LingotekWorkbenchController.php \Drupal\lingotek\Controller\LingotekWorkbenchController::generateWorkbenchLink()
1 call to LingotekWorkbenchController::generateWorkbenchLink()
LingotekWorkbenchController::workbenchPageRedirect in src/Controller/LingotekWorkbenchController.php

File

src/Controller/LingotekWorkbenchController.php, line 46

Class

LingotekWorkbenchController

Namespace

Drupal\lingotek\Controller

Code

public static function generateWorkbenchLink($document_id, $locale_code, $client_id, $access_token, $login_id, $acting_login_id = "anonymous", $base_url = "https://myaccount.lingotek.com", $expiration = NULL) {
  $expiration_default = time() + 60 * 30;

  // 30-minute default, otherwise use $expiration as passed in
  $expiration = is_null($expiration) ? $expiration_default : $expiration;
  $data = array(
    'document_id' => $document_id,
    'locale_code' => $locale_code,
    'client_id' => $client_id,
    'login_id' => $login_id,
    'acting_login_id' => $acting_login_id,
    'expiration' => $expiration,
  );
  $query_data = utf8_encode(http_build_query($data));
  $hmac = urlencode(base64_encode(hash_hmac('sha1', $query_data, $access_token, TRUE)));
  $workbench_url = $base_url . '/lingopoint/portal/wb.action?' . $query_data . "&hmac=" . $hmac;
  return $workbench_url;
}