function globallink_interface_receive_form_submit in GlobalLink Connect for Drupal 7.5
Same name and namespace in other branches
- 7.6 globallink_interface/globallink_interface_receive.inc \globallink_interface_receive_form_submit()
Handles interface form submission.
File
- globallink_interface/
globallink_interface_receive.inc, line 558
Code
function globallink_interface_receive_form_submit($form, &$form_state) {
$type = $_SESSION['transpefect_interface_receive_type'];
$op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
$pd4 = globallink_get_project_director_details();
switch ($op) {
case t('Update All'):
try {
$globallink_arr = unserialize($_SESSION['globallink_interface_globalLink_arr']);
$count = globallink_interface_get_translated($pd4, $globallink_arr);
$error = FALSE;
$delete_records_selected = FALSE;
foreach ($globallink_arr as $updated) {
if ($updated->sourceDeleted == TRUE) {
$delete_records_selected = TRUE;
}
if ($updated->status == 'Error') {
$error = TRUE;
}
}
$status = 'status';
if ($error) {
drupal_set_message(t('There was some error while updating the records. Please check logs for more details.'), 'warning', NULL);
$status = 'warning';
}
drupal_set_message(check_plain($count . ' record(s) updated successfully.'), $status, NULL);
if ($delete_records_selected) {
drupal_set_message(t('Source Deleted record(s) cannot be updated.'), '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(),
)));
}
$_SESSION['globallink_interface_globalLink_arr'] = array();
$_SESSION['globallink_interface_selected_submission'] = array();
unset($_SESSION['globallink_interface_globalLink_arr_last_refreshed']);
break;
case t('Clear Deleted Records'):
try {
$globallink_arr = unserialize($_SESSION['globallink_interface_globalLink_arr']);
$success = FALSE;
$count = 0;
foreach ($globallink_arr as $globallink) {
if ($globallink->sourceDeleted == TRUE) {
$success = globallink_interface_update_deleted_records($pd4, $globallink);
$count++;
}
}
if ($count == 0) {
drupal_set_message(t('No source record(s) deleted.'), 'warning', NULL);
}
else {
$_SESSION['globallink_interface_globalLink_arr'] = array();
$_SESSION['globallink_interface_selected_submission'] = array();
unset($_SESSION['globallink_interface_globalLink_arr_last_refreshed']);
}
if ($success) {
drupal_set_message(check_plain($count . ' Source Deleted record(s) cleared successfully.'), 'status', 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;
case t('Update Selected'):
try {
$globallink_arr = unserialize($_SESSION['globallink_interface_globalLink_arr']);
$updated_globalLink_arr = array();
$rids = array_filter($form_state['values']['table']);
foreach ($rids as $rid) {
array_push($updated_globalLink_arr, $globallink_arr[$rid]);
}
$count = globallink_interface_get_translated($pd4, $updated_globalLink_arr);
$error = FALSE;
$delete_records_selected = FALSE;
foreach ($globallink_arr as $updated) {
if ($updated->sourceDeleted == TRUE) {
$delete_records_selected = TRUE;
}
if ($updated->status == 'Error') {
$error = TRUE;
}
}
$status = 'status';
if ($error) {
drupal_set_message(t('There was some error while updating the records. Please check logs for more details.'), 'warning', NULL);
$status = 'warning';
}
drupal_set_message(check_plain($count . ' record(s) updated successfully.'), $status, NULL);
if ($delete_records_selected) {
drupal_set_message(t('Source Deleted record(s) cannot be updated.'), '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(),
)));
}
$_SESSION['globallink_interface_globalLink_arr'] = array();
$_SESSION['globallink_interface_selected_submission'] = array();
unset($_SESSION['globallink_interface_globalLink_arr_last_refreshed']);
break;
case t('Refresh Page'):
sleep(2);
$pd4 = globallink_get_project_director_details();
try {
$globallink_arr = globallink_get_ready_translations_details_from_pd($pd4, $type);
} 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(),
)));
}
if (sizeof($globallink_arr) > 0) {
$_SESSION['globallink_interface_globalLink_arr'] = serialize($globallink_arr);
$_SESSION['globallink_interface_globalLink_arr_last_refreshed'] = format_date(REQUEST_TIME, 'custom', 'D M j, Y G:i:s');
}
else {
$_SESSION['globallink_interface_globalLink_arr'] = array();
unset($_SESSION['globallink_interface_globalLink_arr_last_refreshed']);
}
break;
}
}