You are here

function tmgmt_ui_submit_add_suggestions in Translation Management Tool 7

Adds selected suggestions to the job.

1 string reference to 'tmgmt_ui_submit_add_suggestions'
tmgmt_job_form in ui/includes/tmgmt_ui.pages.inc
Entity API form the job entity.

File

ui/includes/tmgmt_ui.pages.inc, line 603
Provides page callbacks and form functions for the Translation Management Tool User Interface module.

Code

function tmgmt_ui_submit_add_suggestions($form, &$form_state) {

  // Save all selected suggestion items.
  if (isset($form_state['values']['suggestions_table']) && is_array($form_state['values']['suggestions_table'])) {
    foreach ($form_state['values']['suggestions_table'] as $id) {
      $key = (int) $id - 1;

      // Because in the tableselect we need an idx > 0.
      if (isset($form_state['tmgmt_suggestions'][$key]['job_item'])) {
        $item = $form_state['tmgmt_suggestions'][$key]['job_item'];
        $form_state['tmgmt_job']
          ->addExistingItem($item);
      }
    }
  }

  // Force a rebuild of the form.
  $form_state['rebuild'] = TRUE;
  unset($form_state['tmgmt_suggestions']);
}