You are here

function event_form_validate in Event 5.2

File

./event.module, line 2122

Code

function event_form_validate($form_id, $form_values, $form) {
  event_validate_form_date($form_values, 'start');
  event_validate_form_date($form_values, 'end');
  if (!module_exists('jscalendar')) {
    if (variable_get('event_ampm', '0') == 1) {
      if ($form_values['start_ampm'] == 'pm' && $form_values['start_hour'] != 12) {
        $form_values['start_hour'] += 12;
      }
      if ($form_values['end_ampm'] == 'pm' && $form_values['end_hour'] != 12) {
        $form_values['end_hour'] += 12;
      }
    }
    $start_datetime = array(
      'year' => $form_values['start_year'],
      'month' => $form_values['start_month'],
      'day' => $form_values['start_day'],
      'hour' => $form_values['start_hour'],
      'minute' => $form_values['start_minute'],
    );
    $end_datetime = array(
      'year' => $form_values['end_year'],
      'month' => $form_values['end_month'],
      'day' => $form_values['end_day'],
      'hour' => $form_values['end_hour'],
      'minute' => $form_values['end_minute'],
    );
    if (isset($form_values['start_year']) && event_is_later($start_datetime, $end_datetime, 'array')) {
      form_set_value($form['event']['end']['date']['end_year'], $form_values['start_year']);
      form_set_value($form['event']['end']['date']['end_month'], $form_values['start_month']);
      form_set_value($form['event']['end']['date']['end_day'], $form_values['start_day']);
      form_set_value($form['event']['end']['date']['end_hour'], $form_values['start_hour']);
      form_set_value($form['event']['end']['date']['end_minute'], $form_values['start_minute']);
      if (variable_get('event_ampm', '0') == 1) {
        form_set_value($form['event']['end']['date']['end_ampm'], $form_values['start_ampm']);
      }
    }
  }
  else {
    if (isset($form_values['event_start']) && event_is_later($form_values['event_start'], $form_values['event_end'], 'string')) {
      form_set_value($form['event']['event_end'], $form_values['event_start']);
    }
  }
}