CC-2255: Separate user types admin and program manager
- New user type 'Program Manager' added - 'Program Manager' gets same previlage as Admin but doesn't have access to Configure menu - Changed user type name 'Host' to 'DJ'
This commit is contained in:
parent
f46cdd3888
commit
ad3ef3ec30
|
@ -6,7 +6,8 @@ $ccAcl = new Zend_Acl();
|
||||||
|
|
||||||
$ccAcl->addRole(new Zend_Acl_Role('G'))
|
$ccAcl->addRole(new Zend_Acl_Role('G'))
|
||||||
->addRole(new Zend_Acl_Role('H'), 'G')
|
->addRole(new Zend_Acl_Role('H'), 'G')
|
||||||
->addRole(new Zend_Acl_Role('A'), 'H');
|
->addRole(new Zend_Acl_Role('P'), 'H')
|
||||||
|
->addRole(new Zend_Acl_Role('A'), 'P');
|
||||||
|
|
||||||
$ccAcl->add(new Zend_Acl_Resource('library'))
|
$ccAcl->add(new Zend_Acl_Resource('library'))
|
||||||
->add(new Zend_Acl_Resource('index'))
|
->add(new Zend_Acl_Resource('index'))
|
||||||
|
|
|
@ -59,6 +59,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
$user = new User($userInfo->id);
|
$user = new User($userInfo->id);
|
||||||
$this->view->isAdmin = $user->isAdmin();
|
$this->view->isAdmin = $user->isAdmin();
|
||||||
|
$this->view->isProgramManager = $user->isUserType('P');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function eventFeedAction()
|
public function eventFeedAction()
|
||||||
|
@ -68,7 +69,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
$user = new User($userInfo->id);
|
$user = new User($userInfo->id);
|
||||||
if($user->isAdmin())
|
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)))
|
||||||
$editable = true;
|
$editable = true;
|
||||||
else
|
else
|
||||||
$editable = false;
|
$editable = false;
|
||||||
|
@ -85,7 +86,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
$user = new User($userInfo->id);
|
$user = new User($userInfo->id);
|
||||||
|
|
||||||
if($user->isAdmin()) {
|
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||||
$show = new ShowInstance($showInstanceId);
|
$show = new ShowInstance($showInstanceId);
|
||||||
$error = $show->moveShow($deltaDay, $deltaMin);
|
$error = $show->moveShow($deltaDay, $deltaMin);
|
||||||
}
|
}
|
||||||
|
@ -104,7 +105,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
$user = new User($userInfo->id);
|
$user = new User($userInfo->id);
|
||||||
|
|
||||||
if($user->isAdmin()) {
|
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||||
$show = new ShowInstance($showInstanceId);
|
$show = new ShowInstance($showInstanceId);
|
||||||
$error = $show->resizeShow($deltaDay, $deltaMin);
|
$error = $show->resizeShow($deltaDay, $deltaMin);
|
||||||
}
|
}
|
||||||
|
@ -120,7 +121,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
$user = new User($userInfo->id);
|
$user = new User($userInfo->id);
|
||||||
|
|
||||||
if($user->isAdmin()) {
|
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||||
$show = new ShowInstance($showInstanceId);
|
$show = new ShowInstance($showInstanceId);
|
||||||
$show->deleteShow();
|
$show->deleteShow();
|
||||||
}
|
}
|
||||||
|
@ -182,10 +183,10 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$show = new ShowInstance($id);
|
$show = new ShowInstance($id);
|
||||||
|
|
||||||
$params = '/format/json/id/#id#';
|
$params = '/format/json/id/#id#';
|
||||||
|
|
||||||
if (strtotime($today_timestamp) < strtotime($show->getShowStart())) {
|
if (strtotime($today_timestamp) < strtotime($show->getShowStart())) {
|
||||||
|
|
||||||
if (($user->isHost($show->getShowId()) || $user->isAdmin()) && !$show->isRecorded() && !$show->isRebroadcast()) {
|
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId()) && !$show->isRecorded() && !$show->isRebroadcast()) {
|
||||||
|
|
||||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/schedule-show-dialog'.$params,
|
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/schedule-show-dialog'.$params,
|
||||||
'callback' => 'window["buildScheduleDialog"]'), 'title' => 'Add / Remove Content');
|
'callback' => 'window["buildScheduleDialog"]'), 'title' => 'Add / Remove Content');
|
||||||
|
@ -213,7 +214,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
if (strtotime($show->getShowStart()) <= strtotime($today_timestamp) &&
|
if (strtotime($show->getShowStart()) <= strtotime($today_timestamp) &&
|
||||||
strtotime($today_timestamp) < strtotime($show->getShowEnd()) &&
|
strtotime($today_timestamp) < strtotime($show->getShowEnd()) &&
|
||||||
$user->isAdmin()) {
|
$user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||||
$menu[] = array('action' => array('type' => 'fn',
|
$menu[] = array('action' => array('type' => 'fn',
|
||||||
'callback' => "window['confirmCancelShow']($id)"),
|
'callback' => "window['confirmCancelShow']($id)"),
|
||||||
'title' => 'Cancel Current Show');
|
'title' => 'Cancel Current Show');
|
||||||
|
@ -221,7 +222,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
if (strtotime($today_timestamp) < strtotime($show->getShowStart())) {
|
if (strtotime($today_timestamp) < strtotime($show->getShowStart())) {
|
||||||
|
|
||||||
if ($user->isAdmin()) {
|
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||||
|
|
||||||
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/edit-show/format/json/id/'.$id,
|
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/edit-show/format/json/id/'.$id,
|
||||||
'callback' => 'window["beginEditShow"]'), 'title' => 'Edit Show');
|
'callback' => 'window["beginEditShow"]'), 'title' => 'Edit Show');
|
||||||
|
@ -231,7 +232,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance and All Following');
|
'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance and All Following');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//returns format jjmenu is looking for.
|
//returns format jjmenu is looking for.
|
||||||
die(json_encode($menu));
|
die(json_encode($menu));
|
||||||
}
|
}
|
||||||
|
@ -250,7 +251,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$user = new User($userInfo->id);
|
$user = new User($userInfo->id);
|
||||||
$show = new ShowInstance($showInstanceId);
|
$show = new ShowInstance($showInstanceId);
|
||||||
|
|
||||||
if($user->isHost($show->getShowId()) || $user->isAdmin()) {
|
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId())) {
|
||||||
$show->scheduleShow(array($plId));
|
$show->scheduleShow(array($plId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +270,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$user = new User($userInfo->id);
|
$user = new User($userInfo->id);
|
||||||
$show = new ShowInstance($showInstanceId);
|
$show = new ShowInstance($showInstanceId);
|
||||||
|
|
||||||
if($user->isHost($show->getShowId()) || $user->isAdmin())
|
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId()))
|
||||||
$show->clearShow();
|
$show->clearShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +300,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$user = new User($userInfo->id);
|
$user = new User($userInfo->id);
|
||||||
$show = new ShowInstance($showInstanceId);
|
$show = new ShowInstance($showInstanceId);
|
||||||
|
|
||||||
if($user->isHost($show->getShowId()) || $user->isAdmin()) {
|
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST),$show->getShowId())) {
|
||||||
$show->removeGroupFromShow($group_id);
|
$show->removeGroupFromShow($group_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +378,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
{
|
{
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
$user = new User($userInfo->id);
|
$user = new User($userInfo->id);
|
||||||
if(!$user->isAdmin()) {
|
if(!$user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,7 +598,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
if ($what && $when && $repeats && $who && $style && $record && $rebroadAb && $rebroad) {
|
if ($what && $when && $repeats && $who && $style && $record && $rebroadAb && $rebroad) {
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
$user = new User($userInfo->id);
|
$user = new User($userInfo->id);
|
||||||
if ($user->isAdmin()) {
|
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||||
Show::create($data);
|
Show::create($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,7 +636,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
$user = new User($userInfo->id);
|
$user = new User($userInfo->id);
|
||||||
|
|
||||||
if($user->isAdmin()) {
|
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||||
$showInstanceId = $this->_getParam('id');
|
$showInstanceId = $this->_getParam('id');
|
||||||
|
|
||||||
$showInstance = new ShowInstance($showInstanceId);
|
$showInstance = new ShowInstance($showInstanceId);
|
||||||
|
@ -650,7 +651,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
$user = new User($userInfo->id);
|
$user = new User($userInfo->id);
|
||||||
|
|
||||||
if($user->isAdmin()) {
|
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||||
$showInstanceId = $this->_getParam('id');
|
$showInstanceId = $this->_getParam('id');
|
||||||
$show = new ShowInstance($showInstanceId);
|
$show = new ShowInstance($showInstanceId);
|
||||||
$show->clearShow();
|
$show->clearShow();
|
||||||
|
|
|
@ -73,7 +73,8 @@ class Application_Form_AddUser extends Zend_Form
|
||||||
$select->setAttrib('style', 'width: 40%');
|
$select->setAttrib('style', 'width: 40%');
|
||||||
$select->setMultiOptions(array(
|
$select->setMultiOptions(array(
|
||||||
"G" => "Guest",
|
"G" => "Guest",
|
||||||
"H" => "Host",
|
"H" => "DJ",
|
||||||
|
"P" => "Program Manager",
|
||||||
"A" => "Admin"
|
"A" => "Admin"
|
||||||
));
|
));
|
||||||
$select->setRequired(true);
|
$select->setRequired(true);
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
define('UTYPE_HOST', 'H');
|
||||||
|
define('UTYPE_ADMIN', 'A');
|
||||||
|
define('UTYPE_GUEST', 'G');
|
||||||
|
define('UTYPE_PROGRAM_MANAGER', 'P');
|
||||||
|
|
||||||
class User {
|
class User {
|
||||||
|
|
||||||
private $_userInstance;
|
private $_userInstance;
|
||||||
|
@ -18,12 +23,44 @@ class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isHost($showId) {
|
public function isHost($showId) {
|
||||||
$userId = $this->_userInstance->getDbId();
|
return $this->isUserType(UTYPE_HOST, $showId);
|
||||||
return CcShowHostsQuery::create()->filterByDbShow($showId)->filterByDbHost($userId)->count() > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isAdmin() {
|
public function isAdmin() {
|
||||||
return $this->_userInstance->getDbType() === 'A';
|
return $this->isUserType(UTYPE_ADMIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isUserType($type, $showId=''){
|
||||||
|
if(is_array($type)){
|
||||||
|
$result = false;
|
||||||
|
foreach($type as $t){
|
||||||
|
switch($t){
|
||||||
|
case UTYPE_ADMIN:
|
||||||
|
$result = $this->_userInstance->getDbType() === 'A';
|
||||||
|
break;
|
||||||
|
case UTYPE_HOST:
|
||||||
|
$userId = $this->_userInstance->getDbId();
|
||||||
|
$result = CcShowHostsQuery::create()->filterByDbShow($showId)->filterByDbHost($userId)->count() > 0;
|
||||||
|
break;
|
||||||
|
case UTYPE_PROGRAM_MANAGER:
|
||||||
|
$result = $this->_userInstance->getDbType() === 'P';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if($result){
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
switch($type){
|
||||||
|
case UTYPE_ADMIN:
|
||||||
|
return $this->_userInstance->getDbType() === 'A';
|
||||||
|
case UTYPE_HOST:
|
||||||
|
$userId = $this->_userInstance->getDbId();
|
||||||
|
return CcShowHostsQuery::create()->filterByDbShow($showId)->filterByDbHost($userId)->count() > 0;
|
||||||
|
case UTYPE_PROGRAM_MANAGER:
|
||||||
|
return $this->_userInstance->getDbType() === 'P';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setLogin($login){
|
public function setLogin($login){
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php if($this->isAdmin) : ?>
|
<?php if($this->isAdmin || $this->isProgramManager) : ?>
|
||||||
<form id="add-show-form" method="post" action="" style="display:none;">
|
<form id="add-show-form" method="post" action="" style="display:none;">
|
||||||
<?php echo $this->render('schedule/add-show-form.phtml') ?>
|
<?php echo $this->render('schedule/add-show-form.phtml') ?>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -51,6 +51,9 @@ function rowCallback( nRow, aData, iDisplayIndex ){
|
||||||
} else if ( aData[4] == "G" )
|
} else if ( aData[4] == "G" )
|
||||||
{
|
{
|
||||||
$('td:eq(3)', nRow).html( 'Guest' );
|
$('td:eq(3)', nRow).html( 'Guest' );
|
||||||
|
} else if ( aData[4] == "P" )
|
||||||
|
{
|
||||||
|
$('td:eq(3)', nRow).html( 'Program Manager' );
|
||||||
}
|
}
|
||||||
|
|
||||||
return nRow;
|
return nRow;
|
||||||
|
|
Loading…
Reference in New Issue