You are here

function mail_logger_form_overview_validate in Mail Logger 7

File

./mail_logger.pages.inc, line 234
User-facing UI components for the Mail Logger module.

Code

function mail_logger_form_overview_validate($form, &$form_state) {
  if (in_array('reset', $form_state['triggering_element']['#attributes'])) {
    return;
  }
  $from_date = strtotime($form_state['values']['from_date']['year'] . '-' . str_pad($form_state['values']['from_date']['month'], 2, '0', STR_PAD_LEFT) . '-' . str_pad($form_state['values']['from_date']['day'], 2, '0', STR_PAD_LEFT));
  $to_date = strtotime($form_state['values']['to_date']['year'] . '-' . str_pad($form_state['values']['to_date']['month'], 2, '0', STR_PAD_LEFT) . '-' . str_pad($form_state['values']['to_date']['day'], 2, '0', STR_PAD_LEFT));
  if ($to_date < $from_date) {
    form_set_error('to_date', 'The To Date must be after the From Date.');
  }
  if (!empty($form_state['values']['search_value']) && empty($form_state['values']['search_field'])) {
    form_set_error('search_field', 'Please choose a search field.');
  }
  elseif (empty($form_state['values']['search_value']) && !empty($form_state['values']['search_field'])) {
    form_set_error('search_value', 'Please enter a search text.');
  }
}