Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
43298d60be
|
@ -80,19 +80,19 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
public function moveShowAction()
|
public function moveShowAction()
|
||||||
{
|
{
|
||||||
$deltaDay = $this->_getParam('day');
|
$deltaDay = $this->_getParam('day');
|
||||||
$deltaMin = $this->_getParam('min');
|
$deltaMin = $this->_getParam('min');
|
||||||
$showInstanceId = $this->_getParam('showInstanceId');
|
$showInstanceId = $this->_getParam('showInstanceId');
|
||||||
|
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
$user = new User($userInfo->id);
|
$user = new User($userInfo->id);
|
||||||
|
|
||||||
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||||
$show = new ShowInstance($showInstanceId);
|
$show = new ShowInstance($showInstanceId);
|
||||||
$error = $show->moveShow($deltaDay, $deltaMin);
|
$error = $show->moveShow($deltaDay, $deltaMin);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($error))
|
if(isset($error))
|
||||||
$this->view->error = $error;
|
$this->view->error = $error;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,38 +12,6 @@ class RabbitMq
|
||||||
RabbitMq::$doPush = TRUE;
|
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)
|
public static function SendMessageToPypo($event_type, $md)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
global $CC_CONFIG;
|
||||||
|
|
|
@ -657,13 +657,13 @@ class Schedule {
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
if (is_null($p_fromDateTime)) {
|
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");
|
$range_start = $t1->format("Y-m-d H:i:s");
|
||||||
} else {
|
} else {
|
||||||
$range_start = Schedule::PypoTimeToAirtimeTime($p_fromDateTime);
|
$range_start = Schedule::PypoTimeToAirtimeTime($p_fromDateTime);
|
||||||
}
|
}
|
||||||
if (is_null($p_fromDateTime)) {
|
if (is_null($p_fromDateTime)) {
|
||||||
$t2 = new DateTime("now", new DateTimeZone("UTC"));
|
$t2 = new DateTime("@".time());
|
||||||
$t2->add(new DateInterval("PT24H"));
|
$t2->add(new DateInterval("PT24H"));
|
||||||
$range_end = $t2->format("Y-m-d H:i:s");
|
$range_end = $t2->format("Y-m-d H:i:s");
|
||||||
} else {
|
} else {
|
||||||
|
@ -686,7 +686,6 @@ class Schedule {
|
||||||
$timestamp = strtotime($start);
|
$timestamp = strtotime($start);
|
||||||
$playlists[$pkey]['source'] = "PLAYLIST";
|
$playlists[$pkey]['source'] = "PLAYLIST";
|
||||||
$playlists[$pkey]['x_ident'] = $dx['group_id'];
|
$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]['timestamp'] = $timestamp;
|
||||||
$playlists[$pkey]['duration'] = $dx['clip_length'];
|
$playlists[$pkey]['duration'] = $dx['clip_length'];
|
||||||
$playlists[$pkey]['played'] = '0';
|
$playlists[$pkey]['played'] = '0';
|
||||||
|
|
|
@ -725,25 +725,27 @@ class Show {
|
||||||
public static function create($data)
|
public static function create($data)
|
||||||
{
|
{
|
||||||
|
|
||||||
$utcStartDateTime = new DateTime($data['add_show_start_date']." ".$data['add_show_start_time']);
|
$utcStartDateTime = new DateTime($data['add_show_start_date']." ".$data['add_show_start_time']);
|
||||||
$utcStartDateTime->setTimezone(new DateTimeZone('UTC'));
|
$utcStartDateTime->setTimezone(new DateTimeZone('UTC'));
|
||||||
|
|
||||||
if ($data['add_show_no_end']) {
|
if ($data['add_show_no_end']) {
|
||||||
$endDateTime = NULL;
|
$endDate = NULL;
|
||||||
}
|
}
|
||||||
else if ($data['add_show_repeats']) {
|
else if ($data['add_show_repeats']) {
|
||||||
$endDateTime = new DateTime($data['add_show_end_date']);
|
$endDateTime = new DateTime($data['add_show_end_date']);
|
||||||
$endDateTime->setTimezone(new DateTimeZone('UTC'));
|
$endDateTime->setTimezone(new DateTimeZone('UTC'));
|
||||||
$endDateTime->add(new DateInterval("P1D"));
|
$endDateTime->add(new DateInterval("P1D"));
|
||||||
|
$endDate = $endDateTime->format("Y-m-d");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$endDateTime = new DateTime($data['add_show_start_date']);
|
$endDateTime = new DateTime($data['add_show_start_date']);
|
||||||
$endDateTime->setTimezone(new DateTimeZone('UTC'));
|
$endDateTime->setTimezone(new DateTimeZone('UTC'));
|
||||||
$endDateTime->add(new DateInterval("P1D"));
|
$endDateTime->add(new DateInterval("P1D"));
|
||||||
|
$endDate = $endDateTime->format("Y-m-d");
|
||||||
}
|
}
|
||||||
|
|
||||||
//only want the day of the week from the start date.
|
//only want the day of the week from the start date.
|
||||||
$startDow = date("w", $utcStartDateTime->getTimestamp());
|
$startDow = date("w", $utcStartDateTime->getTimestamp());
|
||||||
if (!$data['add_show_repeats']) {
|
if (!$data['add_show_repeats']) {
|
||||||
$data['add_show_day_check'] = array($startDow);
|
$data['add_show_day_check'] = array($startDow);
|
||||||
} else if ($data['add_show_repeats'] && $data['add_show_day_check'] == "") {
|
} else if ($data['add_show_repeats'] && $data['add_show_day_check'] == "") {
|
||||||
|
@ -771,8 +773,8 @@ class Show {
|
||||||
$isRecorded = ($data['add_show_record']) ? 1 : 0;
|
$isRecorded = ($data['add_show_record']) ? 1 : 0;
|
||||||
|
|
||||||
if ($data['add_show_id'] != -1){
|
if ($data['add_show_id'] != -1){
|
||||||
$show = new Show($showId);
|
$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
|
//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){
|
if ($data['add_show_repeats'] && $data['add_show_repeat_type'] == 2){
|
||||||
$showDay = new CcShowDays();
|
$showDay = new CcShowDays();
|
||||||
$showDay->setDbFirstShow($utcStartDateTime->format("Y-m-d"));
|
$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->setDbStartTime($utcStartDateTime->format("H:i:s"));
|
||||||
$showDay->setDbDuration($data['add_show_duration']);
|
$showDay->setDbDuration($data['add_show_duration']);
|
||||||
$showDay->setDbRepeatType($repeatType);
|
$showDay->setDbRepeatType($repeatType);
|
||||||
|
@ -800,14 +802,14 @@ class Show {
|
||||||
else
|
else
|
||||||
$daysAdd = $day - $startDow;
|
$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 = new CcShowDays();
|
||||||
$showDay->setDbFirstShow($utcStartDateTime->format("Y-m-d"));
|
$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->setDbStartTime($utcStartDateTime->format("H:i"));
|
||||||
$showDay->setDbDuration($data['add_show_duration']);
|
$showDay->setDbDuration($data['add_show_duration']);
|
||||||
$showDay->setDbDay($day);
|
$showDay->setDbDay($day);
|
||||||
$showDay->setDbRepeatType($repeatType);
|
$showDay->setDbRepeatType($repeatType);
|
||||||
|
@ -1284,6 +1286,10 @@ class ShowInstance {
|
||||||
return $this->_instanceId;
|
return $this->_instanceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getShow(){
|
||||||
|
return new Show($this->getShowId());
|
||||||
|
}
|
||||||
|
|
||||||
public function isRebroadcast()
|
public function isRebroadcast()
|
||||||
{
|
{
|
||||||
return $this->_showInstance->getDbOriginalShow();
|
return $this->_showInstance->getDbOriginalShow();
|
||||||
|
@ -1414,6 +1420,10 @@ class ShowInstance {
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
|
if ($this->getShow()->isRepeating()){
|
||||||
|
return "Can't drag and drop repeating shows";
|
||||||
|
}
|
||||||
|
|
||||||
$hours = $deltaMin/60;
|
$hours = $deltaMin/60;
|
||||||
if($hours > 0)
|
if($hours > 0)
|
||||||
$hours = floor($hours);
|
$hours = floor($hours);
|
||||||
|
@ -1422,12 +1432,14 @@ class ShowInstance {
|
||||||
|
|
||||||
$mins = abs($deltaMin%60);
|
$mins = abs($deltaMin%60);
|
||||||
|
|
||||||
$today_timestamp = date("Y-m-d H:i:s");
|
$today_timestamp = time();
|
||||||
$starts = $this->getShowStart();
|
$starts = $this->getShowStart();
|
||||||
$ends = $this->getShowEnd();
|
$ends = $this->getShowEnd();
|
||||||
|
|
||||||
if(strtotime($today_timestamp) > strtotime($starts)) {
|
$startsDateTime = new DateTime($starts, new DateTimeZone("UTC"));
|
||||||
return "can't move a past show";
|
|
||||||
|
if($today_timestamp > $startsDateTime->getTimestamp()) {
|
||||||
|
return "Can't move a past show";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT timestamp '{$starts}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'";
|
$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}'";
|
$sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'";
|
||||||
$new_ends = $CC_DBC->GetOne($sql);
|
$new_ends = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
if(strtotime($today_timestamp) > strtotime($new_starts)) {
|
$newStartsDateTime = new DateTime($new_starts, new DateTimeZone("UTC"));
|
||||||
return "can't move show into past";
|
if($today_timestamp > $newStartsDateTime->getTimestamp()) {
|
||||||
|
return "Can't move show into past";
|
||||||
}
|
}
|
||||||
|
|
||||||
$overlap = Show::getShows($new_starts, $new_ends, array($this->_instanceId));
|
$overlap = Show::getShows($new_starts, $new_ends, array($this->_instanceId));
|
||||||
|
|
Loading…
Reference in New Issue