From e8965fd30a58cbce900b9104363c0eb435679864 Mon Sep 17 00:00:00 2001 From: naomiaro Date: Mon, 13 Dec 2010 11:49:45 -0500 Subject: [PATCH] show hosts have option to schedule, (not implemented yet, just context menu) --- .../controllers/ScheduleController.php | 20 +++++++++----- application/forms/AddShow.php | 3 +-- application/models/Shows.php | 14 +++++----- application/models/Users.php | 26 ++++++++++++++----- .../views/scripts/schedule/index.phtml | 7 +++-- public/js/campcaster/schedule/schedule.js | 13 +++++++--- 6 files changed, 56 insertions(+), 27 deletions(-) diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php index 5eb80ca0a..43ecf9c07 100644 --- a/application/controllers/ScheduleController.php +++ b/application/controllers/ScheduleController.php @@ -32,9 +32,14 @@ class ScheduleController extends Zend_Controller_Action $this->view->headLink()->appendStylesheet('/css/schedule.css'); - $eventMenu[] = array('action' => '/Schedule/delete-show', 'text' => 'Delete'); + $eventDefaultMenu[] = array('action' => '/Schedule/delete-show', 'text' => 'Delete'); - $this->view->eventMenu = $eventMenu; + $this->view->eventDefaultMenu = $eventDefaultMenu; + + $eventHostMenu[] = array('action' => '/Schedule/delete-show', 'text' => 'Delete'); + $eventHostMenu[] = array('action' => '/Schedule/delete-show', 'text' => 'Schedule'); + + $this->view->eventHostMenu = $eventHostMenu; } public function eventFeedAction() @@ -49,7 +54,8 @@ class ScheduleController extends Zend_Controller_Action $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $show = new Show($userInfo->id, $userInfo->type); + $show = new Show(new User($userInfo->id, $userInfo->type)); + $this->view->events = $show->getFullCalendarEvents($start, $end, $weekday); } @@ -63,7 +69,7 @@ class ScheduleController extends Zend_Controller_Action $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $show = new Show($userInfo->id, $userInfo->type); + $show = new Show(new User($userInfo->id, $userInfo->type)); $overlap = $show->addShow($form->getValues()); if(isset($overlap)) { @@ -85,7 +91,7 @@ class ScheduleController extends Zend_Controller_Action $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $show = new Show($userInfo->id, $userInfo->type); + $show = new Show(new User($userInfo->id, $userInfo->type)); $overlap = $show->moveShow($showId, $deltaDay, $deltaMin); @@ -101,7 +107,7 @@ class ScheduleController extends Zend_Controller_Action $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $show = new Show($userInfo->id, $userInfo->type); + $show = new Show(new User($userInfo->id, $userInfo->type)); $overlap = $show->resizeShow($showId, $deltaDay, $deltaMin); @@ -115,7 +121,7 @@ class ScheduleController extends Zend_Controller_Action $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - $show = new Show($userInfo->id, $userInfo->type); + $show = new Show(new User($userInfo->id, $userInfo->type)); $show->deleteShow($showId); } diff --git a/application/forms/AddShow.php b/application/forms/AddShow.php index 98f159a22..b0a2b83b6 100644 --- a/application/forms/AddShow.php +++ b/application/forms/AddShow.php @@ -91,9 +91,8 @@ class Application_Form_AddShow extends Zend_Form 'required' => false, )); - $user = new User(); $options = array(); - $hosts = $user->getHosts(); + $hosts = User::getHosts(); foreach ($hosts as $host) { $options[$host['id']] = $host['login']; diff --git a/application/models/Shows.php b/application/models/Shows.php index f8e10a436..f63a39b9f 100644 --- a/application/models/Shows.php +++ b/application/models/Shows.php @@ -2,13 +2,11 @@ class Show { - private $_userRole; - private $_userId; + private $_user; - public function __construct($userId, $userType='G') + public function __construct($user=NULL) { - $this->_userRole = $userType; - $this->_userId = $userId; + $this->_user = $user; } //end dates are non inclusive. @@ -323,10 +321,14 @@ class Show { $event[$key] = $value; } - if($this->_userRole === "A") { + if($this->_user->isAdmin() === "A") { $event["editable"] = true; } + if($this->_user->isHost($show["show_id"])) { + $event["isHost"] = true; + } + return $event; } } diff --git a/application/models/Users.php b/application/models/Users.php index 292999afd..f37fd6966 100644 --- a/application/models/Users.php +++ b/application/models/Users.php @@ -11,7 +11,23 @@ class User { $this->_userId = $userId; } - public function getUsers($type=NULL) { + public function getType(){ + return $this->userRole; + } + + public function getId(){ + return $this->_userId; + } + + public function isHost($showId) { + return CcShowHostsQuery::create()->filterByDbShow($showId)->filterByDbHost($this->_userId)->count() > 0; + } + + public function isAdmin() { + return $this->_userRole === 'A'; + } + + public static function getUsers($type=NULL) { global $CC_DBC; $sql; @@ -38,12 +54,8 @@ class User { return $CC_DBC->GetAll($sql); } - public function getHosts() { - return $this->getUsers(array('H', 'A')); - } - - public function isHost($showId) { - $res = CCShowHostsQuery::create()->filterByDbShow($showId)->filterByDbHost($this->_userId); + public static function getHosts() { + return User::getUsers(array('H', 'A')); } } diff --git a/application/views/scripts/schedule/index.phtml b/application/views/scripts/schedule/index.phtml index b37b56ce2..3f8400647 100644 --- a/application/views/scripts/schedule/index.phtml +++ b/application/views/scripts/schedule/index.phtml @@ -1,6 +1,9 @@
Add Show
-