SAAS-749, SAAS-753 - Fix for odd linked and repeating show behaviour

This commit is contained in:
Duncan Sommerville 2015-04-30 14:14:56 -04:00
parent 59b90360a1
commit e78bd82c8c
2 changed files with 29 additions and 17 deletions

View File

@ -150,23 +150,27 @@ class Application_Service_CalendarService
$menu["edit"] = array( $menu["edit"] = array(
"name" => _("Edit This Instance"), "name" => _("Edit This Instance"),
"icon" => "edit", "icon" => "edit",
"url" => $baseUrl."Schedule/populate-repeating-show-instance-form"); "url" => $baseUrl . "Schedule/populate-repeating-show-instance-form"
);
} else { } else {
$menu["edit"] = array( $menu["edit"] = array(
"name" => _("Edit"), "name" => _("Edit"),
"icon" => "edit", "icon" => "edit",
"items" => array()); "items" => array()
);
$menu["edit"]["items"]["all"] = array( $menu["edit"]["items"]["all"] = array(
"name" => _("Edit Show"), "name" => _("Edit Show"),
"icon" => "edit", "icon" => "edit",
"url" => $baseUrl."Schedule/populate-show-form"); "url" => $baseUrl . "Schedule/populate-show-form"
);
$menu["edit"]["items"]["instance"] = array( $menu["edit"]["items"]["instance"] = array(
"name" => _("Edit This Instance"), "name" => _("Edit This Instance"),
"icon" => "edit", "icon" => "edit",
"url" => $baseUrl."Schedule/populate-repeating-show-instance-form"); "url" => $baseUrl . "Schedule/populate-repeating-show-instance-form"
} );
}
} else { } else {
$menu["edit"] = array( $menu["edit"] = array(
"name"=> _("Edit Show"), "name"=> _("Edit Show"),

View File

@ -153,14 +153,19 @@ class Application_Service_ShowFormService
if ($ccShowDay->isShowStartInPast()) { if ($ccShowDay->isShowStartInPast()) {
//for a non-repeating show, we should never allow user to change the start time. //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 //for a repeating show, we should allow because the form works as repeating template form
if (!$ccShowDay->isRepeating()) { $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()) {
$form->disableStartDateAndTime(); $form->disableStartDateAndTime();
} else { } else {
list($showStart, $showEnd) = $this->getNextFutureRepeatShowTime(); list($showStart, $showEnd) = $this->getNextFutureRepeatShowTime();
if ($this->hasShowStarted($showStart)) { if ($this->hasShowStarted($showStart)) {
$form->disableStartDateAndTime(); $form->disableStartDateAndTime();
} }
} }*/
} }
$form->populate( $form->populate(
@ -410,9 +415,8 @@ class Application_Service_ShowFormService
//if the show is repeating, set the start date to the next //if the show is repeating, set the start date to the next
//repeating instance in the future //repeating instance in the future
if ($this->ccShow->isRepeating()) { $originalShowStartDateTime = $this->getCurrentOrNextInstanceStartTime();
list($originalShowStartDateTime,) = $this->getNextFutureRepeatShowTime(); if (!$originalShowStartDateTime) {
} else {
$originalShowStartDateTime = $dt; $originalShowStartDateTime = $dt;
} }
@ -421,26 +425,30 @@ class Application_Service_ShowFormService
/** /**
* *
* Returns 2 DateTime objects, in the user's local time, * Returns a DateTime object, in the user's local time,
* of the next future repeat show instance start and end time * of the current or next show instance start time
*
* Returns null if there is no next future repeating show instance
*/ */
public function getNextFutureRepeatShowTime() public function getCurrentOrNextInstanceStartTime()
{ {
$ccShowInstance = CcShowInstancesQuery::create() $ccShowInstance = CcShowInstancesQuery::create()
->filterByDbShowId($this->ccShow->getDbId()) ->filterByDbShowId($this->ccShow->getDbId())
->filterByDbModifiedInstance(false) ->filterByDbModifiedInstance(false)
->filterByDbStarts(gmdate("Y-m-d H:i:s"), Criteria::GREATER_THAN) ->filterByDbStarts(gmdate("Y-m-d"), Criteria::GREATER_EQUAL)
->orderByDbStarts() ->orderByDbStarts()
->findOne(); ->findOne();
if (!$ccShowInstance) {
return null;
}
$starts = new DateTime($ccShowInstance->getDbStarts(), new DateTimeZone("UTC")); $starts = new DateTime($ccShowInstance->getDbStarts(), new DateTimeZone("UTC"));
$ends = new DateTime($ccShowInstance->getDbEnds(), new DateTimeZone("UTC"));
$showTimezone = $this->ccShow->getFirstCcShowDay()->getDbTimezone(); $showTimezone = $this->ccShow->getFirstCcShowDay()->getDbTimezone();
$starts->setTimezone(new DateTimeZone($showTimezone)); $starts->setTimezone(new DateTimeZone($showTimezone));
$ends->setTimezone(new DateTimeZone($showTimezone));
return array($starts, $ends); return $starts;
} }