function globallink_dashboard_active_submit in GlobalLink Connect for Drupal 7.7
Same name and namespace in other branches
- 7.5 globallink_active_submissions.inc \globallink_dashboard_active_submit()
- 7.6 globallink_active_submissions.inc \globallink_dashboard_active_submit()
Handles submission of active GlobalLink form.
File
- ./
globallink_workbench_all_submissions.inc, line 663
Code
function globallink_dashboard_active_submit($form, &$form_state) {
$op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
module_load_include('inc', 'globallink', 'globallink_node');
$query = db_select('globallink_submission', 'gs');
$query
->fields('gs', array(
'rid',
));
if (arg(3) == 'completed') {
$query
->condition('status', array(
GLOBALLINK_STATUS_TRANSLATION_SENT,
GLOBALLINK_STATUS_TRANSLATION_ERROR,
GLOBALLINK_STATUS_TRANSLATION_COMPLETED,
GLOBALLINK_STATUS_TRANSLATION_IMPORTED,
), 'IN');
}
else {
$query
->condition('status', array(
GLOBALLINK_STATUS_TRANSLATION_SENT,
GLOBALLINK_STATUS_TRANSLATION_ERROR,
GLOBALLINK_STATUS_TRANSLATION_COMPLETED,
), 'IN');
}
$results = $query
->execute();
foreach ($results as $value) {
$sub_rids[] = $value->rid;
}
if (!$results
->rowCount()) {
drupal_set_message("No Results available");
}
else {
switch ($op) {
case t('Re-Import All'):
case t('Import All'):
$pd4 = globallink_get_project_director_details();
try {
foreach ($sub_rids as $sub_rid) {
if (module_exists('background_process') && module_exists('background_batch')) {
$operations = array();
$operations[] = array(
'globallink_background_import',
array(
$pd4,
$sub_rid,
NULL,
),
);
$batch = array(
'title' => t('Importing'),
'operations' => $operations,
'error_message' => t('Import has encountered an error.'),
'file' => drupal_get_path('module', 'globallink') . '/globallink_background_jobs.inc',
);
$batch['progressive'] = FALSE;
batch_set($batch);
background_batch_process_batch('admin/globallink-translations/workbench');
drupal_set_message('The submission(s) are being imported in the background. Please refresh the page for the progress. For more information check watchdog.');
}
else {
module_load_include('inc', 'globallink', 'globallink_background_jobs');
globallink_background_import($pd4, $sub_rid, NULL);
drupal_set_message('The submisions have been imported');
}
}
} catch (SoapFault $se) {
watchdog(GLOBALLINK_MODULE, '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_MODULE, '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('Sync All'):
$pd4 = globallink_get_project_director_details();
try {
foreach ($sub_rids as $sub_rid) {
if (module_exists('background_process') && module_exists('background_batch')) {
$operations = array();
$operations[] = array(
'globallink_background_pull',
array(
$pd4,
$sub_rid,
NULL,
0,
),
);
$batch = array(
'title' => t('Pulling Status'),
'operations' => $operations,
'error_message' => t('Sync has encountered an error.'),
'file' => drupal_get_path('module', 'globallink') . '/globallink_background_jobs.inc',
);
batch_set($batch);
$batch['progressive'] = FALSE;
background_batch_process_batch('admin/globallink-translations/workbench');
drupal_set_message('The submission(s) are being synced in the background. Please refresh the page for the progress.');
}
else {
module_load_include('inc', 'globallink', 'globallink_background_jobs');
globallink_background_pull($pd4, $sub_rid, NULL, 0);
drupal_set_message('The submissions have been synced to the latest available status');
}
}
} catch (SoapFault $se) {
watchdog(GLOBALLINK_MODULE, '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_MODULE, '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(),
)));
}
}
}
}