You are here

function lingotek_get_community_settings_v4 in Lingotek Translation 7.3

1 call to lingotek_get_community_settings_v4()
lingotek_community_settings_select_form in ./lingotek.setup.inc
Project Select Screen (for Current Users) - Form Layout

File

./lingotek.setup.inc, line 989

Code

function lingotek_get_community_settings_v4($login, $passwd, $community_identity, $url) {

  // API V4 Connection
  $client = new LingotekSession();
  $client->login_id = $login;
  $client->password = $passwd;
  $client->url = $url;
  $client->community = $community_identity;
  if (!$client
    ->canLogIn()) {
    return FALSE;
  }
  $options = array();

  // get projects
  $options['project'] = array();
  $list_projects = $client
    ->request("listProjects", array(
    'community' => $community_identity,
  ));
  if ($list_projects->results == "success") {
    foreach ($list_projects->projects as $project) {
      if ($project->state == 'Active') {

        //if (!empty($project->workflowId)) { // Send back the ProjectID AND WorkflowID.  Joined by |||

        //  $options['project'][$project->id . '|||' . $project->workflowId] = $project->name;

        //}

        //else { // Just send back the Project ID
        $options['project'][$project->id] = $project->name;

        //}
      }
    }
  }

  // get workflows
  $options['workflow'] = array();
  $list_workflows = $client
    ->request("listWorkflows", array(
    'community' => $community_identity,
  ));
  if ($list_workflows->results == "success") {
    foreach ($list_workflows->workflows as $workflow) {
      $workflow_key = $workflow->id;
      foreach ($workflow->workflow_steps as $step) {
        if (isset($step->save_to_vault)) {
          $vault = array();
          $vault_match = preg_match('/doc_index_id="([0-9]*)"/', $step->save_to_vault, $vault);
          $workflow_key .= '|||' . $vault[1];
        }
      }
      $options['workflow'][$workflow_key] = $workflow->name;
    }
  }

  // get TM vaults
  $options['vault'] = array();
  $list_vaults = $client
    ->request("listTMVaults", array(
    'community' => $community_identity,
  ));
  if ($list_vaults->results == "success") {
    if (isset($list_vaults->personalVaults)) {
      foreach ($list_vaults->personalVaults as $personal_vault) {
        $options['vault']['Personal Vaults'][$personal_vault->id] = $personal_vault->name;
      }
    }
    if (isset($list_vaults->communityVaults)) {
      foreach ($list_vaults->communityVaults as $community_vault) {
        $options['vault']['Community Vaults'][$community_vault->id] = $community_vault->name;
      }
    }
    if (isset($list_vaults->publicVaults)) {
      foreach ($list_vaults->publicVaults as $public_vault) {
        $options['vault']['Public Vaults'][$public_vault->id] = $public_vault->name;
      }
    }
  }
  return $options;
}