CC-5697: Editing a linked show's repeat day sets wrong day for show content

When a user edits a show and changes the repeat day, we are really deleting the instances from the original
repeat day and creating new instances. Therefore, we don't need to update the show content's start/end time
in this case.
This commit is contained in:
drigato 2014-02-24 14:49:11 -05:00
parent 86dafaf61c
commit 787f19f69a
1 changed files with 8 additions and 10 deletions

View File

@ -20,6 +20,7 @@ class Application_Service_ShowService
private $localShowStartHour; private $localShowStartHour;
private $localShowStartMin; private $localShowStartMin;
private $origCcShowDay; private $origCcShowDay;
private $instanceIdsForScheduleUpdates;
public function __construct($showId=null, $showData=null, $isUpdate=false) public function __construct($showId=null, $showData=null, $isUpdate=false)
{ {
@ -39,6 +40,7 @@ class Application_Service_ShowService
$this->isRecorded = (isset($showData['add_show_record']) && $showData['add_show_record']) ? 1 : 0; $this->isRecorded = (isset($showData['add_show_record']) && $showData['add_show_record']) ? 1 : 0;
$this->isRebroadcast = (isset($showData['add_show_rebroadcast']) && $showData['add_show_rebroadcast']) ? 1 : 0; $this->isRebroadcast = (isset($showData['add_show_rebroadcast']) && $showData['add_show_rebroadcast']) ? 1 : 0;
$this->isUpdate = $isUpdate; $this->isUpdate = $isUpdate;
$this->instanceIdsForScheduleUpdates = array();
} }
public function editRepeatingShowInstance($showData) { public function editRepeatingShowInstance($showData) {
@ -230,12 +232,10 @@ class Application_Service_ShowService
private function adjustSchedule($showData) private function adjustSchedule($showData)
{ {
$con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME); $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
$ccShowInstances = CcShowInstancesQuery::create()
->filterByDbShowId($this->ccShow->getDbId())
->find();
$this->updateScheduleStartEndTimes($showData); $this->updateScheduleStartEndTimes($showData);
$ccShowInstances = $this->ccShow->getCcShowInstancess();
foreach ($ccShowInstances as $instance) { foreach ($ccShowInstances as $instance) {
$instance->updateScheduleStatus($con); $instance->updateScheduleStatus($con);
} }
@ -271,6 +271,7 @@ class Application_Service_ShowService
$ccShows = array(); $ccShows = array();
foreach ($ccShowDays as $day) { foreach ($ccShowDays as $day) {
$this->instanceIdsForScheduleUpdates = array();
$this->ccShow = $day->getCcShow(); $this->ccShow = $day->getCcShow();
$this->isRecorded = $this->ccShow->isRecorded(); $this->isRecorded = $this->ccShow->isRecorded();
@ -881,7 +882,6 @@ SQL;
private function updateScheduleStartEndTimes($showData) private function updateScheduleStartEndTimes($showData)
{ {
$showId = $this->ccShow->getDbId(); $showId = $this->ccShow->getDbId();
//DateTime in show's local time //DateTime in show's local time
$newStartDateTime = new DateTime($showData["add_show_start_date"]." ". $newStartDateTime = new DateTime($showData["add_show_start_date"]." ".
$showData["add_show_start_time"], $showData["add_show_start_time"],
@ -890,12 +890,9 @@ SQL;
$diff = $this->calculateShowStartDiff($newStartDateTime, $diff = $this->calculateShowStartDiff($newStartDateTime,
$this->origCcShowDay->getLocalStartDateAndTime()); $this->origCcShowDay->getLocalStartDateAndTime());
$ccShowInstances = $this->ccShow->getFutureCcShowInstancess(); Application_Service_SchedulerService::updateScheduleStartTime(
$instanceIds = array(); $this->instanceIdsForScheduleUpdates,
foreach ($ccShowInstances as $ccShowInstance) { $diff);
array_push($instanceIds, $ccShowInstance->getDbId());
}
Application_Service_SchedulerService::updateScheduleStartTime($instanceIds, $diff);
} }
/** /**
@ -1070,6 +1067,7 @@ SQL;
$ccShowInstance = $this->getInstance($utcStartDateTime); $ccShowInstance = $this->getInstance($utcStartDateTime);
$newInstance = false; $newInstance = false;
$updateScheduleStatus = true; $updateScheduleStatus = true;
array_push($this->instanceIdsForScheduleUpdates, $ccShowInstance->getDbId());
} else { } else {
$newInstance = true; $newInstance = true;
$ccShowInstance = new CcShowInstances(); $ccShowInstance = new CcShowInstances();