From 63a5f45e9bca12402fb1795262d5a7c72f8be459 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 24 Apr 2012 18:22:39 -0400 Subject: [PATCH] CC-3690: Able to create repeat show in the past, by editing an already ON AIR show -fixed --- .../controllers/ScheduleController.php | 5 +-- airtime_mvc/application/models/Show.php | 40 ++++++++----------- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index c5acd6ef3..bdcc4e2b7 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -752,12 +752,11 @@ class ScheduleController extends Zend_Controller_Action //Changing the start date was disabled, since the //array key does not exist. We need to repopulate this entry from the db. //The start date will be returned in UTC time, so lets convert it to local time. - $dt = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartDate()); + $dt = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartDateAndTime()); $data['add_show_start_date'] = $dt->format("Y-m-d"); if (!array_key_exists('add_show_start_time', $data)){ - $startTime = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartTime()); - $data['add_show_start_time'] = $startTime->format("H:i"); + $data['add_show_start_time'] = $dt->format("H:i"); $validateStartTime = false; } $validateStartDate = false; diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 67914093f..3675879b6 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -557,15 +557,15 @@ class Application_Model_Show { $con->exec($sql); } - + /** * Get the start date of the current show in UTC timezone. * * @return string * The start date in the format YYYY-MM-DD */ - public function getStartDate(){ - $con = Propel::getConnection(); + public function getStartDateAndTime(){ + $con = Propel::getConnection(); $showId = $this->getId(); $sql = "SELECT first_show, start_time, timezone FROM cc_show_days" @@ -583,10 +583,21 @@ class Application_Model_Show { $dt = new DateTime($row["first_show"]." ".$row["start_time"], new DateTimeZone($row["timezone"])); $dt->setTimezone(new DateTimeZone("UTC")); - return $dt->format("Y-m-d"); + return $dt->format("Y-m-d H:i"); } } + /** + * Get the start date of the current show in UTC timezone. + * + * @return string + * The start date in the format YYYY-MM-DD + */ + public function getStartDate(){ + list($date,) = explode(" ", $this->getStartDateAndTime()); + return $date; + } + /** * Get the start time of the current show in UTC timezone. * @@ -595,25 +606,8 @@ class Application_Model_Show { */ public function getStartTime(){ - $con = Propel::getConnection(); - - $showId = $this->getId(); - $sql = "SELECT first_show, start_time, timezone FROM cc_show_days" - ." WHERE show_id = $showId" - ." ORDER BY first_show" - ." LIMIT 1"; - - $query = $con->query($sql); - - if ($query->rowCount() == 0){ - return ""; - } else { - $rows = $query->fetchAll(); - $row = $rows[0]; - $dt = new DateTime($row["first_show"]." ".$row["start_time"], new DateTimeZone($row["timezone"])); - $dt->setTimezone(new DateTimeZone("UTC")); - return $dt->format("H:i"); - } + list(,$time) = explode(" ", $this->getStartDateAndTime()); + return $time; } /**