function lingotek_community_settings_select_form in Lingotek Translation 7.3
Project Select Screen (for Current Users) - Form Layout
1 string reference to 'lingotek_community_settings_select_form'
- lingotek_menu in ./
lingotek.module - Implements hook_menu().
File
- ./
lingotek.setup.inc, line 390
Code
function lingotek_community_settings_select_form() {
$login_id = variable_get('lingotek_login_id', '');
$password = variable_get('lingotek_password', '');
$form = array();
// V3 API Call for Legacy Users
$community_identity = variable_get('lingotek_community_identifier', NULL);
$community_settings = lingotek_get_community_settings_v4($login_id, $password, $community_identity, LINGOTEK_API_SERVER . '/lingopoint/api/4');
if ($community_settings === FALSE) {
drupal_set_message(t('Error Retrieving Account Information.'), 'error');
drupal_goto('admin/config/lingotek/account-settings');
// Error geting projects. Go back.
}
else {
if ($community_settings['project'] === FALSE || $community_settings['workflow'] === FALSE || $community_settings['vault'] === FALSE) {
drupal_set_message(t('Error Retrieving Account Information.'), 'error');
drupal_goto('admin/config/lingotek/account-settings');
// Error geting projects. Go back.
}
else {
// PROJECTS
$project_count = count($community_settings['project']);
if ($project_count == 1) {
// If there is just 1 Project, Auto-Select it. Then move on to the next step.
$project_id = '';
$project_keys = array_keys($community_settings['project']);
$project_id = array_pop($project_keys);
variable_set('lingotek_project', $project_id);
}
// WORKFLOWS
$workflow_count = count($community_settings['workflow']);
if ($workflow_count == 1) {
// If there is just 1 Workflow, Auto-Select it. Then move on to the next step.
$workflow_keys = array_keys($workflow_settings['workflow']);
$workflow_string = array_pop($workflow_keys);
// This can come back as the workflow_id ||| vault_id mashed together, so check it first
if (strpos($workflow_string, '|||')) {
$parts = explode('|||', $workflow_string);
$workflow_id = $parts[0];
$vault_id = $parts[1];
}
else {
$workflow_id = $workflow_string;
}
variable_set('lingotek_workflow', $workflow_id);
if (isset($vault_id)) {
// If the vault id is passed back, and there is only one workflow choice, pick the associated vault by default
variable_set('lingotek_vault', $vault_id);
}
}
// VAULTS
$vault_count = count($community_settings['vault']);
if ($vault_count == 1) {
// If there is just 1 Vault, Auto-Select it. Then move on to the next step.
$vault_id = array_keys($community_settings['vault'][0]);
$current_vault = variable_get('lingotek_vault', NULL);
if ($current_vault && $current_vault != $vault_id) {
// Something is wrong here. The workflow is referencing a vault that the user has no access to.
// I don't know what to do in this case, however, or if it will ever happen.
}
variable_set('lingotek_vault', $vault_id);
}
if ($project_count == 1 && $workflow_count == 1 && $vault_count == 1) {
drupal_goto('admin/config/lingotek/language-settings');
// Default path, if they only have 1 project, workflow, and vault.
}
else {
if ($project_count < 1 || $workflow_count < 1 || $vault_count < 1) {
// Something went wrong here, so go back.
drupal_goto('admin/config/lingotek/new-account');
}
}
}
}
$form['lingotek_user_directions'] = array(
'#markup' => '<p>Your account is associated with multiple projects, workflows, or vaults.</p><p>Select the defaults that you would like to use below</p>',
);
if ($project_count > 1) {
$form['lingotek_site_project'] = array(
'#title' => t('Project'),
'#type' => 'select',
'#options' => $community_settings['project'],
'#default_value' => variable_get('lingotek_project', NULL),
'#description' => t('The Lingotek Project with which translations will be associated.'),
'#required' => TRUE,
);
}
if ($workflow_count > 1) {
$form['lingotek_site_workflow'] = array(
'#title' => t('Workflow'),
'#type' => 'select',
'#options' => $community_settings['workflow'],
//'#default_value' => ,
'#description' => t('The Workflow to use when translating content.'),
'#required' => TRUE,
);
}
if ($vault_count > 1) {
$form['lingotek_site_vault'] = array(
'#title' => t('Vault'),
'#type' => 'select',
'#options' => $community_settings['vault'],
'#default_value' => variable_get('lingotek_vault', NULL),
'#description' => t('The Translation Memory Vault where translations are saved.'),
'#required' => TRUE,
);
}
$form['lingotek_button_spacer'] = array(
'#markup' => '<div> </div>',
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Next'),
);
if (is_array($_SESSION['lingotek_setup_path'])) {
if (end($_SESSION['lingotek_setup_path']) == 'admin/config/lingotek/community-settings-select') {
$null = array_pop($_SESSION['lingotek_setup_path']);
}
// if the user went back, remove the last element, which is this page.
$form['lingotek_back_button'] = lingotek_setup_link(end($_SESSION['lingotek_setup_path']), t('Previous Step'));
}
$form['lingotek_support_footer'] = lingotek_support_footer();
return $form;
}