CC-3875: Dashboard: User shouldn't be able to set currently playing shows end time in the past

- fixed
This commit is contained in:
James 2012-06-07 12:25:21 -04:00
parent 3c7f3d52e1
commit fb48184629
1 changed files with 9 additions and 1 deletions
airtime_mvc/application/forms

View File

@ -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];