From 281a9a40960403b4483af33eec5cebab10e32684 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 18 Apr 2011 12:42:30 +0200 Subject: Role Controller geƤndert --- .../modules/user/controllers/RoleController.php | 65 +++++++++++++--------- 1 file changed, 40 insertions(+), 25 deletions(-) (limited to 'application/modules/user/controllers/RoleController.php') 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 } - - - - - - - - - - - - -- cgit v1.2.3-55-g7522 From 5d621c6ce29d2059480b3283daf14162c74365db Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 18 Apr 2011 13:16:23 +0200 Subject: Rechte in PersonController korrigiert --- application/modules/user/controllers/PersonController.php | 6 +++--- application/modules/user/controllers/RoleController.php | 1 + application/modules/user/views/scripts/auth/delete.phtml | 5 +++-- application/modules/user/views/scripts/role/show.phtml | 13 ++++++++----- library/Pbs/NewMember.php | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) (limited to 'application/modules/user/controllers/RoleController.php') diff --git a/application/modules/user/controllers/PersonController.php b/application/modules/user/controllers/PersonController.php index d70067a..76cd958 100644 --- a/application/modules/user/controllers/PersonController.php +++ b/application/modules/user/controllers/PersonController.php @@ -58,11 +58,11 @@ class user_PersonController extends Zend_Controller_Action $this->_redirect('/user'); } $this->view->showRight = Pbs_Acl::checkRight('psod'); - $this->view->editRight = Pbs_Acl::checkRight('peoa'); - $this->view->deleteRight = Pbs_Acl::checkRight('pd'); + $this->view->editRight = Pbs_Acl::checkRight('peod'); + $this->view->deleteRight = Pbs_Acl::checkRight('pdo'); $this->view->showOtherRight = Pbs_Acl::checkRight('psood'); $this->view->editOtherRight = Pbs_Acl::checkRight('peoa'); - $this->view->deleteOtherRight = Pbs_Acl::checkRight('pdo'); + $this->view->deleteOtherRight = Pbs_Acl::checkRight('pd'); $this->view->suspendRight = Pbs_Acl::checkRight('psa'); $this->view->userIDsNamespace = $this->userIDsNamespace; diff --git a/application/modules/user/controllers/RoleController.php b/application/modules/user/controllers/RoleController.php index 8d2b044..93a2cfa 100644 --- a/application/modules/user/controllers/RoleController.php +++ b/application/modules/user/controllers/RoleController.php @@ -217,6 +217,7 @@ class User_RoleController extends Zend_Controller_Action $roleID = $this->userIDsNamespace['roleID']; } } + $this->view->membership = $this->membership; if($roleID) { $roleMapper = new Application_Model_RoleMapper(); $role = $roleMapper->find($roleID); diff --git a/application/modules/user/views/scripts/auth/delete.phtml b/application/modules/user/views/scripts/auth/delete.phtml index 83afc80..75d9ef6 100644 --- a/application/modules/user/views/scripts/auth/delete.phtml +++ b/application/modules/user/views/scripts/auth/delete.phtml @@ -1,6 +1,7 @@