From d11fca8ac8c2891cbee6ed7d6bb9f27ef871e5a3 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 16 Apr 2012 16:48:04 -0400 Subject: [PATCH] CC-3444: Ability to edit currently playing show (end time and permissions - fixed --- .../controllers/ScheduleController.php | 18 ++++++++++++------ airtime_mvc/application/forms/AddShowWhen.php | 11 +++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index b0fd1f011..657fac245 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -89,12 +89,12 @@ class ScheduleController extends Zend_Controller_Action Application_Model_Schedule::createNewFormSections($this->view); - $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $user = new Application_Model_User($userInfo->id); - if($user->isUserType(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)){ + $user = Application_Model_User::GetCurrentUser(); + + if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))){ $this->view->preloadShowForm = true; } - + $this->view->headScript()->appendScript("var weekStart = ".Application_Model_Preference::GetWeekStartDay().";"); } @@ -586,7 +586,11 @@ class ScheduleController extends Zend_Controller_Action 'add_show_repeats' => $show->isRepeating() ? 1 : 0)); if ($show->isStartDateTimeInPast()){ - $formWhen->getElement('add_show_start_date')->setOptions(array('disabled' => true)); + if(!$showInstance->getShow()->isRepeating()){ + $formWhen->disableStartDateAndTime(); + }else{ + $formWhen->getElement('add_show_start_date')->setOptions(array('disabled' => true)); + } } //need to get the days of the week in the php timezone (for the front end). @@ -684,7 +688,7 @@ class ScheduleController extends Zend_Controller_Action $user = Application_Model_User::GetCurrentUser(); - if($user->isUserType(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)){ + if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))){ Application_Model_Schedule::createNewFormSections($this->view); $this->view->form = $this->view->render('schedule/add-show-form.phtml'); } @@ -765,7 +769,9 @@ class ScheduleController extends Zend_Controller_Action //array key does not exist. We need to repopulate this entry from the db. //The start date will be returned in UTC time, so lets convert it to local time. $dt = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartDate()); + $startTime = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartTime()); $data['add_show_start_date'] = $dt->format("Y-m-d"); + $data['add_show_start_time'] = $startTime->format("H:i"); $validateStartDate = false; } diff --git a/airtime_mvc/application/forms/AddShowWhen.php b/airtime_mvc/application/forms/AddShowWhen.php index ed10c89a9..d62dff3c3 100644 --- a/airtime_mvc/application/forms/AddShowWhen.php +++ b/airtime_mvc/application/forms/AddShowWhen.php @@ -131,5 +131,16 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm $element->setAttrib('disabled','disabled'); } } + + public function disableStartDateAndTime(){ + $elements = array($this->getElement('add_show_start_date'), $this->getElement('add_show_start_time')); + foreach ($elements as $element) + { + if ($element->getType() != 'Zend_Form_Element_Hidden') + { + $element->setAttrib('disabled','disabled'); + } + } + } }