CC-5594 : Remove all date_default_timezone_get()
removing now unused old methods
This commit is contained in:
parent
c9773d2a0e
commit
e6808b0c12
|
@ -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 = <<<SQL
|
||||
SELECT starts
|
||||
FROM cc_show_instances
|
||||
WHERE instance_id =
|
||||
(SELECT id
|
||||
FROM cc_show_instances
|
||||
WHERE show_id = :showId
|
||||
ORDER BY starts LIMIT 1)
|
||||
AND rebroadcast = 1
|
||||
ORDER BY starts
|
||||
SQL;
|
||||
|
||||
$rebroadcasts = Application_Common_Database::prepareAndExecute( $sql,
|
||||
array( 'showId' => $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.
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -340,6 +340,7 @@ class Application_Service_CalendarService
|
|||
}
|
||||
}
|
||||
|
||||
//TODO move the method resizeShow from Application_Model_Show here.
|
||||
public function resizeShow($deltaDay, $deltaMin)
|
||||
{
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue