From bc6dd374f49609e10233efcba15203d1d5040ece Mon Sep 17 00:00:00 2001 From: naomiaro Date: Sat, 5 Feb 2011 17:19:54 -0500 Subject: [PATCH] can't move a show into the past. --- application/controllers/ScheduleController.php | 12 ++++++------ application/models/Shows.php | 11 ++++++++++- .../js/airtime/schedule/full-calendar-functions.js | 4 ++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php index 37d8a18ad..12c3bfda4 100644 --- a/application/controllers/ScheduleController.php +++ b/application/controllers/ScheduleController.php @@ -136,10 +136,10 @@ class ScheduleController extends Zend_Controller_Action $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $show = new Show(new User($userInfo->id, $userInfo->type)); - $overlap = $show->moveShow($showInstanceId, $deltaDay, $deltaMin); + $error = $show->moveShow($showInstanceId, $deltaDay, $deltaMin); - if(isset($overlap)) - $this->view->overlap = $overlap; + if(isset($error)) + $this->view->error = $error; } public function resizeShowAction() @@ -151,10 +151,10 @@ class ScheduleController extends Zend_Controller_Action $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $show = new Show(new User($userInfo->id, $userInfo->type)); - $overlap = $show->resizeShow($showInstanceId, $deltaDay, $deltaMin); + $error = $show->resizeShow($showInstanceId, $deltaDay, $deltaMin); - if(isset($overlap)) - $this->view->overlap = $overlap; + if(isset($error)) + $this->view->error = $error; } public function deleteShowAction() diff --git a/application/models/Shows.php b/application/models/Shows.php index 7c9feee2a..187f49a37 100644 --- a/application/models/Shows.php +++ b/application/models/Shows.php @@ -142,6 +142,11 @@ class Show { $sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'"; $new_ends = $CC_DBC->GetOne($sql); + $today_timestamp = date("Y-m-d H:i:s"); + if(strtotime($today_timestamp) > strtotime($new_starts)) { + return "can't move show into past"; + } + $overlap = $this->getShows($new_starts, $new_ends, array($showInstanceId)); if(count($overlap) > 0) { @@ -633,7 +638,11 @@ class Show { } if($this->_user->isAdmin()) { - $event["editable"] = true; + $today_timestamp = date("Y-m-d H:i:s"); + + if(strtotime($today_timestamp) < strtotime($show["starts"])) { + $event["editable"] = true; + } } if($this->_user->isHost($show["show_id"])) { diff --git a/public/js/airtime/schedule/full-calendar-functions.js b/public/js/airtime/schedule/full-calendar-functions.js index 34c73af2a..61c8c766b 100644 --- a/public/js/airtime/schedule/full-calendar-functions.js +++ b/public/js/airtime/schedule/full-calendar-functions.js @@ -139,7 +139,7 @@ function eventDrop(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui $.post(url, {day: dayDelta, min: minuteDelta, showInstanceId: event.id}, function(json){ - if(json.overlap) { + if(json.error) { revertFunc(); } }); @@ -153,7 +153,7 @@ function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, vie $.post(url, {day: dayDelta, min: minuteDelta, showInstanceId: event.id}, function(json){ - if(json.overlap) { + if(json.error) { revertFunc(); } });