You are here

function globallink_taxonomy_active_form_submit in GlobalLink Connect for Drupal 7.5

Same name and namespace in other branches
  1. 7.6 globallink_taxonomy/globallink_taxonomy_active_submissions.inc \globallink_taxonomy_active_form_submit()

Handles submission of active taxonomy form.

File

globallink_taxonomy/globallink_taxonomy_active_submissions.inc, line 323

Code

function globallink_taxonomy_active_form_submit($form, &$form_state) {
  $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
  $pd4 = globallink_get_project_director_details();
  switch ($op) {
    case t('Cancel Selected Documents'):
      try {
        $rids_arr = array_filter($form_state['values']['table']);
        $rids = globallink_taxonomy_check_status($rids_arr);
        if (count($rids) == 0) {
          drupal_set_message(t('No document(s) cancelled.'), 'warning', NULL);
          return;
        }
        $_SESSION['globallink_taxonomy_selected_submission'] = '';
        globallink_taxonomy_cancel_records($rids, $pd4);
        $_SESSION['globallink_taxonomy_globalLink_arr'] = array();
        drupal_set_message(t('Selected document(s) has been cancelled successfully.'));
      } 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(),
        )));
      }
      break;
    case t('Clear Cancelled Documents'):
      try {
        $count = globallink_taxonomy_clear_cancelled_documents();
        $_SESSION['globallink_selected_submission'] = '';
        $_SESSION['globallink_globalLink_arr'] = array();
        if ($count > 0) {
          drupal_set_message(t('Cancelled document(s) has been cleared successfully.'));
        }
        else {
          drupal_set_message(t('No document(s) to clear.'), 'warning', NULL);
        }
      } 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(),
        )));
      }
      break;
  }
}