function tmgmt_ui_translation_review_form_update_state in Translation Management Tool 7
Callback for the action at the job item review form.
2 string references to 'tmgmt_ui_translation_review_form_update_state'
- tmgmt_ui_translation_review_form_reject_confirm in ui/
tmgmt_ui.module - Form callback for the reject confirm form.
- _tmgmt_ui_review_form_element in ui/
tmgmt_ui.module - Build form elements for the review form using flatened data items.
File
- ui/
tmgmt_ui.module, line 955 - Common Translation managment UI.
Code
function tmgmt_ui_translation_review_form_update_state($form, &$form_state) {
$matches = array();
// We should have an #name element
// and the name should beginn with approve-
// and the $matches should now kontain an element with with name key.
preg_match("/^(?P<action>[^-]+)-(?P<key>.+)/i", $form_state['triggering_element']['#name'], $matches);
$values = $form_state['values'];
$data = array();
$job_item = $form_state['item'];
$controller = $job_item
->getTranslatorController();
$success = TRUE;
switch ($matches['action']) {
case 'reviewed':
$form_state['rebuild'] = TRUE;
$data['#status'] = TMGMT_DATA_ITEM_STATE_REVIEWED;
break;
case 'unreviewed':
$form_state['rebuild'] = TRUE;
$data['#status'] = TMGMT_DATA_ITEM_STATE_TRANSLATED;
break;
case 'reject':
if (empty($values['confirm'])) {
if (isset($_GET['destination'])) {
$destination = $_GET['destination'];
unset($_GET['destination']);
}
else {
$destination = '';
}
tmgmt_ui_redirect_queue_set(array(
current_path(),
), $destination);
$form_state['redirect'] = current_path() . '/reject/' . $matches['key'];
$success = FALSE;
}
else {
$form_state['redirect'] = array(
tmgmt_ui_redirect_queue_dequeue(),
array(
'query' => array(
'destination' => tmgmt_ui_redirect_queue_destination(),
),
),
);
if ($controller instanceof TMGMTTranslatorRejectDataItem) {
$success = $job_item
->getTranslatorController()
->rejectDataItem($job_item, tmgmt_ensure_keys_array($matches['key']), $values);
}
}
default:
$data['#status'] = TMGMT_DATA_ITEM_STATE_PENDING;
break;
}
if ($success) {
$job_item
->updateData($matches['key'], $data);
// If a data item has been rejected and the job is in needs review state,
// set back to active.
if ($matches['action'] == 'reject' && $job_item
->isNeedsReview()) {
$job_item
->active(FALSE);
}
}
tmgmt_ui_write_request_messages($job_item
->getJob());
}