You are here

private function LingotekApi::checkUserWorkbenchLinkPermissions in Lingotek Translation 7.6

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

Configures the Lingotek community to allow the local Drupal user to use the Workbench.

Parameters

str $username: A Drupal username.

1 call to LingotekApi::checkUserWorkbenchLinkPermissions()
LingotekApi::getWorkbenchLink in lib/Drupal/lingotek/LingotekApi.php
Gets a workbench URL for the specified document ID and phase.

File

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

Class

LingotekApi
@file Defines Drupal\lingotek\LingotekApi

Code

private function checkUserWorkbenchLinkPermissions($username = self::ANONYMOUS_LINGOTEK_ID) {

  // Don't do anything with the community_admin user.
  if ($username == 'community_admin') {
    return true;
  }

  // To use the workbench, users need to be tagged.  Check to see if the current user has already been tagged.
  $workbench_list = variable_get('lingotek_workbench_tagged_users', array());
  $found = array_search($username, $workbench_list);

  // If not, update his account to allow  him to use the workbench.
  if ($found === false) {
    $profileId = $this
      ->getProfileId($username);
    if ($profileId) {
      $projectId = variable_get('lingotek_project', NULL);
      $role = $this
        ->addRoleAssignment("project_manager", $profileId);
      if ($role && isset($projectId)) {
        $manager = $this
          ->assignProjectManager($projectId, $profileId);

        // This call will only return true the FIRST time.
        $workbench_list[] = $username;
        variable_set('lingotek_workbench_tagged_users', $workbench_list);
      }
    }
  }
}