From e6808b0c123b5458eefc6aa0d0bbf6a64c0c8efb Mon Sep 17 00:00:00 2001 From: Naomi Date: Wed, 4 Dec 2013 14:31:23 -0500 Subject: [PATCH] CC-5594 : Remove all date_default_timezone_get() removing now unused old methods --- airtime_mvc/application/models/Show.php | 151 ------------------ .../application/models/ShowInstance.php | 85 ---------- .../application/services/CalendarService.php | 1 + 3 files changed, 1 insertion(+), 236 deletions(-) diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index d4ff8a972..9cbf6f614 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -424,55 +424,6 @@ SQL; return !is_null($showInstancesRow); } - /** - * Get start time and absolute start date for a recorded - * shows rebroadcasts. For example start date format would be - * YYYY-MM-DD and time would HH:MM - * - * @return array - * array of associate arrays containing "start_date" and "start_time" - */ - public function getRebroadcastsAbsolute() - { - $sql = << $this->getId() ), 'all' ); - - $rebroadcastsLocal = array(); - //get each rebroadcast show in cc_show_instances, convert to current timezone to get start date/time. - /*TODO: refactor the following code to get rid of the $i temporary - variable. -- RG*/ - $i = 0; - - $utc = new DateTimeZone("UTC"); - $dtz = new DateTimeZone( date_default_timezone_get() ); - - foreach ($rebroadcasts as $show) { - $startDateTime = new DateTime($show["starts"], $utc); - $startDateTime->setTimezone($dtz); - - $rebroadcastsLocal[$i]["start_date"] = - $startDateTime->format("Y-m-d"); - $rebroadcastsLocal[$i]["start_time"] = - $startDateTime->format("H:i"); - - $i = $i + 1; - } - - return $rebroadcastsLocal; - } - /** * Get start time and relative start date for a recorded * shows rebroadcasts. For example start date format would be @@ -781,67 +732,6 @@ SQL; ':timestamp' => $timestamp), "execute"); } - private function updateStartDateTime($p_data, $p_endDate) - { - $date = new Application_Common_DateHelper; - $timestamp = $date->getTimestamp(); - - //TODO fix this from overwriting info. - $sql = "UPDATE cc_show_days " - ."SET start_time = :start_time::time, " - ."first_show = :start_date::date, "; - if (strlen ($p_endDate) == 0) { - $sql .= "last_show = NULL "; - } else { - $sql .= "last_show = :end_date::date"; - } - $sql .= "WHERE show_id = :show_id"; - - $map = array(":start_time" => $p_data['add_show_start_time'], - ':start_date' => $p_data['add_show_start_date'], - ':end_date' => $p_endDate, - ':show_id' => $p_data['add_show_id'], - ); - - $res = Application_Common_Database::prepareAndExecute($sql, $map, - Application_Common_Database::EXECUTE); - - $dtOld = new DateTime($this->getStartDate()." ".$this->getStartTime(), new DateTimeZone("UTC")); - $dtNew = new DateTime($p_data['add_show_start_date']." ".$p_data['add_show_start_time'], - new DateTimeZone(date_default_timezone_get())); - $diff = $dtOld->getTimestamp() - $dtNew->getTimestamp(); - - $sql = "UPDATE cc_show_instances " - ."SET starts = starts + :diff1::interval, " - ."ends = ends + :diff2::interval " - ."WHERE show_id = :show_id " - ."AND starts > :timestamp::timestamp"; - $map = array( - ":diff1"=>"$diff sec", - ":diff2"=>"$diff sec", - ":show_id"=>$p_data['add_show_id'], - ":timestamp"=>$timestamp, - ); - $res = Application_Common_Database::prepareAndExecute($sql, $map, - Application_Common_Database::EXECUTE); - - $showInstanceIds = $this->getAllFutureInstanceIds(); - if (count($showInstanceIds) > 0 && $diff != 0) { - $showIdsImploded = implode(",", $showInstanceIds); - $sql = "UPDATE cc_schedule " - ."SET starts = starts + :diff1::interval, " - ."ends = ends + :diff2::interval " - ."WHERE instance_id IN (:show_ids)"; - $map = array( - ":diff1"=>"$diff sec", - ":diff2"=>"$diff sec", - ":show_ids"=>$showIdsImploded, - ); - $res = Application_Common_Database::prepareAndExecute($sql, $map, - Application_Common_Database::EXECUTE); - } - } - public function getDuration($format=false) { $showDay = CcShowDaysQuery::create()->filterByDbShowId($this->getId())->findOne(); @@ -1185,47 +1075,6 @@ SQL; return $percent; } - /* Takes in a UTC DateTime object. - * Converts this to local time, since cc_show days - * requires local time. */ - public function setShowFirstShow($p_dt) - { - //clone object since we are modifying it and it was passed by reference. - $dt = clone $p_dt; - - $dt->setTimezone(new DateTimeZone(date_default_timezone_get())); - - $showDay = CcShowDaysQuery::create() - ->filterByDbShowId($this->_showId) - ->findOne(); - - $showDay->setDbFirstShow($dt)->setDbStartTime($dt) - ->save(); - - //Logging::info("setting show's first show."); - } - - /* Takes in a UTC DateTime object - * Converts this to local time, since cc_show days - * requires local time. */ - public function setShowLastShow($p_dt) - { - //clone object since we are modifying it and it was passed by reference. - $dt = clone $p_dt; - - $dt->setTimezone(new DateTimeZone(date_default_timezone_get())); - - //add one day since the Last Show date in CcShowDays is non-inclusive. - $dt->add(new DateInterval("P1D")); - - $showDay = CcShowDaysQuery::create() - ->filterByDbShowId($this->_showId) - ->findOne(); - - $showDay->setDbLastShow($dt) - ->save(); - } - /** * Given time $timeNow, returns the show being played right now. * Times are all in UTC time. diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index bae020a7b..57c970048 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -239,91 +239,6 @@ SQL; return $newDateTime; } - public function moveShow($deltaDay, $deltaMin) - { - if ($this->getShow()->isRepeating()) { - return _("Can't drag and drop repeating shows"); - } - - $today_timestamp = time(); - $startsDateTime = new DateTime($this->getShowInstanceStart(), new DateTimeZone("UTC")); - $endsDateTime = new DateTime($this->getShowInstanceEnd(), new DateTimeZone("UTC")); - - if ($today_timestamp > $startsDateTime->getTimestamp()) { - return _("Can't move a past show"); - } - - //the user is moving the show on the calendar from the perspective of local time. - //incase a show is moved across a time change border offsets should be added to the localtime - //stamp and then converted back to UTC to avoid show time changes! - $startsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); - $endsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); - - $newStartsDateTime = self::addDeltas($startsDateTime, $deltaDay, $deltaMin); - $newEndsDateTime = self::addDeltas($endsDateTime, $deltaDay, $deltaMin); - - //convert our new starts/ends to UTC. - $newStartsDateTime->setTimezone(new DateTimeZone("UTC")); - $newEndsDateTime->setTimezone(new DateTimeZone("UTC")); - - if ($today_timestamp > $newStartsDateTime->getTimestamp()) { - return _("Can't move show into past"); - } - - //check if show is overlapping - $overlapping = Application_Model_Schedule::checkOverlappingShows($newStartsDateTime, $newEndsDateTime, true, $this->getShowInstanceId()); - if ($overlapping) { - return _("Cannot schedule overlapping shows"); - } - - if ($this->isRecorded()) { - - //rebroadcasts should start at max 1 hour after a recorded show has ended. - $minRebroadcastStart = self::addDeltas($newEndsDateTime, 0, 60); - //check if we are moving a recorded show less than 1 hour before any of its own rebroadcasts. - $rebroadcasts = CcShowInstancesQuery::create() - ->filterByDbOriginalShow($this->_instanceId) - ->filterByDbStarts($minRebroadcastStart->format('Y-m-d H:i:s'), Criteria::LESS_THAN) - ->find(); - - if (count($rebroadcasts) > 0) { - return _("Can't move a recorded show less than 1 hour before its rebroadcasts."); - } - } - - if ($this->isRebroadcast()) { - - try { - $recordedShow = new Application_Model_ShowInstance($this->_showInstance->getDbOriginalShow()); - } - //recorded show doesn't exist. - catch (Exception $e) { - $this->_showInstance->delete(); - - return _("Show was deleted because recorded show does not exist!"); - } - - $recordEndDateTime = new DateTime($recordedShow->getShowInstanceEnd(), new DateTimeZone("UTC")); - $newRecordEndDateTime = self::addDeltas($recordEndDateTime, 0, 60); - - if ($newStartsDateTime->getTimestamp() < $newRecordEndDateTime->getTimestamp()) { - return _("Must wait 1 hour to rebroadcast."); - } - } - - $this->setShowStart($newStartsDateTime); - $this->setShowEnd($newEndsDateTime); - $this->correctScheduleStartTimes(); - - $show = new Application_Model_Show($this->getShowId()); - if (!$show->isRepeating() && is_null($this->isRebroadcast())) { - $show->setShowFirstShow($newStartsDateTime); - $show->setShowLastShow($newEndsDateTime); - } - - Application_Model_RabbitMq::PushSchedule(); - } - public function resizeShow($deltaDay, $deltaMin) { $con = Propel::getConnection(); diff --git a/airtime_mvc/application/services/CalendarService.php b/airtime_mvc/application/services/CalendarService.php index edb76ebf5..6ad49f97f 100644 --- a/airtime_mvc/application/services/CalendarService.php +++ b/airtime_mvc/application/services/CalendarService.php @@ -340,6 +340,7 @@ class Application_Service_CalendarService } } + //TODO move the method resizeShow from Application_Model_Show here. public function resizeShow($deltaDay, $deltaMin) { try {