can delete a show instance

This commit is contained in:
naomiaro 2011-02-05 20:39:35 -05:00
parent 5aca6cd8bb
commit bb5a2af142
2 changed files with 43 additions and 23 deletions

View File

@ -136,8 +136,13 @@ class ScheduleController extends Zend_Controller_Action
$deltaMin = $this->_getParam('min'); $deltaMin = $this->_getParam('min');
$showInstanceId = $this->_getParam('showInstanceId'); $showInstanceId = $this->_getParam('showInstanceId');
$show = new ShowInstance($showInstanceId); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$error = $show->moveShow($deltaDay, $deltaMin); $user = new User($userInfo->id, $userInfo->type);
if($user->isAdmin()) {
$show = new ShowInstance($showInstanceId);
$error = $show->moveShow($deltaDay, $deltaMin);
}
if(isset($error)) if(isset($error))
$this->view->error = $error; $this->view->error = $error;
@ -149,8 +154,13 @@ class ScheduleController extends Zend_Controller_Action
$deltaMin = $this->_getParam('min'); $deltaMin = $this->_getParam('min');
$showInstanceId = $this->_getParam('showInstanceId'); $showInstanceId = $this->_getParam('showInstanceId');
$show = new ShowInstance($showInstanceId); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$error = $show->resizeShow($deltaDay, $deltaMin); $user = new User($userInfo->id, $userInfo->type);
if($user->isAdmin()) {
$show = new ShowInstance($showInstanceId);
$error = $show->resizeShow($deltaDay, $deltaMin);
}
if(isset($error)) if(isset($error))
$this->view->error = $error; $this->view->error = $error;
@ -158,14 +168,15 @@ class ScheduleController extends Zend_Controller_Action
public function deleteShowAction() public function deleteShowAction()
{ {
$showId = $this->_getParam('id'); $showInstanceId = $this->_getParam('id');
$start_timestamp = $this->_getParam('start');
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new User($userInfo->id, $userInfo->type); $user = new User($userInfo->id, $userInfo->type);
$show = new Show($user, $showId);
$show->deleteShow($start_timestamp); if($user->isAdmin()) {
$show = new ShowInstance($showInstanceId);
$show->deleteShow();
}
} }
public function makeContextMenuAction() public function makeContextMenuAction()
@ -182,16 +193,15 @@ class ScheduleController extends Zend_Controller_Action
if(strtotime($today_timestamp) < strtotime($show->getShowStart())) { if(strtotime($today_timestamp) < strtotime($show->getShowStart())) {
if($user->isHost($show->getShowId())) { if($user->isAdmin()) {
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/delete-show'.$params, 'callback' => 'window["scheduleRefetchEvents"]'), $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/delete-show'.$params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete');
'title' => 'Delete'); }
if($user->isHost($show->getShowId()) || $user->isAdmin()) {
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/clear-show'.$params, 'callback' => 'window["scheduleRefetchEvents"]'), $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/clear-show'.$params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Clear');
'title' => 'Clear');
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/schedule-show-dialog'.$params, 'callback' => 'window["buildScheduleDialog"]'), $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/schedule-show-dialog'.$params, 'callback' => 'window["buildScheduleDialog"]'), 'title' => 'Schedule');
'title' => 'Schedule');
} }
} }
@ -231,14 +241,11 @@ class ScheduleController extends Zend_Controller_Action
public function clearShowAction() public function clearShowAction()
{ {
$showInstanceId = $this->_getParam('id'); $showInstanceId = $this->_getParam('id');
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new User($userInfo->id, $userInfo->type); $user = new User($userInfo->id, $userInfo->type);
$show = new ShowInstance($showInstanceId); $show = new ShowInstance($showInstanceId);
if($user->isHost($show->getShowId())) { if($user->isHost($show->getShowId())) {
$show->clearShow(); $show->clearShow();
} }
} }
@ -265,13 +272,17 @@ class ScheduleController extends Zend_Controller_Action
$group_id = $this->_getParam('groupId'); $group_id = $this->_getParam('groupId');
$search = $this->_getParam('search', null); $search = $this->_getParam('search', null);
$show = new ShowInstance($showInstanceId); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$show->removeGroupFromShow($group_id); $user = new User($userInfo->id, $userInfo->type);
$show = new ShowInstance($showInstanceId);
if($user->isHost($show->getShowId())) {
$show->removeGroupFromShow($group_id);
}
$this->view->showContent = $show->getShowContent(); $this->view->showContent = $show->getShowContent();
$this->view->timeFilled = $show->getTimeScheduled(); $this->view->timeFilled = $show->getTimeScheduled();
$this->view->percentFilled = $show->getPercentScheduledInRange(); $this->view->percentFilled = $show->getPercentScheduledInRange();
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml'); $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
unset($this->view->showContent); unset($this->view->showContent);
} }

View File

@ -587,6 +587,15 @@ class ShowInstance {
} }
} }
public function deleteShow() {
$this->clearShow();
$showInstance = CcShowInstancesQuery::create()
->findPK($this->_instanceId)
->delete();
}
public function getTimeScheduled() { public function getTimeScheduled() {
$start_timestamp = $this->getShowStart(); $start_timestamp = $this->getShowStart();