CC-2628: update a repeated show start time cause the show to get corrupted

-disabled dragging + dropping repeated show instances
This commit is contained in:
martin 2011-08-18 18:13:43 -04:00
parent fc66b1d1ba
commit 846e08699e
4 changed files with 42 additions and 62 deletions

View File

@ -80,19 +80,19 @@ class ScheduleController extends Zend_Controller_Action
public function moveShowAction()
{
$deltaDay = $this->_getParam('day');
$deltaMin = $this->_getParam('min');
$showInstanceId = $this->_getParam('showInstanceId');
$deltaMin = $this->_getParam('min');
$showInstanceId = $this->_getParam('showInstanceId');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new User($userInfo->id);
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$show = new ShowInstance($showInstanceId);
$error = $show->moveShow($deltaDay, $deltaMin);
$show = new ShowInstance($showInstanceId);
$error = $show->moveShow($deltaDay, $deltaMin);
}
if(isset($error))
$this->view->error = $error;
if(isset($error))
$this->view->error = $error;
}

View File

@ -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;

View File

@ -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';

View File

@ -724,26 +724,28 @@ class Show {
*/
public static function create($data)
{
$utcStartDateTime = new DateTime($data['add_show_start_date']." ".$data['add_show_start_time']);
$utcStartDateTime->setTimezone(new DateTimeZone('UTC'));
$utcStartDateTime = new DateTime($data['add_show_start_date']." ".$data['add_show_start_time']);
$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->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->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.
$startDow = date("w", $utcStartDateTime->getTimestamp());
$startDow = date("w", $utcStartDateTime->getTimestamp());
if (!$data['add_show_repeats']) {
$data['add_show_day_check'] = array($startDow);
} else if ($data['add_show_repeats'] && $data['add_show_day_check'] == "") {
@ -771,8 +773,8 @@ class Show {
$isRecorded = ($data['add_show_record']) ? 1 : 0;
if ($data['add_show_id'] != -1){
$show = new Show($showId);
$show->deletePossiblyInvalidInstances($data, $endDateTime->format("Y-m-d"), $isRecorded, $repeatType);
$show = new Show($showId);
$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);
@ -1283,6 +1285,10 @@ class ShowInstance {
{
return $this->_instanceId;
}
public function getShow(){
return new Show($this->getShowId());
}
public function isRebroadcast()
{
@ -1413,6 +1419,10 @@ class ShowInstance {
public function moveShow($deltaDay, $deltaMin)
{
global $CC_DBC;
if ($this->getShow()->isRepeating()){
return "Can't drag and drop repeating shows";
}
$hours = $deltaMin/60;
if($hours > 0)
@ -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();
$startsDateTime = new DateTime($starts, new DateTimeZone("UTC"));
if(strtotime($today_timestamp) > strtotime($starts)) {
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}'";
@ -1436,12 +1448,13 @@ 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));
if(count($overlap) > 0) {
return "Should not overlap shows";
}