diff options
author | Simon | 2011-04-18 12:42:30 +0200 |
---|---|---|
committer | Simon | 2011-04-18 12:42:30 +0200 |
commit | 281a9a40960403b4483af33eec5cebab10e32684 (patch) | |
tree | f9a3f7602315e7d1c55f664d161186a911ce2952 /application/modules/user | |
parent | Pbs_Graph bei Minuswerten wird nichts eingefärbt (diff) | |
download | pbs2-281a9a40960403b4483af33eec5cebab10e32684.tar.gz pbs2-281a9a40960403b4483af33eec5cebab10e32684.tar.xz pbs2-281a9a40960403b4483af33eec5cebab10e32684.zip |
Role Controller geändert
Diffstat (limited to 'application/modules/user')
4 files changed, 112 insertions, 104 deletions
diff --git a/application/modules/user/controllers/PersonController.php b/application/modules/user/controllers/PersonController.php index 4f6b975..d70067a 100644 --- a/application/modules/user/controllers/PersonController.php +++ b/application/modules/user/controllers/PersonController.php @@ -411,6 +411,9 @@ class user_PersonController extends Zend_Controller_Action public function deleterequestAction() { + if(!Pbs_Acl::checkRight('gdm')) { + $this->_redirect('/user'); + } $grouprequestID = $this->_request->getParam('grouprequestID'); $grouprequest = $this->groupRequestMapper->find($grouprequestID); try { diff --git a/application/modules/user/controllers/RoleController.php b/application/modules/user/controllers/RoleController.php index 2c22031..8d2b044 100644 --- a/application/modules/user/controllers/RoleController.php +++ b/application/modules/user/controllers/RoleController.php @@ -3,6 +3,8 @@ class User_RoleController extends Zend_Controller_Action { protected $userIDsNamespace = null; + protected $membership; + protected $membershipMapper; public function init() { @@ -15,9 +17,17 @@ class User_RoleController extends Zend_Controller_Action $this->roleMapper = new Application_Model_RoleMapper(); $this->rightMapper = new Application_Model_RightMapper(); $this->rightRolesMapper = new Application_Model_RightRolesMapper(); + $this->membershipMapper = new Application_Model_MembershipMapper(); + + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + $this->membership = new Application_Model_Membership(); + $this->membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); } else { $this->_helper->redirector('login', 'auth'); } + if($this->membership->getGroupID() == ''){ + $this->_helper->redirector('selectmembership', 'person'); + } } public function indexAction() @@ -25,9 +35,33 @@ class User_RoleController extends Zend_Controller_Action if(!Pbs_Acl::checkRight('ro')) { $this->_redirect('/user'); } - if(isset($this->userIDsNamespace['groupID'])) { - $this->view->roleList = $this->roleMapper->findBy(array('groupID' => $this->userIDsNamespace['groupID']),true); - + $this->view->membership = $this->membership; + $groupID = $this->membership->getGroupID(); + $this->view->roleList = $this->roleMapper->findBy(array('groupID' => $groupID),true); + + $roles = array(); + $groupGroupsMapper = new Application_Model_GroupGroupsMapper(); + $parents = $groupGroupsMapper->getParentGroups($groupID); + $groupMapper = new Application_Model_GroupMapper(); + $roleMapper = new Application_Model_RoleMapper(); + $crawled = array(); + foreach($parents as $p){ + foreach($p as $a){ + if(!in_array($a,$crawled)){ + $crawled[] = $a; + $group = $groupMapper->find($a); + if($groupID != $a) + $r = $roleMapper->findBy(array('groupID' => $a,'inheritance'=>"1")); + else + $r = $roleMapper->findBy(array('groupID' => $a)); + foreach($r as $d){ + $roles[$group->getTitle()][] = $d; + } + } + } + } + $this->view->roleList = $roles; + // Search $search = $this->_request->getParam('search'); $mySearch = new Pbs_Search(); @@ -54,10 +88,7 @@ class User_RoleController extends Zend_Controller_Action $this->view->deleteRight = Pbs_Acl::checkRight('rd'); $this->view->detailsRight = Pbs_Acl::checkRight('rdd'); $this->view->userIDsNamespace = $this->userIDsNamespace; - } else { - $this->_helper->redirector('selectmembership', 'person'); - return; - } + } public function searchAction(){ @@ -72,7 +103,7 @@ class User_RoleController extends Zend_Controller_Action if(!Pbs_Acl::checkRight('ra')) { $this->_redirect('/user'); } - if(isset($this->userIDsNamespace['groupID'])) { + $roleID = $this->userIDsNamespace['roleID']; $rights = $this->rightMapper->fetchAll(); if(count($rights) > 0) { @@ -119,10 +150,6 @@ class User_RoleController extends Zend_Controller_Action } } $this->view->addForm = $addForm; - } else { - $this->_helper->redirector('selectmembership', 'person'); - return; - } } public function editAction() @@ -194,7 +221,7 @@ class User_RoleController extends Zend_Controller_Action $roleMapper = new Application_Model_RoleMapper(); $role = $roleMapper->find($roleID); $roleGroupID = $role->getGroupID(); - if($this->userIDsNamespace['groupID'] == $roleGroupID) { + if($this->userIDsNamespace['groupID'] == $roleGroupID || $role->getInheritance() == 1) { $rightroles = $this->rightRolesMapper->findBy(array('roleID' => $roleID),true); if(count($rightroles) > 0) { foreach($rightroles as $rightrole) { @@ -434,15 +461,3 @@ class User_RoleController extends Zend_Controller_Action } - - - - - - - - - - - - diff --git a/application/modules/user/views/scripts/role/index.phtml b/application/modules/user/views/scripts/role/index.phtml index edf03eb..580238f 100644 --- a/application/modules/user/views/scripts/role/index.phtml +++ b/application/modules/user/views/scripts/role/index.phtml @@ -1,6 +1,4 @@ -<?php -if($this->userIDsNamespace['groupID']) { - ?> + <h1>Roles</h1> <?php echo $this->searchform; @@ -9,82 +7,74 @@ if($this->userIDsNamespace['groupID']) { 'class' => 'addbutton')); ?> <div class='searchvars'> -<div class='head'>Available searchfilter:</div> -<div class='code'>title</div> -<div class='code'>description</div> + <div class='head'>Available searchfilter:</div> + <div class='code'>title</div> + <div class='code'>description</div> </div> -<div class='listelement'><?php -if(count($this->roleList)==0) -echo "There are no roles" ?> <?php foreach($this->roleList as $k => $role): ?> -<?php -$class=''; -if($role['roleID'] == $this->userIDsNamespace['roleID']) -$class= 'highlight checked'; -?> - <div class='element<?php echo " $class";?>'> - <?php if($role['roleID'] != $this->userIDsNamespace['roleID']) { ?> - <div class='number'> - <div class='smallnumber'>Role</div> - <?php echo $role['roleID']; ?> - </div> +<div class='listelement'> +<?php if(count($this->roleList)==0) + echo "There are no roles" ?> +<?php foreach($this->roleList as $i => $grouproleList): ?> + <?php foreach($grouproleList as $k => $role): ?> <?php - } - ?> - <div class='content'> - <div class='actions'><?php if($this->detailsRight) {?> - <a href="<?php echo $this->url( - array( - 'module' => 'user', - 'controller' => 'role', - 'action' => 'show', - 'roleID' => $role['roleID'] - ), - 'default', - true) ?>"> <img src='/media/img/show.png' alt='Show Group' /></a> <?php - } - if($this->editRight) { ?> - <a href="<?php echo $this->url( - array( - 'module' => 'user', - 'controller' => 'role', - 'action' => 'edit', - 'roleID' => $role['roleID'] - ), - 'default', - true) ?>"> <img src='/media/img/edit.png' alt='Edit Group' /></a> <?php - } -if($this->deleteRight) { ?> - <a href="<?php echo $this->url( - array( - 'module' => 'user', - 'controller' => 'role', - 'action' => 'delete', - 'roleID' => $role['roleID'] - ), - 'default', - true) ?>"> <img src='/media/img/delete.png' alt='Delete Group' /></a> - -<?php } ?> -</div> -<div class='title'><?php echo $role['title'] ?></div> - <?php if($role['description']) { - ?> -<div class='subtitle'><?php echo $role['description']; ?></div> - <?php - } else { - ?> -<div class='subtitle'> </div> - <?php - } + $class=''; + if($role->getID() == $this->membership->getRoleID()) + $class= 'highlight checked'; + ?> + <div class='element<?php echo " $class";?>'> + <?php if($role->getID() != $this->userIDsNamespace['roleID']) { ?> + <div class='number'> + <div class='smallnumber'>Role</div> + <?php echo $role->getID(); ?> + </div> + <?php + } + ?> + <div class='content'> + <div class='actions'><?php if($this->detailsRight) {?> + <a href="<?php echo $this->url( + array( + 'module' => 'user', + 'controller' => 'role', + 'action' => 'show', + 'roleID' => $role->getID() + ), + 'default', + true) ?>"> <img src='/media/img/show.png' alt='Show Group' /></a> <?php + } + if($this->editRight && $this->membership->getGroupID() == $role->getGroupID()) { ?> + <a href="<?php echo $this->url( + array( + 'module' => 'user', + 'controller' => 'role', + 'action' => 'edit', + 'roleID' => $role->getID() + ), + 'default', + true) ?>"> <img src='/media/img/edit.png' alt='Edit Group' /></a> <?php + } + if($this->deleteRight && $this->membership->getGroupID() == $role->getGroupID()) { ?> + <a href="<?php echo $this->url( + array( + 'module' => 'user', + 'controller' => 'role', + 'action' => 'delete', + 'roleID' => $role->getID() + ), + 'default', + true) ?>"> <img src='/media/img/delete.png' alt='Delete Group' /></a> -?></div> -<div class='clear'></div> + <?php } ?> + </div> + <div class='title'><?php echo "[".$i."] ";?><?php echo $role->getTitle();?></div> + <div class='subtitle'><?php echo $role->getDescription(); ?> </div></div> + <div class='clear'></div> + </div> + <?php endforeach ?> +<?php endforeach ?> </div> -<?php endforeach ?></div> -<?php echo $this->pagination; -} -?> +<?php echo $this->pagination; ?> <br /> <br /> diff --git a/application/modules/user/views/scripts/role/show.phtml b/application/modules/user/views/scripts/role/show.phtml index 43ae781..765153f 100644 --- a/application/modules/user/views/scripts/role/show.phtml +++ b/application/modules/user/views/scripts/role/show.phtml @@ -9,10 +9,10 @@ if($this->roleID) { <h1>Role Details</h1> <?php } - if($this->deleteRight) echo $this->formButton('deleterole', 'Delete', array( + if($this->deleteRight && $this->roleID == $this->userIDsNamespace['roleID']) echo $this->formButton('deleterole', 'Delete', array( 'onclick' => 'self.location="/user/role/delete/roleID/' . $this->role->getID() .'"', 'class' => 'rightbutton')); - if($this->editRight) echo $this->formButton('editrole', 'Edit', array( + if($this->editRight && $this->roleID == $this->userIDsNamespace['roleID']) echo $this->formButton('editrole', 'Edit', array( 'onclick' => 'self.location="/user/role/edit/roleID/' . $this->role->getID() .'"', 'class' => 'rightbutton')); ?> @@ -38,7 +38,7 @@ if($this->roleID) { <h2>Rights:</h2> <?php if($this->rightsAvailable === true) { - if($this->addRightToRoleRight) { + if($this->addRightToRoleRight && $this->roleID == $this->userIDsNamespace['roleID']) { echo $this->formButton('linkright', 'Add Rights', array( 'onclick' => 'self.location="/user/role/linkright/roleID/' . $this->role->getID() .'"', 'class' => 'addbutton'))?> @@ -48,7 +48,7 @@ if($this->rightsAvailable === true) { if(count($this->rightsList)==0) { echo "There are no Rights to display."; } else { - if($this->removeRightOfRoleRight) echo $this->formButton('deleteallrights', 'Delete All Rights', array( + if($this->removeRightOfRoleRight && $this->roleID == $this->userIDsNamespace['roleID']) echo $this->formButton('deleteallrights', 'Delete All Rights', array( 'onclick' => 'self.location="/user/role/unlinkright/rightrolesID/' . $this->roleID . '-all"', 'class' => 'rightbutton'));?> <br /> @@ -63,7 +63,7 @@ if(count($this->rightsList)==0) { foreach($rights as $right): ?> <div class='element'> -<div class='content'><?php if($this->removeRightOfRoleRight) { +<div class='content'><?php if($this->removeRightOfRoleRight && $this->roleID == $this->userIDsNamespace['roleID']) { ?> <div class='actions'><a href="<?php echo $this->url( |