function globallink_block_dashboard_form_validate in GlobalLink Connect for Drupal 7.6
Same name and namespace in other branches
- 7.7 globallink_block/globallink_block_send.inc \globallink_block_dashboard_form_validate()
- 7.5 globallink_block/globallink_block_send.inc \globallink_block_dashboard_form_validate()
Validates block form input.
File
- globallink_block/
globallink_block_send.inc, line 491
Code
function globallink_block_dashboard_form_validate($form, &$form_state) {
module_load_include('inc', 'globallink', 'globallink_settings');
$op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
$pd4 = globallink_get_project_director_details();
globallink_validate_project_director_details($pd4);
$source_locale = $form_state['values']['submission_source_locale'];
$target_locale_arr = $form_state['values']['submission_target_locale'];
if ($op != t('Send for Translation')) {
return;
}
$bids = array_filter($form_state['values']['table']);
if (count($bids) == 0) {
$bids = array_filter($form_state['values']['table']);
form_set_error('', t('No items selected.'));
}
if (!empty($form_state['values']['submission_due_date'])) {
$due_date = globallink_convert_date_to_timestamp($form_state['values']['submission_due_date']) / 1000;
if ($due_date < REQUEST_TIME) {
form_set_error('', t('The specified date is in past.'));
}
}
if (count($bids) == 0) {
return;
}
if (!isset($source_locale) || !isset($target_locale_arr)) {
return;
}
foreach ($target_locale_arr as $key => $target) {
if ($target == FALSE) {
unset($target_locale_arr[$key]);
}
}
$message = FALSE;
if (count($target_locale_arr) > 0) {
foreach ($bids as $bid) {
$rows = globallink_block_get_sent_tpt_rows_by_bid($bid);
foreach ($rows as $row) {
if ($row->source == $source_locale && array_search($row->target, $target_locale_arr)) {
$message = TRUE;
}
}
}
if ($message) {
drupal_set_message(t('Ignored record(s) that has already been sent out for translation.'), 'warning');
}
}
}