Removed unused function.
Removed commented out code. Renamed fillNewLinkedInstances to fillLinkedInstances. Streamline show instance content if a show goes from unlinked to linked.
This commit is contained in:
parent
11de8bd988
commit
6249deb1ac
|
@ -295,24 +295,6 @@ class CcShow extends BaseCcShow {
|
|||
}
|
||||
return $instanceIds;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns all show instances ordered by 'starts' column in desc order.
|
||||
*/
|
||||
public function getInstanceIdsSortedByMostRecentStartTime()
|
||||
{
|
||||
$instances = CcShowInstancesQuery::create()
|
||||
->filterByCcShow($this)
|
||||
->filterByDbModifiedInstance(false)
|
||||
->orderByDbStarts(Criteria::DESC)
|
||||
->find();
|
||||
|
||||
$instanceIdsDescOrder = array();
|
||||
foreach ($instances as $instance) {
|
||||
$instanceIdsDescOrder[] = $instance->getDbId();
|
||||
}
|
||||
return $instanceIdsDescOrder;
|
||||
}
|
||||
|
||||
//what is this??
|
||||
public function getOtherInstances($instanceId)
|
||||
|
|
|
@ -153,46 +153,59 @@ class Application_Service_SchedulerService
|
|||
/**
|
||||
*
|
||||
* Gets a copy of the linked show's schedule from cc_schedule table
|
||||
* The schedule is taken from the most recent show instance that existed
|
||||
* before new show instances were created.
|
||||
*
|
||||
* If $instanceId is not null, we use that variable to grab the linked
|
||||
* show's schedule from cc_schedule table. (This is likely to be the case
|
||||
* if a user has edited a show and changed it from un-linked to linked, in
|
||||
* which case we copy the show content from the show instance that was clicked
|
||||
* on to edit the show in the calendar.) Otherwise the schedule is taken
|
||||
* from the most recent show instance that existed before new show
|
||||
* instances were created. (This is likely to be the case when a user edits a
|
||||
* show and a new repeat show day is added (i.e. mondays), or moves forward in the
|
||||
* calendar triggering show creation)
|
||||
*
|
||||
* @param integer $showId
|
||||
* @param array $instancsIdsToFill
|
||||
* @param integer $instanceId
|
||||
*/
|
||||
public static function getLinkedShowSchedule($showId, $instancsIdsToFill)
|
||||
private static function getLinkedShowSchedule($showId, $instancsIdsToFill, $instanceId)
|
||||
{
|
||||
$showsPopulatedUntil = Application_Model_Preference::GetShowsPopulatedUntil();
|
||||
|
||||
|
||||
$showInstanceWithMostRecentSchedule = CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($showId)
|
||||
->filterByDbStarts($showsPopulatedUntil->format("Y-m-d H:i:s"), Criteria::LESS_THAN)
|
||||
->filterByDbId($instancsIdsToFill, Criteria::NOT_IN)
|
||||
->orderByDbStarts(Criteria::DESC)
|
||||
->limit(1)
|
||||
->findOne();
|
||||
|
||||
$con = Propel::getConnection();
|
||||
$instanceId = $showInstanceWithMostRecentSchedule->getDbId();
|
||||
|
||||
if (is_null($instanceId)) {
|
||||
$showsPopulatedUntil = Application_Model_Preference::GetShowsPopulatedUntil();
|
||||
|
||||
$showInstanceWithMostRecentSchedule = CcShowInstancesQuery::create()
|
||||
->filterByDbShowId($showId)
|
||||
->filterByDbStarts($showsPopulatedUntil->format("Y-m-d H:i:s"), Criteria::LESS_THAN)
|
||||
->filterByDbId($instancsIdsToFill, Criteria::NOT_IN)
|
||||
->orderByDbStarts(Criteria::DESC)
|
||||
->limit(1)
|
||||
->findOne();
|
||||
|
||||
$instanceId = $showInstanceWithMostRecentSchedule->getDbId();
|
||||
}
|
||||
|
||||
$linkedShowSchedule_sql = $con->prepare(
|
||||
"select * from cc_schedule where instance_id = :instance_id ".
|
||||
"order by starts");
|
||||
$linkedShowSchedule_sql->bindParam(':instance_id', $instanceId);
|
||||
$linkedShowSchedule_sql->execute();
|
||||
|
||||
|
||||
return $linkedShowSchedule_sql->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This function gets called after new linked show_instances are created.
|
||||
* This function gets called after new linked show_instances are created, or after
|
||||
* a show has been edited and went from being un-linked to linked.
|
||||
* It fills the new show instances' schedules.
|
||||
*
|
||||
* @param CcShow_type $ccShow
|
||||
* @param array $instanceIdsToFill ids of the new linked cc_show_instances that
|
||||
* were created and now need their schedules filled
|
||||
* need their schedules filled
|
||||
*/
|
||||
public static function fillNewLinkedInstances($ccShow, $instanceIdsToFill)
|
||||
public static function fillLinkedInstances($ccShow, $instanceIdsToFill, $instanceId=null)
|
||||
{
|
||||
//TODO can we remove the code until line 216 ??
|
||||
|
||||
|
@ -230,7 +243,7 @@ class Application_Service_SchedulerService
|
|||
|
||||
//Get the "template" schedule for the linked show (contents of the linked show) that will be
|
||||
//copied into to all the new show instances.
|
||||
$linkedShowSchedule = self::getLinkedShowSchedule($ccShow->getDbId(), $instanceIdsToFill);
|
||||
$linkedShowSchedule = self::getLinkedShowSchedule($ccShow->getDbId(), $instanceIdsToFill, $instanceId);
|
||||
|
||||
//get time_filled so we can update cc_show_instances
|
||||
if (!empty($linkedShowSchedule)) {
|
||||
|
|
|
@ -15,7 +15,6 @@ class Application_Service_ShowService
|
|||
private $isRebroadcast;
|
||||
private $repeatType;
|
||||
private $isUpdate;
|
||||
/*private $linkedShowContent;*/
|
||||
private $oldShowTimezone;
|
||||
private $localShowStartHour;
|
||||
private $localShowStartMin;
|
||||
|
@ -199,6 +198,7 @@ class Application_Service_ShowService
|
|||
$daysAdded = array();
|
||||
|
||||
if ($this->isUpdate) {
|
||||
|
||||
if (!$this->ccShow->getCcShowDayss()->isEmpty()) {
|
||||
$this->storeOrigLocalShowInfo();
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ class Application_Service_ShowService
|
|||
|
||||
foreach ($ccShows as $ccShow) {
|
||||
if (($this->isUpdate || $fillInstances) && $ccShow->isLinked()) {
|
||||
Application_Service_SchedulerService::fillNewLinkedInstances(
|
||||
Application_Service_SchedulerService::fillLinkedInstances(
|
||||
$ccShow, $this->newInstanceIdsCreated[$ccShow->getDbId()]);
|
||||
}
|
||||
}
|
||||
|
@ -1145,16 +1145,13 @@ SQL;
|
|||
if ($this->hasInstance($utcStartDateTime)) {
|
||||
$ccShowInstance = $this->getInstance($utcStartDateTime);
|
||||
$newInstance = false;
|
||||
//$updateScheduleStatus = true;
|
||||
} else {
|
||||
$newInstance = true;
|
||||
$ccShowInstance = new CcShowInstances();
|
||||
//$updateScheduleStatus = false;
|
||||
}
|
||||
} else {
|
||||
$newInstance = true;
|
||||
$ccShowInstance = new CcShowInstances();
|
||||
//$updateScheduleStatus = false;
|
||||
}
|
||||
|
||||
/* When editing the start/end time of a repeating show, we don't want to
|
||||
|
@ -1247,11 +1244,9 @@ SQL;
|
|||
if ($this->isUpdate && $this->hasInstance($utcStartDateTime)) {
|
||||
$ccShowInstance = $this->getInstance($utcStartDateTime);
|
||||
$newInstance = false;
|
||||
//$updateScheduleStatus = true;
|
||||
} else {
|
||||
$newInstance = true;
|
||||
$ccShowInstance = new CcShowInstances();
|
||||
//$updateScheduleStatus = false;
|
||||
}
|
||||
|
||||
/* When editing the start/end time of a repeating show, we don't want to
|
||||
|
@ -1520,10 +1515,14 @@ SQL;
|
|||
$ccShow->setDbLiveStreamUsingCustomAuth($showData['cb_custom_auth'] == 1);
|
||||
$ccShow->setDbLiveStreamUser($showData['custom_username']);
|
||||
$ccShow->setDbLiveStreamPass($showData['custom_password']);
|
||||
|
||||
// Once a show is unlinked it cannot be linked again
|
||||
if ($ccShow->getDbLinked() && !$showData["add_show_linked"]) {
|
||||
$ccShow->setDbIsLinkable(false);
|
||||
|
||||
//Here a user has edited a show and linked it.
|
||||
//We need to grab the existing show instances ids and fill their content
|
||||
//with the content from the show instance that was clicked on to edit the show.
|
||||
//We do this because linked show instances need to have the same content in each.
|
||||
if ($this->isUpdate && (!$ccShow->getDbLinked() && $showData["add_show_linked"])) {
|
||||
$existingShowInstanceIds = $ccShow->getFutureInstanceIds(new Criteria());
|
||||
Application_Service_SchedulerService::fillLinkedInstances($ccShow, $existingShowInstanceIds, $showData["add_show_instance_id"]);
|
||||
}
|
||||
$ccShow->setDbLinked($showData["add_show_linked"]);
|
||||
|
||||
|
|
|
@ -273,9 +273,16 @@ function setAddShowEvents(form) {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$(this).attr("checked") && $("#show-link-warning").length === 0) {
|
||||
$(this).parent().after("<ul id='show-link-warning' class='errors'><li>"+$.i18n._("Warning: Shows cannot be re-linked")+"</li></ul>");
|
||||
|
||||
//only display the warning message if a show is being edited
|
||||
if ($(".button-bar.bottom").find(".ui-button-text").text() === "Update show") {
|
||||
if ($(this).attr("checked") && $("#show-link-warning").length === 0) {
|
||||
$(this).parent().after("<ul id='show-link-warning' class='errors'><li>"+$.i18n._("Warning: A copy of the schedule from the show clicked on to edit this show will get copied to every other show in the repeat series.")+"</li></ul>");
|
||||
}
|
||||
|
||||
if (!$(this).attr("checked") && $("#show-link-warning").length !== 0) {
|
||||
$("#show-link-warning").remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue