From bae9f1202aeb8e113ed2091f34954f39270facf3 Mon Sep 17 00:00:00 2001 From: denise Date: Tue, 19 Mar 2013 10:09:28 -0400 Subject: [PATCH] CC-4961: Show linking Removed unused schedule controller actions Fix bug where changing a show to repeat deletes the original show's content --- .../controllers/ScheduleController.php | 63 +++---------------- .../services/ShowInstanceService.php | 14 ++--- 2 files changed, 13 insertions(+), 64 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 09a2495ca..87e3c4c4e 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -6,6 +6,7 @@ class ScheduleController extends Zend_Controller_Action protected $sched_sess = null; private $service_calendar; + private $currentUser; public function init() { @@ -42,6 +43,9 @@ class ScheduleController extends Zend_Controller_Action $this->sched_sess = new Zend_Session_Namespace("schedule"); $this->service_calendar = new Application_Service_CalendarService(); + + $service_user = new Application_Service_UserService(); + $this->currentUser = $service_user->getCurrentUser(); } public function indexAction() @@ -121,11 +125,9 @@ class ScheduleController extends Zend_Controller_Action $end = new DateTime($this->_getParam('end', null)); $end->setTimezone(new DateTimeZone("UTC")); - $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new Application_Model_User($userInfo->id); - $editable = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); + $events = &Application_Model_Show::getFullCalendarEvents($start, $end, + $this->currentUser->isAdminOrPM()); - $events = &Application_Model_Show::getFullCalendarEvents($start, $end, $editable); $this->view->events = $events; } @@ -421,32 +423,6 @@ class ScheduleController extends Zend_Controller_Action $this->view->show_name = isset($show[0])?$show[0]["name"]:""; } - public function removeGroupAction() - { - $showInstanceId = $this->sched_sess->showInstanceId; - $group_id = $this->_getParam('groupId'); - - $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new Application_Model_User($userInfo->id); - try { - $show = new Application_Model_ShowInstance($showInstanceId); - } catch (Exception $e) { - $this->view->show_error = true; - - return false; - } - - if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)) || $user->isHostOfShow($show->getShowId())) { - $show->removeGroupFromShow($group_id); - } - - $this->view->showContent = $show->getShowContent(); - $this->view->timeFilled = $show->getTimeScheduled(); - $this->view->percentFilled = $show->getPercentScheduled(); - $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml'); - unset($this->view->showContent); - } - public function showContentDialogAction() { $showInstanceId = $this->_getParam('id'); @@ -730,9 +706,7 @@ class ScheduleController extends Zend_Controller_Action public function getFormAction() { - $user = Application_Model_User::getCurrentUser(); - - if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { + if ($this->currentUser->isAdminOrPM()) { $this->createShowFormAction(true); $this->view->form = $this->view->render('schedule/add-show-form.phtml'); } @@ -933,29 +907,6 @@ class ScheduleController extends Zend_Controller_Action } } - public function contentContextMenuAction() - { - $id = $this->_getParam('id'); - - $params = '/format/json/id/#id#/'; - - $paramsPop = str_replace('#id#', $id, $params); - - // added for downlaod - $id = $this->_getParam('id'); - - $file_id = $this->_getParam('id', null); - $file = Application_Model_StoredFile::Recall($file_id); - - $baseUrl = $this->getRequest()->getBaseUrl(); - $url = $file->getRelativeFileUrl($baseUrl).'download/true'; - $menu[] = array('action' => array('type' => 'gourl', 'url' => $url), - 'title' => _('Download')); - - //returns format jjmenu is looking for. - $this->_helper->json->sendJson($menu); - } - /** * Sets the user specific preference for which time scale to use in Calendar. * This is only being used by schedule.js at the moment. diff --git a/airtime_mvc/application/services/ShowInstanceService.php b/airtime_mvc/application/services/ShowInstanceService.php index 93072f2d1..bf9d2b392 100644 --- a/airtime_mvc/application/services/ShowInstanceService.php +++ b/airtime_mvc/application/services/ShowInstanceService.php @@ -372,11 +372,6 @@ SQL; $this->deleteAllRepeatInstances($currentShowDay, $showId); } - //duration has changed - /*if ($showData['add_show_duration'] != $currentShowDay->getDbDuration()) { - $this->updateInstanceDuration($showData); - }*/ - if ($showData['add_show_repeats']) { $localShowStart = $currentShowDay->getLocalStartDateAndTime(); @@ -395,7 +390,10 @@ SQL; $this->deleteAllInstances($showId); } - if ($repeatType != $currentShowDay->getDbRepeatType()) { + $currentRepeatType = $currentShowDay->getDbRepeatType(); + //only delete instances if the show being edited was already repeating + //and the repeat type changed + if ($currentRepeatType != -1 && $repeatType != $currentRepeatType) { //repeat type changed $this->deleteAllInstances($showId); } else { @@ -513,12 +511,12 @@ DELETE FROM cc_show_instances WHERE starts > :timestamp::TIMESTAMP AND show_id = :showId - AND date(starts) != :firstShow + AND starts != :firstShow SQL; Application_Common_Database::prepareAndExecute( $sql, array( ':timestamp' => gmdate("Y-m-d H:i:s"), ':showId' => $showId, - ':firstShow' => $firstShow->format("Y-m-d")), 'execute'); + ':firstShow' => $firstShow->format("Y-m-d H:i:s")), 'execute'); } public function deleteAllInstances($showId)