diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 176c88f3c..6699946b4 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -356,9 +356,9 @@ SQL; ." SET media_item_played=TRUE"; // we need to update 'broadcasted' column as well // check the current switch status - $live_dj = Application_Model_Preference::GetSourceSwitchStatus('live_dj') == 'on'?true:false; - $master_dj = Application_Model_Preference::GetSourceSwitchStatus('master_dj') == 'on'?true:false; - $scheduled_play = Application_Model_Preference::GetSourceSwitchStatus('scheduled_play') == 'on'?true:false; + $live_dj = Application_Model_Preference::GetSourceSwitchStatus('live_dj') == 'on'; + $master_dj = Application_Model_Preference::GetSourceSwitchStatus('master_dj') == 'on'; + $scheduled_play = Application_Model_Preference::GetSourceSwitchStatus('scheduled_play') == 'on'; if (!$live_dj && !$master_dj && $scheduled_play) { $sql .= ", broadcasted=1"; @@ -616,23 +616,23 @@ SQL; $temp = explode('.', Application_Model_Preference::GetDefaultTransitionFade()); // we round down transition time since PHP cannot handle millisecond. We need to // handle this better in the future - $transition_time = intval($temp[0]); + $transition_time = intval($temp[0]); $switchOffDataTime = new DateTime($kick_time, $utcTimeZone); - $switch_off_time = $switchOffDataTime->sub(new DateInterval('PT'.$transition_time.'S')); - $switch_off_time = $switch_off_time->format("Y-m-d H:i:s"); + $switch_off_time = $switchOffDataTime->sub(new DateInterval('PT'.$transition_time.'S')); + $switch_off_time = $switch_off_time->format("Y-m-d H:i:s"); $kick_start = Application_Model_Schedule::AirtimeTimeToPypoTime($kick_time); - $data["media"][$kick_start]['start'] = $kick_start; - $data["media"][$kick_start]['end'] = $kick_start; - $data["media"][$kick_start]['event_type'] = "kick_out"; - $data["media"][$kick_start]['type'] = "event"; + $data["media"][$kick_start]['start'] = $kick_start; + $data["media"][$kick_start]['end'] = $kick_start; + $data["media"][$kick_start]['event_type'] = "kick_out"; + $data["media"][$kick_start]['type'] = "event"; $data["media"][$kick_start]['independent_event'] = true; if ($kick_time !== $switch_off_time) { $switch_start = Application_Model_Schedule::AirtimeTimeToPypoTime($switch_off_time); - $data["media"][$switch_start]['start'] = $switch_start; - $data["media"][$switch_start]['end'] = $switch_start; - $data["media"][$switch_start]['event_type'] = "switch_off"; + $data["media"][$switch_start]['start'] = $switch_start; + $data["media"][$switch_start]['end'] = $switch_start; + $data["media"][$switch_start]['event_type'] = "switch_off"; $data["media"][$switch_start]['independent_event'] = true; } } @@ -757,12 +757,12 @@ SQL; { $isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true; - $formWhat = new Application_Form_AddShowWhat(); - $formWho = new Application_Form_AddShowWho(); - $formWhen = new Application_Form_AddShowWhen(); + $formWhat = new Application_Form_AddShowWhat(); + $formWho = new Application_Form_AddShowWho(); + $formWhen = new Application_Form_AddShowWhen(); $formRepeats = new Application_Form_AddShowRepeats(); - $formStyle = new Application_Form_AddShowStyle(); - $formLive = new Application_Form_AddShowLiveStream(); + $formStyle = new Application_Form_AddShowStyle(); + $formLive = new Application_Form_AddShowLiveStream(); $formWhat->removeDecorator('DtDdWrapper'); $formWho->removeDecorator('DtDdWrapper'); @@ -813,12 +813,12 @@ SQL; { $isSaas = (Application_Model_Preference::GetPlanLevel() != 'disabled'); - $formWhat = new Application_Form_AddShowWhat(); - $formWhen = new Application_Form_AddShowWhen(); + $formWhat = new Application_Form_AddShowWhat(); + $formWhen = new Application_Form_AddShowWhen(); $formRepeats = new Application_Form_AddShowRepeats(); - $formWho = new Application_Form_AddShowWho(); - $formStyle = new Application_Form_AddShowStyle(); - $formLive = new Application_Form_AddShowLiveStream(); + $formWho = new Application_Form_AddShowWho(); + $formStyle = new Application_Form_AddShowStyle(); + $formLive = new Application_Form_AddShowLiveStream(); $formWhat->removeDecorator('DtDdWrapper'); $formWhen->removeDecorator('DtDdWrapper'); @@ -898,12 +898,12 @@ SQL; $isSaas = (Application_Model_Preference::GetPlanLevel() != 'disabled'); $record = false; - $formWhat = new Application_Form_AddShowWhat(); - $formWho = new Application_Form_AddShowWho(); - $formWhen = new Application_Form_AddShowWhen(); + $formWhat = new Application_Form_AddShowWhat(); + $formWho = new Application_Form_AddShowWho(); + $formWhen = new Application_Form_AddShowWhen(); $formRepeats = new Application_Form_AddShowRepeats(); - $formStyle = new Application_Form_AddShowStyle(); - $formLive = new Application_Form_AddShowLiveStream(); + $formStyle = new Application_Form_AddShowStyle(); + $formLive = new Application_Form_AddShowLiveStream(); $formWhat->removeDecorator('DtDdWrapper'); $formWho->removeDecorator('DtDdWrapper'); diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index d0cb8e9c9..d9c6c834c 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -475,10 +475,9 @@ class Application_Model_Show ->filterByDbShowId($this->_showId) ->findOne(); - if (!is_null($showDaysRow)) { + if (!is_null($showDaysRow)) return $showDaysRow->getDbRepeatType(); - } else - + else return -1; } @@ -607,31 +606,36 @@ class Application_Model_Show * Get the start date of the current show in UTC timezone. * * @return string - * The start date in the format YYYY-MM-DD + * The start date in the format YYYY-MM-DD or empty string in case + * start date could not be found */ public function getStartDateAndTime() { $con = Propel::getConnection(); $showId = $this->getId(); - $sql = "SELECT first_show, start_time, timezone FROM cc_show_days" - ." WHERE show_id = $showId" + $stmt = $con->prepare( + "SELECT first_show, start_time, timezone FROM cc_show_days" + ." WHERE show_id = :showId" ." ORDER BY first_show" - ." LIMIT 1"; + ." LIMIT 1"); - $query = $con->query($sql); + $stmt->bindParam(':showId', $showId); + $stmt->execute(); - if ($query->rowCount() == 0) { + //$query = $con->query($sql); + + if (!$stmt) { 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("Y-m-d H:i"); } + + $rows = $stmt->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("Y-m-d H:i"); } /** @@ -670,12 +674,12 @@ class Application_Model_Show */ public function getEndDate() { - $startDate = $this->getStartDate(); - $startTime = $this->getStartTime(); - $duration = $this->getDuration(); + $startDate = $this->getStartDate(); + $startTime = $this->getStartTime(); + $duration = $this->getDuration(); $startDateTime = new DateTime($startDate.' '.$startTime); - $duration = explode(":", $duration); + $duration = explode(":", $duration); $endDate = $startDateTime->add(new DateInterval('PT'.$duration[0].'H'.$duration[1].'M')); @@ -877,7 +881,7 @@ class Application_Model_Show $ccShow = CcShowQuery::create()->findPK($this->_showId); $info['custom_username'] = $ccShow->getDbLiveStreamUser(); $info['cb_airtime_auth'] = $ccShow->getDbLiveStreamUsingAirtimeAuth(); - $info['cb_custom_auth'] = $ccShow->getDbLiveStreamUsingCustomAuth(); + $info['cb_custom_auth'] = $ccShow->getDbLiveStreamUsingCustomAuth(); $info['custom_username'] = $ccShow->getDbLiveStreamUser(); $info['custom_password'] = $ccShow->getDbLiveStreamPass(); @@ -1064,8 +1068,8 @@ class Application_Model_Show $ccShow->setDbGenre($data['add_show_genre']); $ccShow->setDbColor($data['add_show_color']); $ccShow->setDbBackgroundColor($data['add_show_background_color']); - $ccShow->setDbLiveStreamUsingAirtimeAuth($data['cb_airtime_auth'] == 1?true:false); - $ccShow->setDbLiveStreamUsingCustomAuth($data['cb_custom_auth'] == 1?true:false); + $ccShow->setDbLiveStreamUsingAirtimeAuth($data['cb_airtime_auth'] == 1); + $ccShow->setDbLiveStreamUsingCustomAuth($data['cb_custom_auth'] == 1); $ccShow->setDbLiveStreamUser($data['custom_username']); $ccShow->setDbLiveStreamPass($data['custom_password']); $ccShow->save(); @@ -1250,6 +1254,8 @@ class Application_Model_Show */ private static function populateShow($p_showDaysRow, $p_populateUntilDateTime) { + // TODO : use constants instead of int values here? or maybe php will + // get enum types by the time somebody gets around to fix this. -- RG if ($p_showDaysRow["repeat_type"] == -1) { Application_Model_Show::populateNonRepeatingShow($p_showDaysRow, $p_populateUntilDateTime); } elseif ($p_showDaysRow["repeat_type"] == 0) { @@ -1730,17 +1736,18 @@ class Application_Model_Show { $event = array(); - $event["id"] = intval($show["instance_id"]); - $event["title"] = $show["name"]; - $event["start"] = $startDateTime->format("Y-m-d H:i:s"); - $event["startUnix"] = $startsEpoch; - $event["end"] = $endDateTime->format("Y-m-d H:i:s"); - $event["endUnix"] = $endsEpoch; - $event["allDay"] = false; - $event["showId"] = intval($show["show_id"]); - $event["record"] = intval($show["record"]); - $event["rebroadcast"] = intval($show["rebroadcast"]); - $event["soundcloud_id"] = is_null($show["soundcloud_id"]) ? -1 : $show["soundcloud_id"]; + $event["id"] = intval($show["instance_id"]); + $event["title"] = $show["name"]; + $event["start"] = $startDateTime->format("Y-m-d H:i:s"); + $event["startUnix"] = $startsEpoch; + $event["end"] = $endDateTime->format("Y-m-d H:i:s"); + $event["endUnix"] = $endsEpoch; + $event["allDay"] = false; + $event["showId"] = intval($show["show_id"]); + $event["record"] = intval($show["record"]); + $event["rebroadcast"] = intval($show["rebroadcast"]); + $event["soundcloud_id"] = is_null($show["soundcloud_id"]) + ? -1 : $show["soundcloud_id"]; //event colouring if ($show["color"] != "") {