CC-3837: Calendar -> Add Show: Show's duration check does actually allow to create less than 25 hours' show.
-fixed to only allow 24h or less
This commit is contained in:
parent
25ff2b3c3a
commit
19d5655779
|
@ -67,19 +67,19 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
||||||
|
|
||||||
// Add duration element
|
// Add duration element
|
||||||
$this->addElement('text', 'add_show_duration', array(
|
$this->addElement('text', 'add_show_duration', array(
|
||||||
'label' => 'Duration:',
|
'label' => 'Duration:',
|
||||||
'class' => 'input_text',
|
'class' => 'input_text',
|
||||||
'value' => '01h 00m',
|
'value' => '01h 00m',
|
||||||
'readonly' => true,
|
'readonly' => true,
|
||||||
'decorators' => array('ViewHelper')
|
'decorators' => array('ViewHelper')
|
||||||
));
|
));
|
||||||
|
|
||||||
// Add repeats element
|
// Add repeats element
|
||||||
$this->addElement('checkbox', 'add_show_repeats', array(
|
$this->addElement('checkbox', 'add_show_repeats', array(
|
||||||
'label' => 'Repeats?',
|
'label' => 'Repeats?',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'decorators' => array('ViewHelper')
|
'decorators' => array('ViewHelper')
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,21 +92,25 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
||||||
$nowDateTime = new DateTime();
|
$nowDateTime = new DateTime();
|
||||||
$showStartDateTime = new DateTime($start_time);
|
$showStartDateTime = new DateTime($start_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'));
|
||||||
$valid = false;
|
$valid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$hours = intval(substr($formData["add_show_duration"], 0, strpos($formData["add_show_duration"], 'h')));
|
||||||
|
$minutes = intval(substr($formData["add_show_duration"], -3, -1));
|
||||||
if( $formData["add_show_duration"] == "00h 00m" ) {
|
if( $formData["add_show_duration"] == "00h 00m" ) {
|
||||||
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration 00h 00m'));
|
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration 00h 00m'));
|
||||||
$valid = false;
|
$valid = false;
|
||||||
}elseif(strpos($formData["add_show_duration"], 'h') !== false && intval(substr($formData["add_show_duration"], 0, strpos($formData["add_show_duration"], 'h'))) > 24) {
|
}elseif(strpos($formData["add_show_duration"], 'h') !== false && $hours >= 24) {
|
||||||
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration greater than 24h'));
|
if ($hours > 24 || ($hours == 24 && $minutes > 0)) {
|
||||||
$valid = false;
|
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration greater than 24h'));
|
||||||
|
$valid = false;
|
||||||
|
}
|
||||||
}elseif( strstr($formData["add_show_duration"], '-') ){
|
}elseif( strstr($formData["add_show_duration"], '-') ){
|
||||||
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration < 0m'));
|
$this->getElement('add_show_duration')->setErrors(array('Cannot have duration < 0m'));
|
||||||
$valid = false;
|
$valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue