You are here

function lingotek_get_community_settings in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.4 lingotek.setup.inc \lingotek_get_community_settings()
  2. 7.5 lingotek.setup.inc \lingotek_get_community_settings()
  3. 7.6 lingotek.setup.inc \lingotek_get_community_settings()
1 call to lingotek_get_community_settings()
lingotek_project_vault_select_form in ./lingotek.setup.inc
Project Select Screen (for Current Users) - Form Layout

File

./lingotek.setup.inc, line 1044

Code

function lingotek_get_community_settings($community_identity, $return_complete = FALSE) {
  $api = LingotekApi::instance();
  $options = array();
  $complete = array();

  // get projects
  $options['project'] = array();
  $complete['project'] = array();
  $list_projects = $api
    ->request("listProjects", array(
    'community' => $community_identity,
  ));
  if (isset($list_projects->results) && $list_projects->results == "success") {
    foreach ($list_projects->projects as $project) {
      $complete['project'][$project->id] = $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();
  $complete['workflow'] = array();
  $list_workflows = $api
    ->request("listWorkflows", array(
    'community' => $community_identity,
  ));
  if ($list_workflows->results == "success") {
    foreach ($list_workflows->workflows as $workflow) {
      $workflow_key = $workflow->id;
      $complete['workflow'][$workflow_key] = $workflow;
      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];
        }
      }
      if ($workflow->active && !$workflow->is_public) {
        $options['workflow'][$workflow_key] = $workflow->name;
      }
    }
  }

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