Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Martin Konecny 2012-09-04 16:00:26 -04:00
commit f698b70341
2 changed files with 70 additions and 63 deletions

View File

@ -356,9 +356,9 @@ SQL;
." SET media_item_played=TRUE"; ." SET media_item_played=TRUE";
// we need to update 'broadcasted' column as well // we need to update 'broadcasted' column as well
// check the current switch status // check the current switch status
$live_dj = Application_Model_Preference::GetSourceSwitchStatus('live_dj') == 'on'?true:false; $live_dj = Application_Model_Preference::GetSourceSwitchStatus('live_dj') == 'on';
$master_dj = Application_Model_Preference::GetSourceSwitchStatus('master_dj') == 'on'?true:false; $master_dj = Application_Model_Preference::GetSourceSwitchStatus('master_dj') == 'on';
$scheduled_play = Application_Model_Preference::GetSourceSwitchStatus('scheduled_play') == 'on'?true:false; $scheduled_play = Application_Model_Preference::GetSourceSwitchStatus('scheduled_play') == 'on';
if (!$live_dj && !$master_dj && $scheduled_play) { if (!$live_dj && !$master_dj && $scheduled_play) {
$sql .= ", broadcasted=1"; $sql .= ", broadcasted=1";
@ -616,23 +616,23 @@ SQL;
$temp = explode('.', Application_Model_Preference::GetDefaultTransitionFade()); $temp = explode('.', Application_Model_Preference::GetDefaultTransitionFade());
// we round down transition time since PHP cannot handle millisecond. We need to // we round down transition time since PHP cannot handle millisecond. We need to
// handle this better in the future // handle this better in the future
$transition_time = intval($temp[0]); $transition_time = intval($temp[0]);
$switchOffDataTime = new DateTime($kick_time, $utcTimeZone); $switchOffDataTime = new DateTime($kick_time, $utcTimeZone);
$switch_off_time = $switchOffDataTime->sub(new DateInterval('PT'.$transition_time.'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"); $switch_off_time = $switch_off_time->format("Y-m-d H:i:s");
$kick_start = Application_Model_Schedule::AirtimeTimeToPypoTime($kick_time); $kick_start = Application_Model_Schedule::AirtimeTimeToPypoTime($kick_time);
$data["media"][$kick_start]['start'] = $kick_start; $data["media"][$kick_start]['start'] = $kick_start;
$data["media"][$kick_start]['end'] = $kick_start; $data["media"][$kick_start]['end'] = $kick_start;
$data["media"][$kick_start]['event_type'] = "kick_out"; $data["media"][$kick_start]['event_type'] = "kick_out";
$data["media"][$kick_start]['type'] = "event"; $data["media"][$kick_start]['type'] = "event";
$data["media"][$kick_start]['independent_event'] = true; $data["media"][$kick_start]['independent_event'] = true;
if ($kick_time !== $switch_off_time) { if ($kick_time !== $switch_off_time) {
$switch_start = Application_Model_Schedule::AirtimeTimeToPypoTime($switch_off_time); $switch_start = Application_Model_Schedule::AirtimeTimeToPypoTime($switch_off_time);
$data["media"][$switch_start]['start'] = $switch_start; $data["media"][$switch_start]['start'] = $switch_start;
$data["media"][$switch_start]['end'] = $switch_start; $data["media"][$switch_start]['end'] = $switch_start;
$data["media"][$switch_start]['event_type'] = "switch_off"; $data["media"][$switch_start]['event_type'] = "switch_off";
$data["media"][$switch_start]['independent_event'] = true; $data["media"][$switch_start]['independent_event'] = true;
} }
} }
@ -757,12 +757,12 @@ SQL;
{ {
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true; $isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
$formWhat = new Application_Form_AddShowWhat(); $formWhat = new Application_Form_AddShowWhat();
$formWho = new Application_Form_AddShowWho(); $formWho = new Application_Form_AddShowWho();
$formWhen = new Application_Form_AddShowWhen(); $formWhen = new Application_Form_AddShowWhen();
$formRepeats = new Application_Form_AddShowRepeats(); $formRepeats = new Application_Form_AddShowRepeats();
$formStyle = new Application_Form_AddShowStyle(); $formStyle = new Application_Form_AddShowStyle();
$formLive = new Application_Form_AddShowLiveStream(); $formLive = new Application_Form_AddShowLiveStream();
$formWhat->removeDecorator('DtDdWrapper'); $formWhat->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper'); $formWho->removeDecorator('DtDdWrapper');
@ -813,12 +813,12 @@ SQL;
{ {
$isSaas = (Application_Model_Preference::GetPlanLevel() != 'disabled'); $isSaas = (Application_Model_Preference::GetPlanLevel() != 'disabled');
$formWhat = new Application_Form_AddShowWhat(); $formWhat = new Application_Form_AddShowWhat();
$formWhen = new Application_Form_AddShowWhen(); $formWhen = new Application_Form_AddShowWhen();
$formRepeats = new Application_Form_AddShowRepeats(); $formRepeats = new Application_Form_AddShowRepeats();
$formWho = new Application_Form_AddShowWho(); $formWho = new Application_Form_AddShowWho();
$formStyle = new Application_Form_AddShowStyle(); $formStyle = new Application_Form_AddShowStyle();
$formLive = new Application_Form_AddShowLiveStream(); $formLive = new Application_Form_AddShowLiveStream();
$formWhat->removeDecorator('DtDdWrapper'); $formWhat->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper'); $formWhen->removeDecorator('DtDdWrapper');
@ -898,12 +898,12 @@ SQL;
$isSaas = (Application_Model_Preference::GetPlanLevel() != 'disabled'); $isSaas = (Application_Model_Preference::GetPlanLevel() != 'disabled');
$record = false; $record = false;
$formWhat = new Application_Form_AddShowWhat(); $formWhat = new Application_Form_AddShowWhat();
$formWho = new Application_Form_AddShowWho(); $formWho = new Application_Form_AddShowWho();
$formWhen = new Application_Form_AddShowWhen(); $formWhen = new Application_Form_AddShowWhen();
$formRepeats = new Application_Form_AddShowRepeats(); $formRepeats = new Application_Form_AddShowRepeats();
$formStyle = new Application_Form_AddShowStyle(); $formStyle = new Application_Form_AddShowStyle();
$formLive = new Application_Form_AddShowLiveStream(); $formLive = new Application_Form_AddShowLiveStream();
$formWhat->removeDecorator('DtDdWrapper'); $formWhat->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper'); $formWho->removeDecorator('DtDdWrapper');

View File

@ -475,10 +475,9 @@ class Application_Model_Show
->filterByDbShowId($this->_showId) ->filterByDbShowId($this->_showId)
->findOne(); ->findOne();
if (!is_null($showDaysRow)) { if (!is_null($showDaysRow))
return $showDaysRow->getDbRepeatType(); return $showDaysRow->getDbRepeatType();
} else else
return -1; return -1;
} }
@ -607,31 +606,36 @@ class Application_Model_Show
* Get the start date of the current show in UTC timezone. * Get the start date of the current show in UTC timezone.
* *
* @return string * @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() public function getStartDateAndTime()
{ {
$con = Propel::getConnection(); $con = Propel::getConnection();
$showId = $this->getId(); $showId = $this->getId();
$sql = "SELECT first_show, start_time, timezone FROM cc_show_days" $stmt = $con->prepare(
." WHERE show_id = $showId" "SELECT first_show, start_time, timezone FROM cc_show_days"
." WHERE show_id = :showId"
." ORDER BY first_show" ." 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 ""; 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() public function getEndDate()
{ {
$startDate = $this->getStartDate(); $startDate = $this->getStartDate();
$startTime = $this->getStartTime(); $startTime = $this->getStartTime();
$duration = $this->getDuration(); $duration = $this->getDuration();
$startDateTime = new DateTime($startDate.' '.$startTime); $startDateTime = new DateTime($startDate.' '.$startTime);
$duration = explode(":", $duration); $duration = explode(":", $duration);
$endDate = $startDateTime->add(new DateInterval('PT'.$duration[0].'H'.$duration[1].'M')); $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); $ccShow = CcShowQuery::create()->findPK($this->_showId);
$info['custom_username'] = $ccShow->getDbLiveStreamUser(); $info['custom_username'] = $ccShow->getDbLiveStreamUser();
$info['cb_airtime_auth'] = $ccShow->getDbLiveStreamUsingAirtimeAuth(); $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_username'] = $ccShow->getDbLiveStreamUser();
$info['custom_password'] = $ccShow->getDbLiveStreamPass(); $info['custom_password'] = $ccShow->getDbLiveStreamPass();
@ -1064,8 +1068,8 @@ class Application_Model_Show
$ccShow->setDbGenre($data['add_show_genre']); $ccShow->setDbGenre($data['add_show_genre']);
$ccShow->setDbColor($data['add_show_color']); $ccShow->setDbColor($data['add_show_color']);
$ccShow->setDbBackgroundColor($data['add_show_background_color']); $ccShow->setDbBackgroundColor($data['add_show_background_color']);
$ccShow->setDbLiveStreamUsingAirtimeAuth($data['cb_airtime_auth'] == 1?true:false); $ccShow->setDbLiveStreamUsingAirtimeAuth($data['cb_airtime_auth'] == 1);
$ccShow->setDbLiveStreamUsingCustomAuth($data['cb_custom_auth'] == 1?true:false); $ccShow->setDbLiveStreamUsingCustomAuth($data['cb_custom_auth'] == 1);
$ccShow->setDbLiveStreamUser($data['custom_username']); $ccShow->setDbLiveStreamUser($data['custom_username']);
$ccShow->setDbLiveStreamPass($data['custom_password']); $ccShow->setDbLiveStreamPass($data['custom_password']);
$ccShow->save(); $ccShow->save();
@ -1250,6 +1254,8 @@ class Application_Model_Show
*/ */
private static function populateShow($p_showDaysRow, $p_populateUntilDateTime) 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) { if ($p_showDaysRow["repeat_type"] == -1) {
Application_Model_Show::populateNonRepeatingShow($p_showDaysRow, $p_populateUntilDateTime); Application_Model_Show::populateNonRepeatingShow($p_showDaysRow, $p_populateUntilDateTime);
} elseif ($p_showDaysRow["repeat_type"] == 0) { } elseif ($p_showDaysRow["repeat_type"] == 0) {
@ -1730,17 +1736,18 @@ class Application_Model_Show
{ {
$event = array(); $event = array();
$event["id"] = intval($show["instance_id"]); $event["id"] = intval($show["instance_id"]);
$event["title"] = $show["name"]; $event["title"] = $show["name"];
$event["start"] = $startDateTime->format("Y-m-d H:i:s"); $event["start"] = $startDateTime->format("Y-m-d H:i:s");
$event["startUnix"] = $startsEpoch; $event["startUnix"] = $startsEpoch;
$event["end"] = $endDateTime->format("Y-m-d H:i:s"); $event["end"] = $endDateTime->format("Y-m-d H:i:s");
$event["endUnix"] = $endsEpoch; $event["endUnix"] = $endsEpoch;
$event["allDay"] = false; $event["allDay"] = false;
$event["showId"] = intval($show["show_id"]); $event["showId"] = intval($show["show_id"]);
$event["record"] = intval($show["record"]); $event["record"] = intval($show["record"]);
$event["rebroadcast"] = intval($show["rebroadcast"]); $event["rebroadcast"] = intval($show["rebroadcast"]);
$event["soundcloud_id"] = is_null($show["soundcloud_id"]) ? -1 : $show["soundcloud_id"]; $event["soundcloud_id"] = is_null($show["soundcloud_id"])
? -1 : $show["soundcloud_id"];
//event colouring //event colouring
if ($show["color"] != "") { if ($show["color"] != "") {