CC-4528: Calendar: Can drag and drop current show into past (it's forbidden to set it by editing show)

-fixed
This commit is contained in:
denise 2012-10-09 14:20:00 -04:00
parent 279737751b
commit dc410f4289

View file

@ -179,14 +179,19 @@ SQL;
if ($deltaDay > 0) { if ($deltaDay > 0) {
return "Shows can have a max length of 24 hours."; return "Shows can have a max length of 24 hours.";
} }
$utc = new DateTimeZone("UTC");
$nowDateTime = new DateTime("now", $utc);
$showInstances = CcShowInstancesQuery::create() $showInstances = CcShowInstancesQuery::create()
->filterByDbShowId($this->_showId) ->filterByDbShowId($this->_showId)
->find($con); ->find($con);
/* Check if the show being resized and any of its repeats * overlap /* Check two things:
with other scheduled shows */ 1. If the show being resized and any of its repeats end in the past
$utc = new DateTimeZone("UTC"); 2. If the show being resized and any of its repeats overlap
with other scheduled shows */
foreach ($showInstances as $si) { foreach ($showInstances as $si) {
$startsDateTime = new DateTime($si->getDbStarts(), new DateTimeZone("UTC")); $startsDateTime = new DateTime($si->getDbStarts(), new DateTimeZone("UTC"));
@ -201,6 +206,10 @@ SQL;
$newStartsDateTime = Application_Model_ShowInstance::addDeltas($startsDateTime, $deltaDay, $deltaMin); $newStartsDateTime = Application_Model_ShowInstance::addDeltas($startsDateTime, $deltaDay, $deltaMin);
$newEndsDateTime = Application_Model_ShowInstance::addDeltas($endsDateTime, $deltaDay, $deltaMin); $newEndsDateTime = Application_Model_ShowInstance::addDeltas($endsDateTime, $deltaDay, $deltaMin);
if ($newEndsDateTime->getTimestamp() < $nowDateTime->getTimestamp()) {
return "End date/time cannot be in the past";
}
//convert our new starts/ends to UTC. //convert our new starts/ends to UTC.
$newStartsDateTime->setTimezone($utc); $newStartsDateTime->setTimezone($utc);