function globallink_entity_dashboard_form_validate in GlobalLink Connect for Drupal 7.6
Same name and namespace in other branches
- 7.7 globallink_entity/globallink_entity_send.inc \globallink_entity_dashboard_form_validate()
- 7.5 globallink_entity/globallink_entity_send.inc \globallink_entity_dashboard_form_validate()
Validates entity form input.
File
- globallink_entity/
globallink_entity_send.inc, line 1229
Code
function globallink_entity_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;
}
$nids = array_filter($form_state['values']['table']);
if (count($nids) == 0) {
$nids = 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($nids) == 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) {
return;
}
foreach ($nids as $nid) {
list($nid, $vid) = explode('-', $nid, 2);
$node = node_load($nid, $vid);
if ($node->tnid != 0 && $node->tnid != $node->nid) {
$nid = $node->tnid;
}
$rows = globallink_entity_get_sent_rows_by_nid($nid);
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');
}
}