function lingotek_admin_profile_form_submit in Lingotek Translation 7.4
Same name and namespace in other branches
- 7.7 lingotek.admin.inc \lingotek_admin_profile_form_submit()
- 7.5 lingotek.admin.inc \lingotek_admin_profile_form_submit()
- 7.6 lingotek.admin.inc \lingotek_admin_profile_form_submit()
File
- ./
lingotek.admin.inc, line 1697
Code
function lingotek_admin_profile_form_submit($form, &$form_state) {
if ($form_state['values']['op'] == 'Save') {
$profiles = variable_get('lingotek_profiles');
$profile = array();
$profile['name'] = $form_state['values']['name'];
foreach (lingotek_get_profile_fields(TRUE, TRUE) as $key) {
if (isset($form_state['values'][$key])) {
$profile[$key] = $form_state['values'][$key];
}
}
if (module_exists('workbench_moderation')) {
// set or unset multiple transition globals based on form selection
$states = lingotek_get_workbench_moderation_states();
if ($form_state['values']['sync_method'] == 1) {
if ($form_state['values']['sync_method_workbench_moderation'] == 'increment') {
foreach ($states as $state) {
if (isset($form_state['input']['lingotek_sync_wb_select_' . $state])) {
$profile['lingotek_sync_wb_select_' . $state] = $form_state['input']['lingotek_sync_wb_select_' . $state];
}
}
}
}
}
// If the workflow has changed and if current translations should be changed,
// then pull all nodes associated with this profile and update the workflow
// on TMS, including the correct phase.
if (isset($form_state['values']['profile_id']) && isset($form_state['values']['prefill_phases_checkbox']) && $form_state['values']['prefill_phases_checkbox']) {
$profile_id = $form_state['values']['profile_id'];
$workflow_id = $form_state['values']['workflow_id'];
$prefill_phase = $form_state['values']['prefill_phase_select'];
$nids = lingotek_admin_get_nids_by_profile($profile_id);
$document_ids = LingotekSync::getDocIdsFromNodeIds($nids);
if (!$document_ids) {
return;
}
$api = LingotekApi::instance();
$api
->changeWorkflow($document_ids, $workflow_id, $prefill_phase);
// CREATE/UPDATE WORKFLOW ENTRIES IN THE LINGOTEK METADATA TABLE
foreach ($nids as $nid) {
lingotek_lingonode($nid, 'workflow_id', $workflow_id);
}
}
$profiles[$form_state['values']['profile_id']] = $profile;
variable_set('lingotek_profiles', $profiles);
}
elseif ($form_state['values']['op'] == 'Delete') {
$profiles = variable_get('lingotek_profiles');
unset($profiles[$form_state['values']['profile_id']]);
variable_set('lingotek_profiles', $profiles);
}
elseif ($form_state['values']['op'] == 'Cancel') {
//do nothing
}
}