From 6521222deb21df89ba62fe5b92d25fcf8fc643bb Mon Sep 17 00:00:00 2001 From: Björn Geiger Date: Tue, 29 Mar 2011 16:26:39 +0200 Subject: RightCategories auch auf der Role Detail Seite --- application/modules/user/controllers/RoleController.php | 13 ++++++++++--- application/modules/user/views/scripts/role/show.phtml | 11 +++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'application/modules') diff --git a/application/modules/user/controllers/RoleController.php b/application/modules/user/controllers/RoleController.php index 3db425f..3d8e0de 100644 --- a/application/modules/user/controllers/RoleController.php +++ b/application/modules/user/controllers/RoleController.php @@ -131,12 +131,20 @@ class User_RoleController extends Zend_Controller_Action if(count($rightroles) > 0) { foreach($rightroles as $rightrole) { $right = $this->rightMapper->find($rightrole['rightID']); - $rightsList[] = $right; + $rightsList[$right->getRightcategoryID()][] = $right; } if(is_array($rightsList)) { $this->view->rightsList = $rightsList; } } + $rightCategoryMapper = new Application_Model_RightCategoryMapper(); + $rightCategories = $rightCategoryMapper->fetchAll(); + if(count($rightCategories) > 0) { + foreach($rightCategories as $rightCategory) { + $rightcategorieslist[$rightCategory->getID()] = $rightCategory->getTitle(); + } + $this->view->rightcategorieslist = $rightcategorieslist; + } $this->view->role = $this->roleMapper->find($roleID); $this->view->roleID = $roleID; $this->view->userIDsNamespace = $this->userIDsNamespace; @@ -214,8 +222,7 @@ class User_RoleController extends Zend_Controller_Action } } if(!$found) { - $rightCategory = $right->getRightcategoryID(); - $rightlist[$rightCategory][] = $right; + $rightlist[$right->getRightcategoryID()][] = $right; } $found = false; } diff --git a/application/modules/user/views/scripts/role/show.phtml b/application/modules/user/views/scripts/role/show.phtml index b99c1f8..0a7522a 100644 --- a/application/modules/user/views/scripts/role/show.phtml +++ b/application/modules/user/views/scripts/role/show.phtml @@ -34,8 +34,13 @@ if($this->roleID) { formButton('linkright', 'Add Right', array( 'onclick' => 'self.location="/user/role/linkright/roleID/' . $this->role->getID() .'"', 'class' => 'addbutton'))?> +
rightsList)) { - ?> + if(isset($this->rightcategorieslist)) { + foreach($this->rightcategorieslist as $k => $v) { + $rights = $this->rightsList[$k]; + ?> +

@@ -44,7 +49,7 @@ if($this->roleID) { rightsList as $right) { + foreach($rights as $right) { ?> @@ -66,6 +71,8 @@ if($this->roleID) { ?>
Title
getTitle(); ?>

-- cgit v1.2.3-55-g7522 From 596f2dc724b1a576bbf4db118fc8648ca72801e2 Mon Sep 17 00:00:00 2001 From: Björn Geiger Date: Tue, 29 Mar 2011 16:37:43 +0200 Subject: Add Right nur anzeigen, wenn nicht schon alle Rechte vorhanden --- application/modules/user/controllers/PersonController.php | 14 ++++++++++++++ application/modules/user/controllers/RoleController.php | 6 ++++++ application/modules/user/views/scripts/role/show.phtml | 11 ++++++++--- 3 files changed, 28 insertions(+), 3 deletions(-) (limited to 'application/modules') diff --git a/application/modules/user/controllers/PersonController.php b/application/modules/user/controllers/PersonController.php index 3d231f4..62d3b6b 100644 --- a/application/modules/user/controllers/PersonController.php +++ b/application/modules/user/controllers/PersonController.php @@ -41,6 +41,10 @@ class user_PersonController extends Zend_Controller_Action public function indexAction() { + + if(!Pbs_Acl::checkRight('psod')) { + $this->_redirect('/user'); + } $this->view->person = $this->person; $this->view->groups = $this->groups; $this->view->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); @@ -48,6 +52,9 @@ class user_PersonController extends Zend_Controller_Action public function editAction() { + if(!Pbs_Acl::checkRight('peod')) { + $this->_redirect('/user'); + } $this->view->person = $this->person; if (!isset($_POST["save"])){ $editForm = new user_Form_PersonEdit(); @@ -79,6 +86,9 @@ class user_PersonController extends Zend_Controller_Action public function requestAction() { + if(!Pbs_Acl::checkRight('grm')) { + $this->_redirect('/user'); + } $this->view->person = $this->person; $allgroups = $this->groupMapper->fetchAll(); $groupRequests = $this->groupRequestMapper->findBy('personID', $this->person->getID()); @@ -141,6 +151,10 @@ class user_PersonController extends Zend_Controller_Action public function leaveAction() { + // Nicht klar welches Recht geprüft werden soll + /*if(!Pbs_Acl::checkRight('peod')) { + $this->_redirect('/user'); + }*/ $this->_helper-> viewRenderer-> setNoRender(); $this->view->person = $this->person; $membershipID = $this->_request->getParam('membershipID'); diff --git a/application/modules/user/controllers/RoleController.php b/application/modules/user/controllers/RoleController.php index 3d8e0de..dcd00ef 100644 --- a/application/modules/user/controllers/RoleController.php +++ b/application/modules/user/controllers/RoleController.php @@ -145,6 +145,12 @@ class User_RoleController extends Zend_Controller_Action } $this->view->rightcategorieslist = $rightcategorieslist; } + $rights = $this->rightMapper->fetchAll(); + if(count($rights) == count($rightroles)) { + $this->view->rightsAvailable = false; + } else { + $this->view->rightsAvailable = true; + } $this->view->role = $this->roleMapper->find($roleID); $this->view->roleID = $roleID; $this->view->userIDsNamespace = $this->userIDsNamespace; diff --git a/application/modules/user/views/scripts/role/show.phtml b/application/modules/user/views/scripts/role/show.phtml index 0a7522a..408dcc4 100644 --- a/application/modules/user/views/scripts/role/show.phtml +++ b/application/modules/user/views/scripts/role/show.phtml @@ -31,10 +31,15 @@ if($this->roleID) {

Rights:

- formButton('linkright', 'Add Right', array( + rightsAvailable === true) { + echo $this->formButton('linkright', 'Add Right', array( 'onclick' => 'self.location="/user/role/linkright/roleID/' . $this->role->getID() .'"', 'class' => 'addbutton'))?>
+ rightsList)) { if(isset($this->rightcategorieslist)) { foreach($this->rightcategorieslist as $k => $v) { @@ -79,6 +84,6 @@ if($this->roleID) {

No Rights have been added!

- rightMapper->fetchAll(); if(count($rightroles) > 0) { if(count($rights) > 0) { + $rightCategoryMapper = new Application_Model_RightCategoryMapper(); foreach($rights as $right) { foreach($rightroles as $rightrole) { if($right->getID() == $rightrole['rightID']) { @@ -228,7 +229,8 @@ class User_RoleController extends Zend_Controller_Action } } if(!$found) { - $rightlist[$right->getRightcategoryID()][] = $right; + $rightCategory = $rightCategoryMapper->find($right->getRightcategoryID()); + $rightlist[$rightCategory->getTitle()][$right->getID()] = $right->getTitle(); } $found = false; } @@ -237,22 +239,11 @@ class User_RoleController extends Zend_Controller_Action $rightlist = $rights; } if(count($rightlist) > 0) { - $rightCategoryMapper = new Application_Model_RightCategoryMapper(); - $rightCategories = $rightCategoryMapper->fetchAll(); - if(count($rightCategories) > 0) { - foreach($rightCategories as $rightCategory) { - $rightcategorieslist[$rightCategory->getID()] = $rightCategory->getTitle(); - } - } if (!isset($_POST["link"])){ - $linkForm = new user_Form_LinkRight(array('rightlist' => $rightlist, 'rightcategorieslist' => $rightcategorieslist, 'roleID' => $roleID)); + $linkForm = new user_Form_LinkRight(array('rightlist' => $rightlist, 'roleID' => $roleID)); } else { - $linkForm = new user_Form_LinkRight(array('rightlist' => $rightlist, 'rightcategorieslist' => $rightcategorieslist, 'roleID' => $roleID), $_POST); + $linkForm = new user_Form_LinkRight(array('rightlist' => $rightlist, 'roleID' => $roleID), $_POST); if ($linkForm->isValid($_POST)) { - if(strpos($_POST['rightID'], 'category') !== false) { - $this->_redirect($_SERVER['HTTP_REFERER']); - return; - } $rightroles = new Application_Model_RightRoles(); $rightroles->setRightID($_POST['rightID']); $rightroles->setRoleID($roleID); diff --git a/application/modules/user/forms/LinkRight.php b/application/modules/user/forms/LinkRight.php index d99c2b6..8fe2f46 100644 --- a/application/modules/user/forms/LinkRight.php +++ b/application/modules/user/forms/LinkRight.php @@ -3,17 +3,12 @@ class user_Form_LinkRight extends Zend_Form { private $rightlist; - private $rightcategorieslist; private $roleID; public function setRightlist($rightlist){ $this->rightlist = $rightlist; } - public function setRightcategorieslist($rightcategorieslist){ - $this->rightcategorieslist = $rightcategorieslist; - } - public function setRoleID($roleID){ $this->roleID = $roleID; } @@ -23,20 +18,7 @@ class user_Form_LinkRight extends Zend_Form $this->setName("LinkRight"); $this->setMethod('post'); - $rightfield = $this->createElement('select','rightID'); - $rightfield ->setLabel('Right:'); - - if(count($this->rightlist)>0){ - foreach($this->rightcategorieslist as $k => $v) { - $rightfield->addMultiOption("category" . $k, "---" . $v . "---"); - $rights = $this->rightlist[$k]; - foreach($rights as $right => $r){ - $rightfield->addMultiOption($r->getID(), $r->getTitle()); - $count++; - } - - } - } + $rightfield = $this->createElement('select','rightID',array('label'=> 'Right: ','required' => true,'multioptions'=> $this->rightlist)); $rightfield->setRegisterInArrayValidator(false); $this->addElement($rightfield); -- cgit v1.2.3-55-g7522