You are here

function search_log_report_form_validate in Search Log 7

Same name and namespace in other branches
  1. 6 search_log.admin.inc \search_log_report_form_validate()

Report filter form validation.

File

./search_log.admin.inc, line 399
Admin page callbacks file for the search_log module.

Code

function search_log_report_form_validate($form, &$form_state) {
  $today = _search_log_get_time();
  $from = strtotime($form_state['values']['from_date']);
  if (!$from) {
    $from = $today;
  }
  if ($from > $today) {
    form_set_error('from_date', t('From date cannot be after today.'));
  }
  $to = strtotime($form_state['values']['to_date']);
  if (!$to) {
    $to = $today;
  }
  if ($from > $to) {
    form_set_error('from_date', t('From date cannot be after To date.'));
  }
  if (isset($form_state['values']['modules'])) {
    $modules = array_flip($form_state['values']['modules']);
    unset($modules[0]);
    if (count($modules) < 1) {
      form_set_error('modules', t('At least one module must be selected.'));
    }
  }
  if (isset($form_state['values']['languages'])) {
    $languages = array_flip($form_state['values']['languages']);
    unset($languages[0]);
    if (count($languages) < 1) {
      form_set_error('languages', t('At least one language must be selected.'));
    }
  }
}