function tmgmt_local_translation_form_save_as_completed_submit in Translation Management Tool 7
Form submit callback for save as completed submit action.
Change items to needs review state and task to completed status.
1 string reference to 'tmgmt_local_translation_form_save_as_completed_submit'
- tmgmt_local_translation_form in translators/
tmgmt_local/ includes/ tmgmt_local.pages.inc - Form callback for translating a job item.
File
- translators/
tmgmt_local/ includes/ tmgmt_local.pages.inc, line 202 - Provides page and forms callbacks.
Code
function tmgmt_local_translation_form_save_as_completed_submit($form, &$form_state) {
/**
* @var TMGMTLocalTask $task.
*/
$task = $form_state['task'];
/**
* @var TMGMTLocalTaskItem $task_item.
*/
$task_item = $form_state['task_item'];
$task_item
->completed();
$task_item
->save();
// Mark the task as completed if all assigned job items are at needs done.
$all_done = TRUE;
foreach ($task
->getItems() as $item) {
if ($item
->isPending()) {
$all_done = FALSE;
break;
}
}
if ($all_done) {
$task
->setStatus(TMGMT_LOCAL_TASK_STATUS_COMPLETED);
// If the task is now completed, redirect back to the overview.
$form_state['redirect'] = 'translate';
}
else {
// If there are more task items, redirect back to the task.
$uri = $task
->uri();
$form_state['redirect'] = $uri['path'];
}
/**
* @var TMGMTJobItem $job_item.
*/
$job_item = $form_state['job_item'];
// Add the translations to the job item.
$job_item
->addTranslatedData($task_item
->getData());
}