CC-3875: Dashboard: User shouldn't be able to set currently playing shows end time in the past
- fixed
This commit is contained in:
parent
3c7f3d52e1
commit
fb48184629
1 changed files with 9 additions and 1 deletions
|
@ -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;
|
$valid = true;
|
||||||
|
|
||||||
$start_time = $formData['add_show_start_date']." ".$formData['add_show_start_time'];
|
$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
|
//DateTime stores $start_time in the current timezone
|
||||||
$nowDateTime = new DateTime();
|
$nowDateTime = new DateTime();
|
||||||
$showStartDateTime = new DateTime($start_time);
|
$showStartDateTime = new DateTime($start_time);
|
||||||
|
$showEndDateTime = new DateTime($end_time);
|
||||||
if ($validateStartDate){
|
if ($validateStartDate){
|
||||||
if($showStartDateTime->getTimestamp() < $nowDateTime->getTimestamp()) {
|
if($showStartDateTime->getTimestamp() < $nowDateTime->getTimestamp()) {
|
||||||
$this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past'));
|
$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/';
|
$pattern = '/([0-9][0-9])h ([0-9][0-9])m/';
|
||||||
preg_match($pattern, $formData['add_show_duration'], $matches);
|
preg_match($pattern, $formData['add_show_duration'], $matches);
|
||||||
$hours = $matches[1];
|
$hours = $matches[1];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue