diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index a0429bf17..3e84b4940 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -760,7 +760,8 @@ class ScheduleController extends Zend_Controller_Action } $data['add_show_record'] = $show->isRecorded(); - $success = Application_Model_Schedule::addUpdateShow($data, $this, $validateStartDate); + $origianlShowStartDateTime = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartDateAndTime()); + $success = Application_Model_Schedule::addUpdateShow($data, $this, $validateStartDate, $origianlShowStartDateTime); if ($success){ $this->view->addNewShow = true; diff --git a/airtime_mvc/application/forms/AddShowWhen.php b/airtime_mvc/application/forms/AddShowWhen.php index 50a7ec5a0..fb0f361d4 100644 --- a/airtime_mvc/application/forms/AddShowWhen.php +++ b/airtime_mvc/application/forms/AddShowWhen.php @@ -83,7 +83,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm } - public function checkReliantFields($formData, $validateStartDate) { + public function checkReliantFields($formData, $validateStartDate, $originalStartDate=false) { $valid = true; $start_time = $formData['add_show_start_date']." ".$formData['add_show_start_time']; @@ -91,12 +91,19 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm //DateTime stores $start_time in the current timezone $nowDateTime = new DateTime(); $showStartDateTime = new DateTime($start_time); - if ($validateStartDate){ if($showStartDateTime->getTimestamp() < $nowDateTime->getTimestamp()) { $this->getElement('add_show_start_time')->setErrors(array('Cannot create show in the past')); $valid = false; } + // if edit action, check if original show start time is in the past. CC-3864 + if($originalStartDate){ + if($originalStartDate->getTimestamp() < $nowDateTime->getTimestamp()) { + $this->getElement('add_show_start_time')->setErrors(array('Cannot modify start date/time of the show that is already started')); + $this->disableStartDateAndTime(); + $valid = false; + } + } } $pattern = '/([0-9][0-9])h ([0-9][0-9])m/'; diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 05b527ee0..338923877 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -750,7 +750,7 @@ class Application_Model_Schedule { * Another clean-up is to move all the form manipulation to the proper form class..... * -Martin */ - public static function addUpdateShow($data, $controller, $validateStartDate){ + public static function addUpdateShow($data, $controller, $validateStartDate, $originalStartDate=null){ $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new Application_Model_User($userInfo->id); @@ -777,7 +777,7 @@ class Application_Model_Schedule { $when = $formWhen->isValid($data); $live = $formLive->isValid($data); if($when) { - $when = $formWhen->checkReliantFields($data, $validateStartDate); + $when = $formWhen->checkReliantFields($data, $validateStartDate, $originalStartDate); } //The way the following code works is that is parses the hour and