You are here

public function LingotekApi::getWorkbenchLink in Lingotek Translation 7.2

Same name and namespace in other branches
  1. 7.7 lib/Drupal/lingotek/LingotekApi.php \LingotekApi::getWorkbenchLink()
  2. 7.3 lib/Drupal/lingotek/LingotekApi.php \LingotekApi::getWorkbenchLink()
  3. 7.4 lib/Drupal/lingotek/LingotekApi.php \LingotekApi::getWorkbenchLink()
  4. 7.5 lib/Drupal/lingotek/LingotekApi.php \LingotekApi::getWorkbenchLink()
  5. 7.6 lib/Drupal/lingotek/LingotekApi.php \LingotekApi::getWorkbenchLink()

Gets a workbench URL for the specified document ID and phase.

Parameters

int $document_id: A Lingotek Document ID.

int $phase_id: A Lingotek workflow phase ID.

Return value

mixed A workbench URL string on success, or FALSE on failure.

File

lib/Drupal/lingotek/LingotekApi.php, line 659
Defines Drupal\lingotek\LingotekApi

Class

LingotekApi
@file Defines Drupal\lingotek\LingotekApi

Code

public function getWorkbenchLink($document_id, $phase_id) {
  $links =& drupal_static(__FUNCTION__);
  global $user;
  $externalId = isset($user->name) ? $user->name : '';

  // send a blank string for anonymous users (community translation)
  self::checkUserWorkbenchLinkPermissions($externalId);
  $static_id = $document_id . '-' . $phase_id;
  if (empty($links[$static_id])) {
    $params = array(
      'documentId' => $document_id,
      'phaseId' => $phase_id,
      'externalId' => $externalId,
    );
    if ($output = $this
      ->request('getWorkbenchLink', $params)) {
      $links[$static_id] = $url = $output->url;
    }
    else {
      $url = FALSE;
    }
  }
  else {
    $url = $links[$static_id];
  }
  return $url;
}