diff options
| author | michael pereira | 2011-04-05 15:35:35 +0200 |
|---|---|---|
| committer | michael pereira | 2011-04-05 15:35:35 +0200 |
| commit | 324b653c50e328019127c0aad29939fb933e4bcf (patch) | |
| tree | 10f6eaa134ab8a8bb804b8699293ad8fa2ef5b65 /application/modules/user/controllers/PersonController.php | |
| parent | Rechte in Controller eingepflanzt (diff) | |
| parent | Merge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2 (diff) | |
| download | pbs2-324b653c50e328019127c0aad29939fb933e4bcf.tar.gz pbs2-324b653c50e328019127c0aad29939fb933e4bcf.tar.xz pbs2-324b653c50e328019127c0aad29939fb933e4bcf.zip | |
Merge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2
Diffstat (limited to 'application/modules/user/controllers/PersonController.php')
| -rw-r--r-- | application/modules/user/controllers/PersonController.php | 150 |
1 files changed, 118 insertions, 32 deletions
diff --git a/application/modules/user/controllers/PersonController.php b/application/modules/user/controllers/PersonController.php index e614b98..08add21 100644 --- a/application/modules/user/controllers/PersonController.php +++ b/application/modules/user/controllers/PersonController.php @@ -2,7 +2,6 @@ class user_PersonController extends Zend_Controller_Action { - protected $person = null; protected $personmapper = null; protected $membershipMapper = null; @@ -10,14 +9,20 @@ class user_PersonController extends Zend_Controller_Action protected $groupMapper = null; protected $groups = null; protected $groupRequestMapper = null; + protected $userIDsNamespace = null; public function init() { if (Zend_Auth::getInstance()->hasIdentity()) { $this->personmapper = new Application_Model_PersonMapper(); - $result = $this->personmapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()),true); - $this->person = new Application_Model_Person($result[0]); - $this->person->setID($result[0]['personID']); + $this->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + if($this->userIDsNamespace['personID']) { + $this->person = $this->personmapper->find($this->userIDsNamespace['personID']); + } else { + $result = $this->personmapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()),true); + $this->person = new Application_Model_Person($result[0]); + $this->person->setID($result[0]['personID']); + } $this->groupMapper = new Application_Model_GroupMapper(); $this->groupRequestMapper = new Application_Model_GroupRequestMapper(); $this->membershipMapper = new Application_Model_MembershipMapper(); @@ -26,10 +31,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'] ); } } @@ -41,12 +46,15 @@ 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->groupRequestRight = Pbs_Acl::checkRight('grm'); + $this->view->editRight = Pbs_Acl::checkRight('peoa'); + $this->view->leaveRight = Pbs_Acl::checkRight('gl'); + $this->view->overviewRight = Pbs_Acl::checkRight('pso'); $this->view->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); } @@ -55,27 +63,54 @@ class user_PersonController extends Zend_Controller_Action if(!Pbs_Acl::checkRight('peod')) { $this->_redirect('/user'); } - $this->view->person = $this->person; + if($personID = $this->_request->getParam('personID')) { + if(!Pbs_Acl::checkRight('peoa')) { + $this->_redirect('/user'); + } + $person = $this->personmapper->find($personID); + $this->view->person = $person; + } else { + $this->view->person = $this->person; + } if (!isset($_POST["save"])){ $editForm = new user_Form_PersonEdit(); } else { $editForm = new user_Form_PersonEdit($_POST); if ($editForm->isValid($_POST)) { - if(isset($_POST['newpassword'])) { - $date = new DateTime(); - $this->person->setPassword($_POST['newpassword']); - $this->person->setPasswordSalt(MD5($date->getTimestamp())); - $this->person->setPassword(MD5($this->person->getPassword() . $this->person->getPasswordSalt())); - } - $this->person->setOptions($_POST); - try { - $this->personmapper->save($this->person); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - echo "Email Address already existing."; - return; + if($personID = $this->_request->getParam('personID')) { + if(isset($_POST['newpassword'])) { + $date = new DateTime(); + $person->setPassword($_POST['newpassword']); + $person->setPasswordSalt(MD5($date->getTimestamp())); + $person->setPassword(MD5($person->getPassword() . $this->person->getPasswordSalt())); + } + $person->setOptions($_POST); + try { + $this->personmapper->save($person); + } catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + echo "Email Address already existing."; + return; + } + } else { + if(isset($_POST['newpassword'])) { + $date = new DateTime(); + $this->person->setPassword($_POST['newpassword']); + $this->person->setPasswordSalt(MD5($date->getTimestamp())); + $this->person->setPassword(MD5($this->person->getPassword() . $this->person->getPasswordSalt())); + } + $this->person->setOptions($_POST); + try { + $this->personmapper->save($this->person); + } catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + echo "Email Address already existing."; + return; + } } $this->_helper->redirector('', 'person'); return; @@ -151,10 +186,9 @@ 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'); - }*/ + if(!Pbs_Acl::checkRight('gl')) { + $this->_redirect('/user'); + } $this->_helper-> viewRenderer-> setNoRender(); $this->view->person = $this->person; $membershipID = $this->_request->getParam('membershipID'); @@ -197,9 +231,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() ); } } @@ -220,6 +254,54 @@ class user_PersonController extends Zend_Controller_Action return; } + public function showallAction() + { + if(!Pbs_Acl::checkRight('pso')) { + $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->showOtherRight = Pbs_Acl::checkRight('psood'); + $this->view->editOtherRight = Pbs_Acl::checkRight('peoa'); + $this->view->deleteOtherRight = Pbs_Acl::checkRight('pdo'); + $this->view->userIDsNamespace = $this->userIDsNamespace; + $this->view->personList = $this->personmapper->fetchAll(); + } + + public function showAction() + { + if(!Pbs_Acl::checkRight('psood')) { + $this->_redirect('/user'); + } + $personID = $this->_request->getParam('personID'); + if($personID) { + $person = $this->personmapper->find($personID); + $memberships = $this->membershipMapper->findBy(array("personID" => $person->getID()),true); + if(isset($memberships)) { + foreach($memberships as $membership) { + $group = $this->groupMapper->find($membership['groupID']); + $groups[] = array ( + 'groupID' => $group->getID(), + 'title' => $group->getTitle(), + 'description' => $group->getDescription(), + 'membershipID' => $membership['membershipID'] + ); + } + } + $this->view->person = $person; + $this->view->groups = $groups; + $this->view->personID = $personID; + $this->view->editRight = Pbs_Acl::checkRight('peoa'); + $this->view->deleteRight = Pbs_Acl::checkRight('pd'); + $this->view->overviewRight = Pbs_Acl::checkRight('pso'); + $this->view->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + } else { + $this->_helper->redirector('', 'person'); + return; + } + } + } @@ -237,3 +319,7 @@ class user_PersonController extends Zend_Controller_Action + + + + |
