can't move a show into the past.

This commit is contained in:
naomiaro 2011-02-05 17:19:54 -05:00
parent c45437633b
commit bc6dd374f4
3 changed files with 18 additions and 9 deletions

View File

@ -136,10 +136,10 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$show = new Show(new User($userInfo->id, $userInfo->type)); $show = new Show(new User($userInfo->id, $userInfo->type));
$overlap = $show->moveShow($showInstanceId, $deltaDay, $deltaMin); $error = $show->moveShow($showInstanceId, $deltaDay, $deltaMin);
if(isset($overlap)) if(isset($error))
$this->view->overlap = $overlap; $this->view->error = $error;
} }
public function resizeShowAction() public function resizeShowAction()
@ -151,10 +151,10 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$show = new Show(new User($userInfo->id, $userInfo->type)); $show = new Show(new User($userInfo->id, $userInfo->type));
$overlap = $show->resizeShow($showInstanceId, $deltaDay, $deltaMin); $error = $show->resizeShow($showInstanceId, $deltaDay, $deltaMin);
if(isset($overlap)) if(isset($error))
$this->view->overlap = $overlap; $this->view->error = $error;
} }
public function deleteShowAction() public function deleteShowAction()

View File

@ -142,6 +142,11 @@ class Show {
$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);
$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)); $overlap = $this->getShows($new_starts, $new_ends, array($showInstanceId));
if(count($overlap) > 0) { if(count($overlap) > 0) {
@ -633,7 +638,11 @@ class Show {
} }
if($this->_user->isAdmin()) { 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"])) { if($this->_user->isHost($show["show_id"])) {

View File

@ -139,7 +139,7 @@ function eventDrop(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui
$.post(url, $.post(url,
{day: dayDelta, min: minuteDelta, showInstanceId: event.id}, {day: dayDelta, min: minuteDelta, showInstanceId: event.id},
function(json){ function(json){
if(json.overlap) { if(json.error) {
revertFunc(); revertFunc();
} }
}); });
@ -153,7 +153,7 @@ function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, vie
$.post(url, $.post(url,
{day: dayDelta, min: minuteDelta, showInstanceId: event.id}, {day: dayDelta, min: minuteDelta, showInstanceId: event.id},
function(json){ function(json){
if(json.overlap) { if(json.error) {
revertFunc(); revertFunc();
} }
}); });