diff options
| author | Simon | 2011-04-13 12:59:17 +0200 |
|---|---|---|
| committer | Simon | 2011-04-13 12:59:17 +0200 |
| commit | a3fe05f88ef948366d58dbc47b3d55a8b4511df5 (patch) | |
| tree | 326633fde5d5a7c326106a86c4bd0aeb7f9356bc /application/modules | |
| parent | Code eingerückt damit man es lesen kann (diff) | |
| download | pbs2-a3fe05f88ef948366d58dbc47b3d55a8b4511df5.tar.gz pbs2-a3fe05f88ef948366d58dbc47b3d55a8b4511df5.tar.xz pbs2-a3fe05f88ef948366d58dbc47b3d55a8b4511df5.zip | |
Erster Teil der Rechte in Group Controller
Diffstat (limited to 'application/modules')
3 files changed, 129 insertions, 75 deletions
diff --git a/application/modules/user/controllers/GroupController.php b/application/modules/user/controllers/GroupController.php index 37cdee8..fb0d2a9 100644 --- a/application/modules/user/controllers/GroupController.php +++ b/application/modules/user/controllers/GroupController.php @@ -10,6 +10,7 @@ class User_GroupController extends Zend_Controller_Action protected $rolemapper = null; protected $groupList = null; protected $userIDsNamespace = null; + protected $membership; public function init() { @@ -22,6 +23,11 @@ class User_GroupController extends Zend_Controller_Action $this->personmapper = new Application_Model_PersonMapper(); $this->rolemapper = new Application_Model_RoleMapper(); $this->groupList = $this->groupMapper->fetchAll(); + + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + $this->membership = new Application_Model_Membership(); + $this->membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); + } else { $this->_helper->redirector('login', 'auth'); return; @@ -30,6 +36,10 @@ class User_GroupController extends Zend_Controller_Action public function indexAction() { + // ACL show overview + if(!Pbs_Acl::checkRight('gso')) + $this->_redirect('/user'); + $this->view->groupList = $this->groupList; // Search @@ -62,6 +72,10 @@ class User_GroupController extends Zend_Controller_Action public function addAction() { + // ACL create new group + if(!Pbs_Acl::checkRight('gc')) + $this->_redirect('/user'); + if (!isset($_POST["add"])){ $addForm = new user_Form_GroupAdd(array('grouplist' => $this->groupList)); } else { @@ -139,6 +153,11 @@ class User_GroupController extends Zend_Controller_Action public function editAction() { + // ACL edit a group + // TODO: THERE IS NO RIGHT TO EDIT A GROUP + #if(!Pbs_Acl::checkRight('')) + # $this->_redirect('/user'); + $groupID = $this->_request->getParam('groupID'); if(!isset($groupID)) { if(count($this->userIDsNamespace) > 0) { @@ -176,27 +195,42 @@ class User_GroupController extends Zend_Controller_Action public function showAction() { + // ACL create new group + if(!Pbs_Acl::checkRight('gsdo') && !Pbs_Acl::checkRight('gsdog')) + $this->_redirect('/user'); + $groupID = $this->_request->getParam('groupID'); - if(!isset($groupID)) { + if($groupID == '' || !Pbs_Acl::checkRight('gsdog')) { if(count($this->userIDsNamespace) > 0) { $groupID = $this->userIDsNamespace['groupID']; } } - if($groupID) { + if($groupID == $this->membership->getGroupID() && !Pbs_Acl::checkRight('gsdo')) + $this->_redirect('/user'); + + $this->view->usergroup = $this->membership->getGroupID(); + $this->view->requestgroup = $groupID; + // ACL is he allowed to see the requests of a group ? + // TODO: THERE IS NO RIGHT TO EDIT A GROUP + # if(Pbs_Acl::checkRight('')){ $groupRequests = $this->groupRequestMapper->findBy(array('groupID' => $groupID),true); if(isset($groupRequests)) { foreach($groupRequests as $groupRequest) { $person = $this->personmapper->find($groupRequest['personID']); $groupRequestList[] = array( - 'grouprequestID' => $groupRequest['grouprequestID'], - 'person' => $person + 'grouprequestID' => $groupRequest['grouprequestID'], + 'person' => $person ); } if(is_array($groupRequestList)) { $this->view->groupRequestList = $groupRequestList; } + // TODO: expand with al inherit roles $this->view->roleList = $this->rolemapper->findBy(array('groupID' => $groupID),true); } + # } + + if(Pbs_Acl::checkRight('gsmg')){ $members = $this->membershipMapper->findBy(array('groupID' => $groupID),true); if(isset($members)) { foreach($members as $member) { @@ -225,19 +259,16 @@ class User_GroupController extends Zend_Controller_Action $this->view->page = $memberPagination->getRequestPage(); } } - $groupgroups = $this->groupGroupsMapper->findBy(array('groupID' => $groupID),true); - if(is_object($groupgroups)) { - $parentGroup = $this->groupMapper->find($groupgroups->getParentID()); - $this->view->$parentGroup = $parentGroup; - } - $group = $this->groupMapper->find($groupID); - $this->view->userIDsNamespace = $this->userIDsNamespace; - $this->view->group = $group; - $this->view->groupID = $groupID; - } else { - $this->_redirect('/user/'); - return; } + $groupgroups = $this->groupGroupsMapper->findBy(array('groupID' => $groupID),true); + if(is_object($groupgroups)) { + $parentGroup = $this->groupMapper->find($groupgroups->getParentID()); + $this->view->$parentGroup = $parentGroup; + } + $group = $this->groupMapper->find($groupID); + $this->view->userIDsNamespace = $this->userIDsNamespace; + $this->view->group = $group; + $this->view->groupID = $groupID; } public function linkAction() @@ -355,4 +386,4 @@ class User_GroupController extends Zend_Controller_Action } } } -}
\ No newline at end of file +} diff --git a/application/modules/user/views/scripts/group/index.phtml b/application/modules/user/views/scripts/group/index.phtml index 2e376b3..e3b5082 100644 --- a/application/modules/user/views/scripts/group/index.phtml +++ b/application/modules/user/views/scripts/group/index.phtml @@ -6,31 +6,34 @@ ?> <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 +<div class='listelement'> +<?php if(count($this->groupList)==0) -echo "There are no groups" ?> <?php foreach ($this->groupList as $k => $group): ?> +echo "There are no groups" ?> +<?php foreach ($this->groupList as $k => $group): ?> <?php $class=''; if($group->getID() == $this->userIDsNamespace['groupID']) $class= 'highlight checked'; ?> -<div class='element<?php echo " $class";?>'><?php if($group->getID() != $this->userIDsNamespace['groupID']) { + <div class='element<?php echo " $class";?>'> + <?php if($group->getID() != $this->userIDsNamespace['groupID']) { + ?> + <div class='number'> + <div class='smallnumber'>Group</div> + <?php echo $k+1; ?> + </div> + <?php + } ?> -<div class='number'> - <div class='smallnumber'>Group</div> - <?php echo $k+1; ?> -</div> - <?php -} -?> -<div class='content'> -<div class='actions'><a - href="<?php if($group->getID() == $this->userIDsNamespace['groupID']) echo $this->url( + <div class='content'> + <div class='actions'> + <a href="<?php if($group->getID() == $this->userIDsNamespace['groupID']) echo $this->url( array( 'module' => 'user', 'controller' => 'group', @@ -45,9 +48,8 @@ $class= 'highlight checked'; 'groupID' => $group->getID() ), 'default', - true); ?>"> <img src='/media/img/show.png' alt='Show Group' /></a> -<a - href="<?php if($group->getID() == $this->userIDsNamespace['groupID']) echo $this->url( + true); ?>"> <img src='/media/img/show.png' alt='Show Group' /> </a> + <a href="<?php if($group->getID() == $this->userIDsNamespace['groupID']) echo $this->url( array( 'module' => 'user', 'controller' => 'group', @@ -62,9 +64,8 @@ $class= 'highlight checked'; 'groupID' => $group->getID() ), 'default', - true); ?>"> <img src='/media/img/edit.png' alt='Edit Group' /></a> -<a - href="<?php if($group->getID() == $this->userIDsNamespace['groupID']) echo $this->url( + true); ?>"> <img src='/media/img/edit.png' alt='Edit Group' /> </a> + <a href="<?php if($group->getID() == $this->userIDsNamespace['groupID']) echo $this->url( array( 'module' => 'user', 'controller' => 'group', @@ -80,24 +81,26 @@ $class= 'highlight checked'; ), 'default', true); ?>"> <img src='/media/img/delete.png' alt='Delete Group' /></a> + </div> + <div class='title'><?php echo $group->getTitle(); ?></div> + <?php if($group->getDescription()) { + ?> + <div class='subtitle'><?php echo $group->getDescription(); ?></div> + <?php + } else { + ?> + <div class='subtitle'> </div> + <?php + } + ?> + </div> + <div class='clear'></div> + </div> + <?php endforeach ?> </div> -<div class='title'><?php echo $group->getTitle(); ?></div> - <?php if($group->getDescription()) { - ?> -<div class='subtitle'><?php echo $group->getDescription(); ?></div> - <?php - } else { - ?> -<div class='subtitle'> </div> - <?php - } - ?></div> -<div class='clear'></div> -</div> -<?php endforeach ?></div> -<?php echo $this->pagination; ?> + <?php echo $this->pagination; ?> -<?php echo $this->formButton('linkgroups', 'Link Groups', array( + <?php echo $this->formButton('linkgroups', 'Link Groups', array( 'onclick' => 'self.location="/user/group/link"', 'class' => 'addbutton')) ?> diff --git a/application/modules/user/views/scripts/group/show.phtml b/application/modules/user/views/scripts/group/show.phtml index f1a14d1..18bc33a 100644 --- a/application/modules/user/views/scripts/group/show.phtml +++ b/application/modules/user/views/scripts/group/show.phtml @@ -1,31 +1,32 @@ -<?php -if($this->groupID) { - if(isset($this->userIDsNamespace['groupID'])) { - ?> -<h1>Own Group</h1> - <?php - echo $this->formButton('deletegroup', 'Delete', array( +<h1>Groupdetails</h1> +<?php +if($this->usergroup == $this->requestgroup){ + echo $this->formButton('deletegroup', 'Delete', array( 'onclick' => 'self.location="/user/group/delete/"', 'class' => 'rightbutton')); - echo $this->formButton('editgroup', 'Edit', array( + echo $this->formButton('editgroup', 'Edit', array( 'onclick' => 'self.location="/user/group/edit/"', 'class' => 'rightbutton')); - } else { - ?> -<h1>Group Details</h1> - <?php - echo $this->formButton('deletegroup', 'Delete', array( +} +else{ + echo $this->formButton('deletegroup', 'Delete', array( 'onclick' => 'self.location="/user/group/delete/groupID/' . $this->group->getID() .'"', 'class' => 'rightbutton')); - echo $this->formButton('editgroup', 'Edit', array( + echo $this->formButton('editgroup', 'Edit', array( 'onclick' => 'self.location="/user/group/edit/groupID/' . $this->group->getID() .'"', 'class' => 'rightbutton')); - } - ?> +} +?> <div class='listelement'> <div class='element'> <div class='number'> - <div class='smallnumber'>Your Group</div> + <?php + if($this->usergroup == $this->requestgroup){ ?> + <div class='smallnumber'>Your Group</div> + <?php }else{ ?> + <div class='smallnumber'>Group</div> + <?php echo $this->group->getID(); ?> + <?php } ?> </div> <div class='content'> <div class='title'><?php echo $this->group->getTitle(); ?></div> @@ -40,7 +41,7 @@ if($this->groupID) { </div> </div> <?php -} + // Show Request List if(isset($this->groupRequestList)){ @@ -55,12 +56,23 @@ if(isset($this->groupRequestList)){ ?> <div class='element'> <div class='content'> + <?php + if($this->usergroup == $this->requestgroup && (Pbs_Acl::checkRight('gam') || Pbs_Acl::checkRight('gdm'))){ + ?> <div class='actions'> + <?php if(Pbs_Acl::checkRight('gam')): ?> <form action="/user/group/grantperson" method="post"> <input type="hidden" name="grouprequestID" value="<?php echo $grouprequestID; ?>" /> <?php printRoleSelect($this->roleList); ?> <input type="image" src='/media/img/save.png' alt='Grant Person' name="confirm" value="confirm" /> </form> + <?php endif; ?> + <?php if(Pbs_Acl::checkRight('gdm')): ?> + TODO + <?php endif; ?> </div> + <?php + } + ?> <div class='title'><?php echo $person->getTitle(); ?> <?php echo $person->getFirstname(); ?> <?php echo $person->getName(); ?></div> <div class='subtitle'><?php echo $person->getCity(); ?></div> <div class='details dispnone'> @@ -69,12 +81,14 @@ if(isset($this->groupRequestList)){ </div> </div> </div> - <?php } ?> + <?php + } + ?> </div> <?php } // Show Memberlist -if(isset($this->membersList)){ +if(isset($this->membersList) && Pbs_Acl::checkRight('gsmg')){ ?> <br /> <h2>Members:</h2> @@ -105,6 +119,9 @@ if(count($this->membersList)==0) ?> <div class='content'> <div class='actions'> + <?php + if((Pbs_Acl::checkRight('gdmo') && $this->usergroup == $this->requestgroup) || (Pbs_Acl::checkRight('gdmog') && $this->usergroup != $this->requestgroup)): + ?> <a href="<?php echo $this->url( array( 'module' => 'user', @@ -114,6 +131,9 @@ if(count($this->membersList)==0) ), 'default', true) ?>"> <img src='/media/img/delete.png' alt='Revoke Membership' /></a> + <?php + endif; + ?> </div> <div class='title'><?php echo $person->getFirstname(); ?> <?php echo $person->getName(); ?></div> <div class='subtitle'>Role: <?php echo $role->getTitle(); ?></div> |
