From 254ebb709e3cb7f306b135ad1f7df0a36ea03e42 Mon Sep 17 00:00:00 2001 From: denise Date: Wed, 15 May 2013 11:25:30 -0400 Subject: [PATCH] CC-5151: Calendar -> Remove all content -> Does not update scheduled flag in library --- .../application/services/SchedulerService.php | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/airtime_mvc/application/services/SchedulerService.php b/airtime_mvc/application/services/SchedulerService.php index c5eb0a504..b8403bcd0 100644 --- a/airtime_mvc/application/services/SchedulerService.php +++ b/airtime_mvc/application/services/SchedulerService.php @@ -289,23 +289,39 @@ class Application_Service_SchedulerService $ccShowInstance = CcShowInstancesQuery::create()->findPk($instanceId); $instances = array(); + $instanceIds = array(); if ($ccShowInstance->getCcShow()->isLinked()) { - $instanceIds = array(); foreach ($ccShowInstance->getCcShow()->getCcShowInstancess() as $instance) { $instanceIds[] = $instance->getDbId(); $instances[] = $instance; } - CcScheduleQuery::create() - ->filterByDbInstanceId($instanceIds, Criteria::IN) - ->delete(); } else { + $instanceIds[] = $ccShowInstance->getDbId(); $instances[] = $ccShowInstance; - CcScheduleQuery::create() - ->filterByDbInstanceId($ccShowInstance->getDbId()) - ->delete(); } + /* Update the is_scheduled flag in cc_files to false + * We need to do this before we delete the scheduled items + */ + $ccSchedules = CcScheduleQuery::create() + ->filterByDbInstanceId($instanceIds, Criteria::IN) + ->find(); + $fileIds = array(); + foreach ($ccSchedules as $ccSchedule) { + $fileIds[] = $ccSchedule->getDbFileId(); + } + $selectCriteria = new Criteria(); + $selectCriteria->add(CcFilesPeer::ID, $fileIds, Criteria::IN); + $updateCriteria = new Criteria(); + $updateCriteria->add(CcFilesPeer::IS_SCHEDULED, false); + BasePeer::doUpdate($selectCriteria, $updateCriteria, Propel::getConnection()); + + /* Clear out the schedule */ + CcScheduleQuery::create() + ->filterByDbInstanceId($instanceIds, Criteria::IN) + ->delete(); + Application_Model_RabbitMq::PushSchedule(); $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME); foreach ($instances as $instance) {