From ddea0446edb165f23df02f324cb3ca3c4066b308 Mon Sep 17 00:00:00 2001
From: Björn Geiger
Date: Tue, 12 Apr 2011 15:45:15 +0200
Subject: Anzeige Request bei Personendetails
---
.../modules/user/controllers/PersonController.php | 103 ++++++++++++++++-----
1 file changed, 82 insertions(+), 21 deletions(-)
(limited to 'application/modules/user/controllers')
diff --git a/application/modules/user/controllers/PersonController.php b/application/modules/user/controllers/PersonController.php
index 7511233..bbdf232 100644
--- a/application/modules/user/controllers/PersonController.php
+++ b/application/modules/user/controllers/PersonController.php
@@ -2,13 +2,21 @@
class user_PersonController extends Zend_Controller_Action
{
+
protected $person = null;
+
protected $personmapper = null;
+
protected $membershipMapper = null;
+
protected $memberships = null;
+
protected $groupMapper = null;
+
protected $groups = null;
+
protected $groupRequestMapper = null;
+
protected $userIDsNamespace = null;
public function init()
@@ -31,10 +39,10 @@ class user_PersonController extends Zend_Controller_Action
foreach($this->memberships as $membership) {
$group = $this->groupMapper->find($membership['groupID']);
$this->groups[] = array (
- 'groupID' => $group->getID(),
- 'title' => $group->getTitle(),
- 'description' => $group->getDescription(),
- 'membershipID' => $membership['membershipID']
+ 'groupID' => $group->getID(),
+ 'title' => $group->getTitle(),
+ 'description' => $group->getDescription(),
+ 'membershipID' => $membership['membershipID']
);
}
}
@@ -88,6 +96,19 @@ class user_PersonController extends Zend_Controller_Action
# $this->_redirect('/user');
#}
$this->view->person = $this->person;
+ $groupRequests = $this->groupRequestMapper->findBy(array('personID' => $this->person->getID()),true);
+ if(isset($groupRequests)) {
+ foreach($groupRequests as $groupRequest) {
+ $group = $this->groupMapper->find($groupRequest['groupID']);
+ $groupRequestList[] = array(
+ 'grouprequestID' => $groupRequest['grouprequestID'],
+ 'group' => $group
+ );
+ }
+ if(is_array($groupRequestList)) {
+ $this->view->groupRequestList = $groupRequestList;
+ }
+ }
// Pagination
$pagination = new Pbs_Pagination();
$pagination->setPerPage(3);
@@ -217,13 +238,21 @@ class user_PersonController extends Zend_Controller_Action
$date = new DateTime();
$groupRequest->setTime($date->getTimestamp());
$groupRequest->setPersonID($this->person->getID());
- try {
- $groupRequestMapper->save($groupRequest);
- } catch(Zend_Exception $e)
- {
- echo "Caught exception: " . get_class($e) . "
";
- echo "Message: " . $e->getMessage() . "
";
- return;
+ foreach($groupRequests as $groupRequestDB) {
+ if($groupRequestDB['groupID'] == $groupRequest->getGroupID()) {
+ $requestFound = true;
+ break;
+ }
+ }
+ if(!$requestFound) {
+ try {
+ $groupRequestMapper->save($groupRequest);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "
";
+ echo "Message: " . $e->getMessage() . "
";
+ return;
+ }
}
$this->_helper->redirector('owndetails', 'person');
return;
@@ -279,9 +308,9 @@ class user_PersonController extends Zend_Controller_Action
$group = $groupMapper->find($membership['groupID']);
$role = $roleMapper->find($membership['roleID']);
$membershipList[] = array(
- 'membershipID' => $membership['membershipID'],
- 'group' => $group->getTitle(),
- 'role' => $role->getTitle()
+ 'membershipID' => $membership['membershipID'],
+ 'group' => $group->getTitle(),
+ 'role' => $role->getTitle()
);
}
}
@@ -302,7 +331,8 @@ class user_PersonController extends Zend_Controller_Action
return;
}
- public function searchAction(){
+ public function searchAction()
+ {
if(!Pbs_Acl::checkRight('pso')) {
$this->_redirect('/user');
}
@@ -322,15 +352,27 @@ class user_PersonController extends Zend_Controller_Action
foreach($memberships as $membership) {
$group = $this->groupMapper->find($membership['groupID']);
$groups[] = array (
- 'groupID' => $group->getID(),
- 'title' => $group->getTitle(),
- 'description' => $group->getDescription(),
- 'membershipID' => $membership['membershipID']
+ 'groupID' => $group->getID(),
+ 'title' => $group->getTitle(),
+ 'description' => $group->getDescription(),
+ 'membershipID' => $membership['membershipID']
);
}
}
$this->view->person = $person;
-
+ $groupRequests = $this->groupRequestMapper->findBy(array('personID' => $person->getID()),true);
+ if(isset($groupRequests)) {
+ foreach($groupRequests as $groupRequest) {
+ $group = $this->groupMapper->find($groupRequest['groupID']);
+ $groupRequestList[] = array(
+ 'grouprequestID' => $groupRequest['grouprequestID'],
+ 'group' => $group
+ );
+ }
+ if(is_array($groupRequestList)) {
+ $this->view->groupRequestList = $groupRequestList;
+ }
+ }
// Pagination
$pagination = new Pbs_Pagination();
$pagination->setPerPage(2);
@@ -350,4 +392,23 @@ class user_PersonController extends Zend_Controller_Action
return;
}
}
-}
\ No newline at end of file
+
+ public function deleterequestAction()
+ {
+ $grouprequestID = $this->_request->getParam('grouprequestID');
+ $grouprequest = $this->groupRequestMapper->find($grouprequestID);
+ try {
+ $this->groupRequestMapper->delete($grouprequest);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "
";
+ echo "Message: " . $e->getMessage() . "
";
+ return;
+ }
+ $this->_helper->redirector('owndetails', 'person');
+ return;
+ }
+
+
+}
+
--
cgit v1.2.3-55-g7522
From 4cbe29cb27b1963cabdeaa83b780b6705cd0ece9 Mon Sep 17 00:00:00 2001
From: Björn Geiger
Date: Tue, 12 Apr 2011 16:37:05 +0200
Subject: Rechte können nun wieder bei Rollen hinzugefügt und gelöscht werden,
alle Rechte gleichzeitig von einer Rolle löschen
---
.../modules/user/controllers/RoleController.php | 55 +++++++++++++++-------
.../modules/user/views/scripts/role/show.phtml | 34 ++++++++-----
2 files changed, 59 insertions(+), 30 deletions(-)
(limited to 'application/modules/user/controllers')
diff --git a/application/modules/user/controllers/RoleController.php b/application/modules/user/controllers/RoleController.php
index 91357f0..1b2e54f 100644
--- a/application/modules/user/controllers/RoleController.php
+++ b/application/modules/user/controllers/RoleController.php
@@ -322,7 +322,11 @@ class User_RoleController extends Zend_Controller_Action
}
}
} else {
- $rightlist = $rights;
+ $rightCategoryMapper = new Application_Model_RightCategoryMapper();
+ foreach($rights as $right) {
+ $rightCategory = $rightCategoryMapper->find($right->getRightcategoryID());
+ $rightlist[$rightCategory->getTitle()][$right->getID()] = $right->getTitle();
+ }
}
if(count($rightlist) > 0) {
if (!isset($_POST["link"])){
@@ -377,15 +381,10 @@ class User_RoleController extends Zend_Controller_Action
if(isset($rightRolesID)) {
$rightRolesID = explode('-',$rightRolesID);
$roleID = $rightRolesID[0];
- $rightID = $rightRolesID[1];
- if (isset($roleID) && isset($rightID)){
- $roleMapper = new Application_Model_RoleMapper();
- $role = $roleMapper->find($roleID);
- $roleGroupID = $role->getGroupID();
- if($this->userIDsNamespace['groupID'] == $roleGroupID) {
- $rightroles = new Application_Model_RightRoles();
- $rightroles->setRoleID($roleID);
- $rightroles->setRightID($rightID);
+ if($rightRolesID[1] == 'all') {
+ $rightRolesMapper = new Application_Model_RightRolesMapper();
+ $rightroleslist = $rightRolesMapper->findBy(array('roleID' => $roleID));
+ foreach($rightroleslist as $rightroles) {
try {
$this->rightRolesMapper->delete($rightroles);
} catch(Zend_Exception $e)
@@ -393,15 +392,37 @@ class User_RoleController extends Zend_Controller_Action
echo "Caught exception: " . get_class($e) . "
";
echo "Message: " . $e->getMessage() . "
";
return;
+ }
+ }
+ $this->_redirect('/user/role/show/roleID/' . $roleID);
+ return;
+ } else {
+ $rightID = $rightRolesID[1];
+ if (isset($roleID) && isset($rightID)){
+ $roleMapper = new Application_Model_RoleMapper();
+ $role = $roleMapper->find($roleID);
+ $roleGroupID = $role->getGroupID();
+ if($this->userIDsNamespace['groupID'] == $roleGroupID) {
+ $rightroles = new Application_Model_RightRoles();
+ $rightroles->setRoleID($roleID);
+ $rightroles->setRightID($rightID);
+ try {
+ $this->rightRolesMapper->delete($rightroles);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "
";
+ echo "Message: " . $e->getMessage() . "
";
+ return;
+ }
+ $this->_redirect('/user/role/show/roleID/' . $roleID);
+ return;
+ } else {
+ $pbsNotifier = new Pbs_Notifier();
+ echo $pbsNotifier->notify('unlink','forbidden');
+ $this->_helper-> viewRenderer-> setNoRender();
+ return;
}
- $this->_redirect('/user/role/show/roleID/' . $roleID);
- return;
- } else {
- $pbsNotifier = new Pbs_Notifier();
- echo $pbsNotifier->notify('unlink','forbidden');
- $this->_helper-> viewRenderer-> setNoRender();
- return;
}
}
} else {
diff --git a/application/modules/user/views/scripts/role/show.phtml b/application/modules/user/views/scripts/role/show.phtml
index 8f4bb50..8c7503f 100644
--- a/application/modules/user/views/scripts/role/show.phtml
+++ b/application/modules/user/views/scripts/role/show.phtml
@@ -53,17 +53,22 @@ if($this->rightsAvailable === true) {
echo $this->formButton('linkright', 'Add Rights', array(
'onclick' => 'self.location="/user/role/linkright/roleID/' . $this->role->getID() .'"',
'class' => 'addbutton'))?>
-
rightsList)==0)
-echo "There are no Rights to display.";
-if(isset($this->rightcategorieslist)) {
- foreach($this->rightcategorieslist as $k => $v):
- $rights = $this->rightsList[$k];
- if(count($rights) > 0) {
- ?>
+if(count($this->rightsList)==0) {
+ echo "There are no Rights to display.";
+} else {
+ if($this->removeRightOfRoleRight) echo $this->formButton('deleteallrights', 'Delete All Rights', array(
+ 'onclick' => 'self.location="/user/role/unlinkright/rightrolesID/' . $this->roleID . '-all"',
+ 'class' => 'rightbutton'));?>
+
+ rightcategorieslist)) {
+ foreach($this->rightcategorieslist as $k => $v):
+ $rights = $this->rightsList[$k];
+ if(count($rights) > 0) {
+ ?>