diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 8d9382717..32e2a3fc6 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -190,8 +190,9 @@ class ScheduleController extends Zend_Controller_Action if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { try { - $showInstance = new Application_Model_ShowInstance($showInstanceId); + $showInstance = new Application_Model_ShowInstance($showInstanceId); } catch (Exception $e) { + Logging::info($e->getMessage()); $this->view->show_error = true; return false; diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index eb538f57f..4914302b6 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -558,6 +558,7 @@ WHERE st.ends > :startTime1 AND st.starts < :endTime AND st.playout_status > 0 AND si.ends > :startTime2 + AND si.modified_instance = 'f' ORDER BY st.starts SQL; @@ -578,6 +579,7 @@ WHERE st.ends > :startTime1 AND st.starts < :rangeEnd AND st.playout_status > 0 AND si.ends > :startTime2 + AND si.modified_instance = 'f' ORDER BY st.starts LIMIT 3 SQL; diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 4cb90d1bc..7f905b687 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -275,8 +275,6 @@ SQL; public function cancelShow($day_timestamp) { - $con = Propel::getConnection(); - $timeinfo = explode(" ", $day_timestamp); CcShowDaysQuery::create() @@ -284,30 +282,23 @@ SQL; ->update(array('DbLastShow' => $timeinfo[0])); $sql = <<= :dayTimestamp::TIMESTAMP AND show_id = :showId SQL; - - Application_Common_Database::prepareAndExecute( $sql, array( + + $rows = Application_Common_Database::prepareAndExecute( $sql, array( ':dayTimestamp' => $day_timestamp, - ':showId' => $this->getId()), 'execute'); + ':showId' => $this->getId()), 'all'); - // check if we can safely delete the show - $showInstancesRow = CcShowInstancesQuery::create() - ->filterByDbShowId($this->_showId) - ->filterByDbModifiedInstance(false) - ->findOne(); - - if (is_null($showInstancesRow)) { - $sql = << $this->_showId ), "execute"); - $con->exec($sql); - } + foreach ($rows as $row) { + try { + $showInstance = new Application_Model_ShowInstance($row["id"]); + $showInstance->delete($rabbitmqPush = false); + } catch (Exception $e) { + Logging::info($e->getMessage()); + } + } Application_Model_RabbitMq::PushSchedule(); } diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index e6a3dcc58..f88a1d63a 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -518,7 +518,7 @@ SQL; return false; } - public function delete() + public function delete($rabbitmqPush = true) { // see if it was recording show $recording = $this->isRecorded(); @@ -568,7 +568,9 @@ SQL; } } - Application_Model_RabbitMq::PushSchedule(); + if ($rabbitmqPush) { + Application_Model_RabbitMq::PushSchedule(); + } } public function setRecordedFile($file_id)