Removed scheduleController private variable, currentUser

Removed showService private variable, currentUser
This commit is contained in:
denise 2013-03-27 09:02:49 -04:00
parent 418bf0b5ff
commit e259639d1a
3 changed files with 32 additions and 75 deletions

View file

@ -5,8 +5,6 @@ class ScheduleController extends Zend_Controller_Action
protected $sched_sess = null; protected $sched_sess = null;
private $currentUser;
public function init() public function init()
{ {
$ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext = $this->_helper->getHelper('AjaxContext');
@ -40,9 +38,6 @@ class ScheduleController extends Zend_Controller_Action
->initContext(); ->initContext();
$this->sched_sess = new Zend_Session_Namespace("schedule"); $this->sched_sess = new Zend_Session_Namespace("schedule");
$service_user = new Application_Service_UserService();
$this->currentUser = $service_user->getCurrentUser();
} }
public function indexAction() public function indexAction()
@ -117,13 +112,16 @@ class ScheduleController extends Zend_Controller_Action
public function eventFeedAction() public function eventFeedAction()
{ {
$service_user = new Application_Service_UserService();
$currentUser = $service_user->getCurrentUser();
$start = new DateTime($this->_getParam('start', null)); $start = new DateTime($this->_getParam('start', null));
$start->setTimezone(new DateTimeZone("UTC")); $start->setTimezone(new DateTimeZone("UTC"));
$end = new DateTime($this->_getParam('end', null)); $end = new DateTime($this->_getParam('end', null));
$end->setTimezone(new DateTimeZone("UTC")); $end->setTimezone(new DateTimeZone("UTC"));
$events = &Application_Model_Show::getFullCalendarEvents($start, $end, $events = &Application_Model_Show::getFullCalendarEvents($start, $end,
$this->currentUser->isAdminOrPM()); $currentUser->isAdminOrPM());
$this->view->events = $events; $this->view->events = $events;
} }
@ -367,81 +365,32 @@ class ScheduleController extends Zend_Controller_Action
unset($this->view->showContent); unset($this->view->showContent);
} }
public function populateShowInstanceFormAction(){ public function populateShowInstanceFormAction()
$formWhat = new Application_Form_AddShowWhat(); {
$formWho = new Application_Form_AddShowWho(); $showId = $this->_getParam('showId');
$formWhen = new Application_Form_AddShowWhen(); $instanceId = $this->_getParam('instanceId');
$formRepeats = new Application_Form_AddShowRepeats(); $service_showForm = new Application_Service_ShowFormService($showId, $instanceId);
$formStyle = new Application_Form_AddShowStyle();
$formLive = new Application_Form_AddShowLiveStream();
$formWhat->removeDecorator('DtDdWrapper'); $forms = $this->createShowFormAction();
$formWho->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper'); $service_showForm->delegateShowInstanceFormPopulation($forms);
$formRepeats->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$this->view->what = $formWhat;
$this->view->when = $formWhen;
$this->view->repeats = $formRepeats;
$this->view->who = $formWho;
$this->view->style = $formStyle;
$this->view->live = $formLive;
$this->view->addNewShow = false; $this->view->addNewShow = false;
$showInstanceId = $this->_getParam('id');
$show_instance = CcShowInstancesQuery::create()->findPK($showInstanceId);
$show = new Application_Model_Show($show_instance->getDbShowId());
$starts_string = $show_instance->getDbStarts();
$ends_string = $show_instance->getDbEnds();
$starts_datetime = new DateTime($starts_string, new DateTimeZone("UTC"));
$ends_datetime = new DateTime($ends_string, new DateTimeZone("UTC"));
$starts_datetime->setTimezone(new DateTimeZone(date_default_timezone_get()));
$ends_datetime->setTimezone(new DateTimeZone(date_default_timezone_get()));
$instance_duration = $starts_datetime->diff($ends_datetime);
$formWhat->populate(array('add_show_id' => $show->getId(),
'add_show_instance_id' => $showInstanceId,
'add_show_name' => $show->getName(),
'add_show_url' => $show->getUrl(),
'add_show_genre' => $show->getGenre(),
'add_show_description' => $show->getDescription()));
$formWhen->populate(array('add_show_start_date' => $starts_datetime->format("Y-m-d"),
'add_show_start_time' => $starts_datetime->format("H:i"),
'add_show_end_date_no_repeat' => $ends_datetime->format("Y-m-d"),
'add_show_end_time' => $ends_datetime->format("H:i"),
'add_show_duration' => $instance_duration->format("%h")));
$formWhat->disable();
$formWho->disable();
$formWhen->disableRepeatCheckbox();
$formRepeats->disable();
$formStyle->disable();
//$formRecord->disable();
//$formAbsoluteRebroadcast->disable();
//$formRebroadcast->disable();
$this->view->action = "edit-show-instance"; $this->view->action = "edit-show-instance";
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml'); $this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
} }
public function populateShowFormAction() public function populateShowFormAction()
{ {
$service_user = new Application_Service_UserService();
$currentUser = $service_user->getCurrentUser();
$showId = $this->_getParam('showId'); $showId = $this->_getParam('showId');
$instanceId = $this->_getParam('instanceId'); $instanceId = $this->_getParam('instanceId');
$service_showForm = new Application_Service_ShowFormService($showId, $instanceId); $service_showForm = new Application_Service_ShowFormService($showId, $instanceId);
$this->view->action = "edit-show"; $isAdminOrPM = $currentUser->isAdminOrPM();
/*$isHostOfShow = $currentUser->isHostOfShow($showId);
$isAdminOrPM = $this->currentUser->isAdminOrPM();
/*$isHostOfShow = $this->currentUser->isHostOfShow($showId);
// in case a user was once a dj and had been assigned to a show // in case a user was once a dj and had been assigned to a show
// but was then changed to an admin user we need to allow // but was then changed to an admin user we need to allow
// the user to edit the show as an admin (CC-4925) // the user to edit the show as an admin (CC-4925)
@ -451,7 +400,7 @@ class ScheduleController extends Zend_Controller_Action
$forms = $this->createShowFormAction(); $forms = $this->createShowFormAction();
$service_showForm->delegateFormPopulation($forms); $service_showForm->delegateShowFormPopulation($forms);
if (!$isAdminOrPM) { if (!$isAdminOrPM) {
foreach ($forms as $form) { foreach ($forms as $form) {
@ -459,13 +408,17 @@ class ScheduleController extends Zend_Controller_Action
} }
} }
$this->view->action = "edit-show";
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml'); $this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
$this->view->entries = 5; $this->view->entries = 5;
} }
public function getFormAction() public function getFormAction()
{ {
if ($this->currentUser->isAdminOrPM()) { $service_user = new Application_Service_UserService();
$currentUser = $service_user->getCurrentUser();
if ($currentUser->isAdminOrPM()) {
$this->createShowFormAction(true); $this->createShowFormAction(true);
$this->view->form = $this->view->render('schedule/add-show-form.phtml'); $this->view->form = $this->view->render('schedule/add-show-form.phtml');
} }

View file

@ -73,6 +73,11 @@ class Application_Service_ShowFormService
$formRepeats->populate(array('add_show_end_date' => date("Y-m-d"))); $formRepeats->populate(array('add_show_end_date' => date("Y-m-d")));
} }
public function delegateShowInstanceFormPopulation($forms)
{
$this->populateFormWhat($forms["what"]);
}
/** /**
* *
* Delegates populating each show form with the appropriate * Delegates populating each show form with the appropriate
@ -80,7 +85,7 @@ class Application_Service_ShowFormService
* *
* @param $forms * @param $forms
*/ */
public function delegateFormPopulation($forms) public function delegateShowFormPopulation($forms)
{ {
$this->populateFormWhat($forms["what"]); $this->populateFormWhat($forms["what"]);
$this->populateFormWhen($forms["when"]); $this->populateFormWhen($forms["when"]);

View file

@ -9,20 +9,19 @@ define("REPEAT_MONTHLY_WEEKLY", 3);
class Application_Service_ShowService class Application_Service_ShowService
{ {
private $ccShow; private $ccShow;
private $currentUser;
public function __construct($showId=null) public function __construct($showId=null)
{ {
if (!is_null($showId)) { if (!is_null($showId)) {
$this->ccShow = CcShowQuery::create()->findPk($showId); $this->ccShow = CcShowQuery::create()->findPk($showId);
} }
$service_user = new Application_Service_UserService();
$this->currentUser = $service_user->getCurrentUser();
} }
public function addUpdateShow($showData, $isUpdate=false) public function addUpdateShow($showData, $isUpdate=false)
{ {
$service_user = new Application_Service_UserService();
$currentUser = $service_user->getCurrentUser();
if ($showData["add_show_repeats"]) { if ($showData["add_show_repeats"]) {
$repeatType = $showData["add_show_repeat_type"]; $repeatType = $showData["add_show_repeat_type"];
if ($showData["add_show_repeat_type"] == 2) { if ($showData["add_show_repeat_type"] == 2) {