You are here

function globallink_entity_dashboard_form_submit in GlobalLink Connect for Drupal 7.5

Same name and namespace in other branches
  1. 7.7 globallink_entity/globallink_entity_send.inc \globallink_entity_dashboard_form_submit()
  2. 7.6 globallink_entity/globallink_entity_send.inc \globallink_entity_dashboard_form_submit()

Handles entity form submission.

File

globallink_entity/globallink_entity_send.inc, line 1284

Code

function globallink_entity_dashboard_form_submit($form, &$form_state) {
  $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
  $submission_details = array();
  $pd4 = globallink_get_project_director_details();
  if ($op != t('Send for Translation')) {
    return;
  }
  try {
    $nids = array_filter($form_state['values']['table']);
    $submission_name = $form_state['values']['submission_name'];
    $source_locale = $form_state['values']['submission_source_locale'];
    $target_locale_arr = $form_state['values']['submission_target_locale'];
    $submission_details['instructions'] = $form_state['values']['submission_instructions'];
    $submission_details['submitter'] = $form_state['values']['submission_submitter'];
    $submission_priority = $form_state['values']['submission_pd_priority'];
    foreach ($target_locale_arr as $key => $target) {
      if ($target == FALSE) {
        unset($target_locale_arr[$key]);
      }
    }
    $due_date = globallink_convert_date_to_timestamp($form_state['values']['submission_due_date']);
    $project_code = $form_state['values']['submission_pd_project'];
    $updated_globalLink_arr = globallink_entity_send_for_translations($nids, $pd4, $submission_name, $due_date, $project_code, $source_locale, $target_locale_arr, $submission_details, $submission_priority);
    if (count($updated_globalLink_arr) > 0) {
      globallink_entity_update_ticket_id($updated_globalLink_arr, $project_code);
      drupal_set_message(t('Content has been successfully sent for translations.'));
    }
    else {
      if (empty($_SESSION['messages']['warning'])) {
        drupal_set_message(t('Content is empty and has not been sent for translations.'), 'warning');
      }
    }
    if (isset($_GET['rnid'])) {
      unset($_GET['rnid']);
    }
  } catch (SoapFault $se) {
    watchdog('GlobalLink', 'SOAP Exception - %function - Code[%faultcode], Message[%faultstring]', array(
      '%function' => __FUNCTION__,
      '%faultcode' => $se->faultcode,
      '%faultstring' => $se->faultstring,
    ), WATCHDOG_ERROR);
    form_set_error('', t('Web Services Error: @faultcode - @faultstring', array(
      '@faultcode' => $se->faultcode,
      '@faultstring' => $se->faultstring,
    )));
  } catch (Exception $e) {
    watchdog('GlobalLink', 'Exception - %function - File[%file], Line[%line], Code[%code], Message[%message]', array(
      '%function' => __FUNCTION__,
      '%file' => $e
        ->getFile(),
      '%line' => $e
        ->getLine(),
      '%code' => $e
        ->getCode(),
      '%message' => $e
        ->getMessage(),
    ), WATCHDOG_ERROR);
    form_set_error('', t('Error: @message', array(
      '@message' => $e
        ->getMessage(),
    )));
  }
}