Merge branch 'saas-dev' of github.com:sourcefabric/airtime into saas-dev

This commit is contained in:
Duncan Sommerville 2015-07-13 13:23:39 -04:00
commit d9117721b9
1 changed files with 31 additions and 9 deletions

View File

@ -155,19 +155,18 @@ class Application_Service_ShowFormService
if ($ccShowDay->isShowStartInPast()) {
//for a non-repeating show, we should never allow user to change the start time.
//for a repeating show, we should allow because the form works as repeating template form
$form->disableStartDateAndTime();
// Removing this - if there is no future instance, this will throw an error.
// If there is a future instance, then we get a WHEN block representing the next instance
// which may be confusing.
/*if (!$ccShowDay->isRepeating()) {
if (!$ccShowDay->isRepeating()) {
$form->disableStartDateAndTime();
} else {
list($showStart, $showEnd) = $this->getNextFutureRepeatShowTime();
$showStartAndEnd = $this->getNextFutureRepeatShowTime();
if (!is_null($showStartAndEnd)) {
$showStart = $showStartAndEnd["starts"];
$showEnd = $showStartAndEnd["ends"];
}
if ($this->hasShowStarted($showStart)) {
$form->disableStartDateAndTime();
}
}*/
}
}
$form->populate(
@ -183,6 +182,29 @@ class Application_Service_ShowFormService
return $showStart;
}
public function getNextFutureRepeatShowTime()
{
$ccShowInstance = CcShowInstancesQuery::create()
->filterByDbShowId($this->ccShow->getDbId())
->filterByDbModifiedInstance(false)
->filterByDbStarts(gmdate("Y-m-d H:i:s"), Criteria::GREATER_THAN)
->orderByDbStarts()
->findOne();
if (!$ccShowInstance) {
return null;
}
$starts = new DateTime($ccShowInstance->getDbStarts(), new DateTimeZone("UTC"));
$ends = new DateTime($ccShowInstance->getDbEnds(), new DateTimeZone("UTC"));
$showTimezone = $this->ccShow->getFirstCcShowDay()->getDbTimezone();
$starts->setTimezone(new DateTimeZone($showTimezone));
$ends->setTimezone(new DateTimeZone($showTimezone));
return array("starts" => $starts, "ends" => $ends);
}
private function populateInstanceFormWhen($form)
{
$ccShowInstance = CcShowInstancesQuery::create()->findPk($this->instanceId);
@ -437,7 +459,7 @@ class Application_Service_ShowFormService
$ccShowInstance = CcShowInstancesQuery::create()
->filterByDbShowId($this->ccShow->getDbId())
->filterByDbModifiedInstance(false)
->filterByDbStarts(gmdate("Y-m-d"), Criteria::GREATER_EQUAL)
->filterByDbStarts(gmdate("Y-m-d H:i:s"), Criteria::GREATER_EQUAL)
->orderByDbStarts()
->findOne();