Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
43298d60be
|
@ -12,38 +12,6 @@ class RabbitMq
|
|||
RabbitMq::$doPush = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push the current schedule to RabbitMQ, to be picked up by Pypo.
|
||||
* Will push the schedule in the range from 24 hours ago to 24 hours
|
||||
* in the future.
|
||||
*/
|
||||
/* public static function PushScheduleFinal()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
if (RabbitMq::$doPush) {
|
||||
$conn = new AMQPConnection($CC_CONFIG["rabbitmq"]["host"],
|
||||
$CC_CONFIG["rabbitmq"]["port"],
|
||||
$CC_CONFIG["rabbitmq"]["user"],
|
||||
$CC_CONFIG["rabbitmq"]["password"]);
|
||||
$channel = $conn->channel();
|
||||
$channel->access_request($CC_CONFIG["rabbitmq"]["vhost"], false, false, true, true);
|
||||
|
||||
$EXCHANGE = 'airtime-schedule';
|
||||
$channel->exchange_declare($EXCHANGE, 'direct', false, true);
|
||||
|
||||
$temp['event_type'] = "update_schedule";
|
||||
$temp['schedule'] = Schedule::GetScheduledPlaylists();
|
||||
$data = json_encode($temp);
|
||||
$msg = new AMQPMessage($data, array('content_type' => 'text/plain'));
|
||||
|
||||
$channel->basic_publish($msg, $EXCHANGE);
|
||||
$channel->close();
|
||||
$conn->close();
|
||||
|
||||
self::SendMessageToShowRecorder("update_schedule");
|
||||
}
|
||||
} */
|
||||
|
||||
public static function SendMessageToPypo($event_type, $md)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
|
|
@ -657,13 +657,13 @@ class Schedule {
|
|||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
if (is_null($p_fromDateTime)) {
|
||||
$t1 = new DateTime("now", new DateTimeZone("UTC"));
|
||||
$t1 = new DateTime("@".time());
|
||||
$range_start = $t1->format("Y-m-d H:i:s");
|
||||
} else {
|
||||
$range_start = Schedule::PypoTimeToAirtimeTime($p_fromDateTime);
|
||||
}
|
||||
if (is_null($p_fromDateTime)) {
|
||||
$t2 = new DateTime("now", new DateTimeZone("UTC"));
|
||||
$t2 = new DateTime("@".time());
|
||||
$t2->add(new DateInterval("PT24H"));
|
||||
$range_end = $t2->format("Y-m-d H:i:s");
|
||||
} else {
|
||||
|
@ -686,7 +686,6 @@ class Schedule {
|
|||
$timestamp = strtotime($start);
|
||||
$playlists[$pkey]['source'] = "PLAYLIST";
|
||||
$playlists[$pkey]['x_ident'] = $dx['group_id'];
|
||||
//$playlists[$pkey]['subtype'] = '1'; // Just needs to be between 1 and 4 inclusive
|
||||
$playlists[$pkey]['timestamp'] = $timestamp;
|
||||
$playlists[$pkey]['duration'] = $dx['clip_length'];
|
||||
$playlists[$pkey]['played'] = '0';
|
||||
|
|
|
@ -729,17 +729,19 @@ class Show {
|
|||
$utcStartDateTime->setTimezone(new DateTimeZone('UTC'));
|
||||
|
||||
if ($data['add_show_no_end']) {
|
||||
$endDateTime = NULL;
|
||||
$endDate = NULL;
|
||||
}
|
||||
else if ($data['add_show_repeats']) {
|
||||
$endDateTime = new DateTime($data['add_show_end_date']);
|
||||
$endDateTime->setTimezone(new DateTimeZone('UTC'));
|
||||
$endDateTime->add(new DateInterval("P1D"));
|
||||
$endDate = $endDateTime->format("Y-m-d");
|
||||
}
|
||||
else {
|
||||
$endDateTime = new DateTime($data['add_show_start_date']);
|
||||
$endDateTime->setTimezone(new DateTimeZone('UTC'));
|
||||
$endDateTime->add(new DateInterval("P1D"));
|
||||
$endDate = $endDateTime->format("Y-m-d");
|
||||
}
|
||||
|
||||
//only want the day of the week from the start date.
|
||||
|
@ -772,7 +774,7 @@ class Show {
|
|||
|
||||
if ($data['add_show_id'] != -1){
|
||||
$show = new Show($showId);
|
||||
$show->deletePossiblyInvalidInstances($data, $endDateTime->format("Y-m-d"), $isRecorded, $repeatType);
|
||||
$show->deletePossiblyInvalidInstances($data, $endDate, $isRecorded, $repeatType);
|
||||
}
|
||||
|
||||
//check if we are adding or updating a show, and if updating
|
||||
|
@ -785,7 +787,7 @@ class Show {
|
|||
if ($data['add_show_repeats'] && $data['add_show_repeat_type'] == 2){
|
||||
$showDay = new CcShowDays();
|
||||
$showDay->setDbFirstShow($utcStartDateTime->format("Y-m-d"));
|
||||
$showDay->setDbLastShow($endDateTime->format("Y-m-d"));
|
||||
$showDay->setDbLastShow($endDate);
|
||||
$showDay->setDbStartTime($utcStartDateTime->format("H:i:s"));
|
||||
$showDay->setDbDuration($data['add_show_duration']);
|
||||
$showDay->setDbRepeatType($repeatType);
|
||||
|
@ -800,14 +802,14 @@ class Show {
|
|||
else
|
||||
$daysAdd = $day - $startDow;
|
||||
|
||||
$utcStartDateTime->add("P".$daysAdd."d");
|
||||
$utcStartDateTime->add(new DateInterval("P".$daysAdd."D"));
|
||||
}
|
||||
|
||||
if (is_null($endDateTime) || strtotime($utcStartDateTime->format("Y-m-d")) <= $endDateTime->getTimestamp()) {
|
||||
if (is_null($endDateTime) || $utcStartDateTime->getTimestamp <= $endDateTime->getTimestamp()) {
|
||||
$showDay = new CcShowDays();
|
||||
$showDay->setDbFirstShow($utcStartDateTime->format("Y-m-d"));
|
||||
$showDay->setDbLastShow($endDateTime->format("Y-m-d"));
|
||||
$showDay->setDbStartTime($utcStartDateTime->format("H:i:s"));
|
||||
$showDay->setDbLastShow($endDate);
|
||||
$showDay->setDbStartTime($utcStartDateTime->format("H:i"));
|
||||
$showDay->setDbDuration($data['add_show_duration']);
|
||||
$showDay->setDbDay($day);
|
||||
$showDay->setDbRepeatType($repeatType);
|
||||
|
@ -1284,6 +1286,10 @@ class ShowInstance {
|
|||
return $this->_instanceId;
|
||||
}
|
||||
|
||||
public function getShow(){
|
||||
return new Show($this->getShowId());
|
||||
}
|
||||
|
||||
public function isRebroadcast()
|
||||
{
|
||||
return $this->_showInstance->getDbOriginalShow();
|
||||
|
@ -1414,6 +1420,10 @@ class ShowInstance {
|
|||
{
|
||||
global $CC_DBC;
|
||||
|
||||
if ($this->getShow()->isRepeating()){
|
||||
return "Can't drag and drop repeating shows";
|
||||
}
|
||||
|
||||
$hours = $deltaMin/60;
|
||||
if($hours > 0)
|
||||
$hours = floor($hours);
|
||||
|
@ -1422,12 +1432,14 @@ class ShowInstance {
|
|||
|
||||
$mins = abs($deltaMin%60);
|
||||
|
||||
$today_timestamp = date("Y-m-d H:i:s");
|
||||
$today_timestamp = time();
|
||||
$starts = $this->getShowStart();
|
||||
$ends = $this->getShowEnd();
|
||||
|
||||
if(strtotime($today_timestamp) > strtotime($starts)) {
|
||||
return "can't move a past show";
|
||||
$startsDateTime = new DateTime($starts, new DateTimeZone("UTC"));
|
||||
|
||||
if($today_timestamp > $startsDateTime->getTimestamp()) {
|
||||
return "Can't move a past show";
|
||||
}
|
||||
|
||||
$sql = "SELECT timestamp '{$starts}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'";
|
||||
|
@ -1436,8 +1448,9 @@ class ShowInstance {
|
|||
$sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'";
|
||||
$new_ends = $CC_DBC->GetOne($sql);
|
||||
|
||||
if(strtotime($today_timestamp) > strtotime($new_starts)) {
|
||||
return "can't move show into past";
|
||||
$newStartsDateTime = new DateTime($new_starts, new DateTimeZone("UTC"));
|
||||
if($today_timestamp > $newStartsDateTime->getTimestamp()) {
|
||||
return "Can't move show into past";
|
||||
}
|
||||
|
||||
$overlap = Show::getShows($new_starts, $new_ends, array($this->_instanceId));
|
||||
|
|
Loading…
Reference in New Issue