diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 83ee7cf91..5494d6d0b 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -238,7 +238,7 @@ class ScheduleController extends Zend_Controller_Action } $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); - $isDJ = $user->isHost($instance->getShowId()); + $isDJ = $user->isHostOfShow($instance->getShowId()); $showStartLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceStart()); $showEndLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceEnd()); @@ -338,7 +338,7 @@ class ScheduleController extends Zend_Controller_Action return false; } - if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId())) + if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER) && $user->isHostOfShow($show->getShowId()))) $show->clearShow(); } @@ -403,7 +403,7 @@ class ScheduleController extends Zend_Controller_Action return false; } - if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId())) { + if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER) && $user->isHostOfShow($show->getShowId()))) { $show->removeGroupFromShow($group_id); } @@ -543,7 +543,7 @@ class ScheduleController extends Zend_Controller_Action } $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)); - $isDJ = $user->isHost($showInstance->getShowId()); + $isDJ = $user->isHostOfShow($showInstance->getShowId()); if (!($isAdminOrPM || $isDJ)) { return; diff --git a/airtime_mvc/application/models/User.php b/airtime_mvc/application/models/User.php index ffb137ad9..9788f7641 100644 --- a/airtime_mvc/application/models/User.php +++ b/airtime_mvc/application/models/User.php @@ -32,9 +32,17 @@ class Application_Model_User return $this->getType() == UTYPE_GUEST; } + public function isHostOfShow($showId) + { + $userId = $this->_userInstance->getDbId(); + return CcShowHostsQuery::create() + ->filterByDbShow($showId) + ->filterByDbHost($userId)->count() > 0; + } + public function isHost($showId) { - return $this->isUserType(UTYPE_HOST, $showId); + return $this->isUserType(UTYPE_HOST); } public function isPM() @@ -61,7 +69,7 @@ class Application_Model_User return $result; } - public function isUserType($type, $showId='') + public function isUserType($type) { if (is_array($type)) { $result = false; @@ -71,10 +79,7 @@ class Application_Model_User $result = $this->_userInstance->getDbType() === 'A'; break; case UTYPE_HOST: - $userId = $this->_userInstance->getDbId(); - $result = CcShowHostsQuery::create() - ->filterByDbShow($showId) - ->filterByDbHost($userId)->count() > 0; + $result = $this->_userInstance->getDbType() === 'H'; break; case UTYPE_PROGRAM_MANAGER: $result = $this->_userInstance->getDbType() === 'P'; @@ -89,9 +94,7 @@ class Application_Model_User case UTYPE_ADMIN: return $this->_userInstance->getDbType() === 'A'; case UTYPE_HOST: - $userId = $this->_userInstance->getDbId(); - - return CcShowHostsQuery::create()->filterByDbShow($showId)->filterByDbHost($userId)->count() > 0; + return $this->_userInstance->getDbId() === 'H'; case UTYPE_PROGRAM_MANAGER: return $this->_userInstance->getDbType() === 'P'; }