function lingotek_project_vault_select_form_submit in Lingotek Translation 7.6
Same name and namespace in other branches
- 7.7 lingotek.setup.inc \lingotek_project_vault_select_form_submit()
- 7.4 lingotek.setup.inc \lingotek_project_vault_select_form_submit()
- 7.5 lingotek.setup.inc \lingotek_project_vault_select_form_submit()
Project Select Screen - Form Submit
File
- ./
lingotek.setup.inc, line 563
Code
function lingotek_project_vault_select_form_submit($form, $form_state) {
$auto_provision_project = FALSE;
$params = array();
// Project
if ($form_state['values']['project_new_or_existing']) {
// new
$auto_provision_project = TRUE;
$project_name = $form_state['values']['project_new'];
$params['projectName'] = $project_name;
}
else {
// existing
$project_id = $form_state['values']['project_existing'];
$lingotek_community_data = json_decode($form_state['values']['lingotek_community_data']);
$workflow_id = $lingotek_community_data->project->{$project_id}->workflowId;
variable_set('lingotek_project', $project_id);
variable_set('lingotek_workflow', $workflow_id);
variable_set('lingotek_translate_comments_workflow_id', $workflow_id);
variable_set('lingotek_translate_config_workflow_id', $workflow_id);
}
// Vault
if ($form_state['values']['vault_existing_or_new']) {
// new
$vault_name = $form_state['values']['vault_new'];
$params['tmVaultName'] = $vault_name;
}
else {
// existing
$vault_id = $form_state['values']['vault_existing'];
variable_set('lingotek_vault', $vault_id);
$params['tmVaultId'] = $vault_id;
}
if ($auto_provision_project) {
$notify_url = lingotek_notify_url_generate();
$params['callbackUrl'] = $notify_url;
$api = LingotekApi::instance();
$response = $api
->request('autoProvisionProject', $params);
if ($response->results == 'success') {
$project_id = $response->project_id;
$workflow_id = $response->workflow_id;
$vault_id = $response->tm_vault_id;
variable_set('lingotek_project', $project_id);
variable_set('lingotek_workflow', $workflow_id);
variable_set('lingotek_translate_comments_workflow_id', $workflow_id);
variable_set('lingotek_translate_config_workflow_id', $workflow_id);
variable_set('lingotek_vault', $vault_id);
variable_set('lingotek_integration_method', $response->integration_method_id);
variable_set('lingotek_notify_url', $notify_url);
}
}
$_SESSION['lingotek_setup_path'][] = 'admin/config/lingotek/project-vault-select';
drupal_set_message(t('Your Lingotek project, workflow, and vault selections have been setup and saved.'));
drupal_goto('admin/config/lingotek/setup-language-switcher');
}