function lingotek_admin_profile_form_submit in Lingotek Translation 7.6
Same name and namespace in other branches
- 7.7 lingotek.admin.inc \lingotek_admin_profile_form_submit()
- 7.4 lingotek.admin.inc \lingotek_admin_profile_form_submit()
- 7.5 lingotek.admin.inc \lingotek_admin_profile_form_submit()
File
- ./
lingotek.admin.inc, line 1945
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 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'])) {
$profile_id = $form_state['values']['profile_id'];
lingotek_set_profile_settings($profile_id, $profile);
if (isset($form_state['values']['prefill_phases_checkbox']) && $form_state['values']['prefill_phases_checkbox']) {
$workflow_id = $form_state['values']['workflow_id'];
$prefill_phase = $form_state['values']['prefill_phase_select'];
$entities = lingotek_get_all_entities_by_profile($profile_id);
$api = LingotekApi::instance();
$document_ids = array();
// gather doc IDs for bulk submission
foreach ($entities as $entity) {
if (isset($entity['document_id']) && $entity['document_id']) {
$document_ids[] = $entity['document_id'];
lingotek_keystore($entity['type'], $entity['id'], 'workflow_id', $workflow_id);
}
}
if (!empty($document_ids)) {
$api
->changeWorkflow($document_ids, $workflow_id, $prefill_phase);
}
}
}
}
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
}
}