From fb48184629daac680603850c74c80eab7ee04dd9 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 7 Jun 2012 12:25:21 -0400 Subject: [PATCH] CC-3875: Dashboard: User shouldn't be able to set currently playing shows end time in the past - fixed --- airtime_mvc/application/forms/AddShowWhen.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/forms/AddShowWhen.php b/airtime_mvc/application/forms/AddShowWhen.php index 270af52bf..73405e5a1 100644 --- a/airtime_mvc/application/forms/AddShowWhen.php +++ b/airtime_mvc/application/forms/AddShowWhen.php @@ -83,14 +83,16 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm } - public function checkReliantFields($formData, $validateStartDate, $originalStartDate=false) { + public function checkReliantFields($formData, $validateStartDate, $originalStartDate=null) { $valid = true; $start_time = $formData['add_show_start_date']." ".$formData['add_show_start_time']; + $end_time = $formData['add_show_end_date_no_repeat']." ".$formData['add_show_end_time']; //DateTime stores $start_time in the current timezone $nowDateTime = new DateTime(); $showStartDateTime = new DateTime($start_time); + $showEndDateTime = new DateTime($end_time); if ($validateStartDate){ if($showStartDateTime->getTimestamp() < $nowDateTime->getTimestamp()) { $this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past')); @@ -108,6 +110,12 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm } } + // if end time is in the past, return error + if($showEndDateTime->getTimestamp() < $nowDateTime->getTimestamp()) { + $this->getElement('add_show_end_time')->setErrors(array('End date/time cannot be in the past')); + $valid = false; + } + $pattern = '/([0-9][0-9])h ([0-9][0-9])m/'; preg_match($pattern, $formData['add_show_duration'], $matches); $hours = $matches[1];