Make user functions work more consistently
isHost didn't work similar to isPM or isAdmin
This commit is contained in:
parent
9885374d34
commit
ea4567f373
2 changed files with 16 additions and 13 deletions
|
@ -238,7 +238,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
|
|
||||||
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
$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());
|
$showStartLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceStart());
|
||||||
$showEndLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceEnd());
|
$showEndLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceEnd());
|
||||||
|
@ -338,7 +338,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
return false;
|
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();
|
$show->clearShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
return false;
|
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);
|
$show->removeGroupFromShow($group_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,7 +543,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
|
|
||||||
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
||||||
$isDJ = $user->isHost($showInstance->getShowId());
|
$isDJ = $user->isHostOfShow($showInstance->getShowId());
|
||||||
|
|
||||||
if (!($isAdminOrPM || $isDJ)) {
|
if (!($isAdminOrPM || $isDJ)) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -32,9 +32,17 @@ class Application_Model_User
|
||||||
return $this->getType() == UTYPE_GUEST;
|
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)
|
public function isHost($showId)
|
||||||
{
|
{
|
||||||
return $this->isUserType(UTYPE_HOST, $showId);
|
return $this->isUserType(UTYPE_HOST);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isPM()
|
public function isPM()
|
||||||
|
@ -61,7 +69,7 @@ class Application_Model_User
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isUserType($type, $showId='')
|
public function isUserType($type)
|
||||||
{
|
{
|
||||||
if (is_array($type)) {
|
if (is_array($type)) {
|
||||||
$result = false;
|
$result = false;
|
||||||
|
@ -71,10 +79,7 @@ class Application_Model_User
|
||||||
$result = $this->_userInstance->getDbType() === 'A';
|
$result = $this->_userInstance->getDbType() === 'A';
|
||||||
break;
|
break;
|
||||||
case UTYPE_HOST:
|
case UTYPE_HOST:
|
||||||
$userId = $this->_userInstance->getDbId();
|
$result = $this->_userInstance->getDbType() === 'H';
|
||||||
$result = CcShowHostsQuery::create()
|
|
||||||
->filterByDbShow($showId)
|
|
||||||
->filterByDbHost($userId)->count() > 0;
|
|
||||||
break;
|
break;
|
||||||
case UTYPE_PROGRAM_MANAGER:
|
case UTYPE_PROGRAM_MANAGER:
|
||||||
$result = $this->_userInstance->getDbType() === 'P';
|
$result = $this->_userInstance->getDbType() === 'P';
|
||||||
|
@ -89,9 +94,7 @@ class Application_Model_User
|
||||||
case UTYPE_ADMIN:
|
case UTYPE_ADMIN:
|
||||||
return $this->_userInstance->getDbType() === 'A';
|
return $this->_userInstance->getDbType() === 'A';
|
||||||
case UTYPE_HOST:
|
case UTYPE_HOST:
|
||||||
$userId = $this->_userInstance->getDbId();
|
return $this->_userInstance->getDbId() === 'H';
|
||||||
|
|
||||||
return CcShowHostsQuery::create()->filterByDbShow($showId)->filterByDbHost($userId)->count() > 0;
|
|
||||||
case UTYPE_PROGRAM_MANAGER:
|
case UTYPE_PROGRAM_MANAGER:
|
||||||
return $this->_userInstance->getDbType() === 'P';
|
return $this->_userInstance->getDbType() === 'P';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue