diff options
Diffstat (limited to 'application/modules/user/controllers/PersonController.php')
| -rw-r--r-- | application/modules/user/controllers/PersonController.php | 82 |
1 files changed, 42 insertions, 40 deletions
diff --git a/application/modules/user/controllers/PersonController.php b/application/modules/user/controllers/PersonController.php index da640ba..07a69ee 100644 --- a/application/modules/user/controllers/PersonController.php +++ b/application/modules/user/controllers/PersonController.php @@ -14,19 +14,12 @@ 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() @@ -34,7 +27,7 @@ class user_PersonController extends Zend_Controller_Action if (Zend_Auth::getInstance()->hasIdentity()) { $this->personmapper = new Application_Model_PersonMapper(); $this->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); - if($this->userIDsNamespace['personID']) { + if(isset($this->userIDsNamespace['personID'])) { $this->person = $this->personmapper->find($this->userIDsNamespace['personID']); } else { $result = $this->personmapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()),true); @@ -45,28 +38,28 @@ class user_PersonController extends Zend_Controller_Action $this->groupRequestMapper = new Application_Model_GroupRequestMapper(); $this->membershipMapper = new Application_Model_MembershipMapper(); $this->memberships = $this->membershipMapper->findBy(array("personID" => $this->person->getID()),true); - + $rightrolesMapper = new Application_Model_RightRolesMapper(); - $rightroles = new Application_Model_RightRoles(); + $rightroles = new Application_Model_RightRoles(); $role = new Application_Model_Role(); $roleMapper = new Application_Model_RoleMapper(); - - $this->view->apikeys = array(); + $this->view->apikeys = array(); + if(isset($this->memberships)) { foreach($this->memberships as $membership) { $group = $this->groupMapper->find($membership['groupID']); @list($rightroles) = $rightrolesMapper->findBy(array('rightID' => '55', 'roleID' => $membership['roleID'])); $role = $roleMapper->find($membership['roleID']); if($rightroles != null) - $this->view->apikeys[$group->getID()] = $membership['apikey']; - + $this->view->apikeys[$group->getID()] = $membership['apikey']; + $this->groups[] = array ( - 'groupID' => $group->getID(), - 'title' => $group->getTitle(), - 'description' => $group->getDescription(), - 'membershipID' => $membership['membershipID'], - 'role' => $role->getTitle() + 'groupID' => $group->getID(), + 'title' => $group->getTitle(), + 'description' => $group->getDescription(), + 'membershipID' => $membership['membershipID'], + 'role' => $role->getTitle() ); } } @@ -111,7 +104,7 @@ class user_PersonController extends Zend_Controller_Action $pagination->setPageUrl('/user/person/index/'.((isset($this->view->search))?'/search/'.$this->view->search:'')); $this->view->personList = $pagination->getElements(); - $this->view->pagination = $pagination->pagination($pageurl); + $this->view->pagination = $pagination->pagination(); $this->view->page = $pagination->getRequestPage(); } @@ -123,6 +116,7 @@ class user_PersonController extends Zend_Controller_Action $this->view->person = $this->person; $groupRequests = $this->groupRequestMapper->findBy(array('personID' => $this->person->getID()),true); if(isset($groupRequests)) { + $groupRequestList = array(); foreach($groupRequests as $groupRequest) { $group = $this->groupMapper->find($groupRequest['groupID']); $groupRequestList[] = array( @@ -130,7 +124,7 @@ class user_PersonController extends Zend_Controller_Action 'group' => $group ); } - if(is_array($groupRequestList)) { + if(count($groupRequestList)> 0) { $this->view->groupRequestList = $groupRequestList; } } @@ -142,7 +136,7 @@ class user_PersonController extends Zend_Controller_Action $pagination->setPageUrl('/user/person/index' .((isset($this->view->search))?'/search/'.$this->view->search:'')); $this->view->groups = $pagination->getElements(); - $this->view->pagination = $pagination->pagination($pageurl); + $this->view->pagination = $pagination->pagination(); $this->view->page = $pagination->getRequestPage(); // This should be activated in case the person has no membership and no rights. $this->view->groupRequestRight = true; @@ -157,7 +151,7 @@ class user_PersonController extends Zend_Controller_Action if(!Pbs_Acl::checkRight('peod')) { $this->_redirect('/user'); } - if($personID = $this->_request->getParam('personID')) { + if($this->person->getID() == $this->_request->getParam('personID')) { if(!Pbs_Acl::checkRight('peoa')) { $this->_redirect('/user'); } @@ -171,14 +165,14 @@ class user_PersonController extends Zend_Controller_Action } else { $editForm = new user_Form_PersonEdit($_POST); if ($editForm->isValid($_POST)) { - if($personID = $this->_request->getParam('personID')) { - if(isset($_POST['newpassword'])) { - $date = new DateTime(); + if($this->person->getID() == $this->_request->getParam('personID')) { + + $person->setOptions($_POST); + if($_POST['newpassword'] != '') { $person->setPassword($_POST['newpassword']); - $person->setPasswordSalt(MD5($date->getTimestamp())); - $person->setPassword(MD5($person->getPassword() . $this->person->getPasswordSalt())); + $person->setPasswordSalt(MD5(microtime(true))); + $person->setPassword(MD5($person->getPassword() . $person->getPasswordSalt())); } - $person->setOptions($_POST); try { $this->personmapper->save($person); } catch(Zend_Exception $e) @@ -189,14 +183,13 @@ class user_PersonController extends Zend_Controller_Action return; } $this->_helper->redirector('', 'person'); - } else { - if(isset($_POST['newpassword'])) { - $date = new DateTime(); + } else { + $this->person->setOptions($_POST); + if($_POST['newpassword'] != '') { $this->person->setPassword($_POST['newpassword']); - $this->person->setPasswordSalt(MD5($date->getTimestamp())); + $this->person->setPasswordSalt(MD5(microtime(true))); $this->person->setPassword(MD5($this->person->getPassword() . $this->person->getPasswordSalt())); } - $this->person->setOptions($_POST); try { $this->personmapper->save($this->person); } catch(Zend_Exception $e) @@ -235,7 +228,7 @@ class user_PersonController extends Zend_Controller_Action if($membership['groupID'] == $group->getID()) { $groupsFound[$count] = true; } else { - if($groupsFound[$count] != true) { + if(@$groupsFound[$count] != true) { $groupsFound[$count] = false; } } @@ -316,7 +309,15 @@ class user_PersonController extends Zend_Controller_Action if(isset($userIDsNamespace['membershipID'])) { $this->_redirect('/user/'); } else { - if(count($this->memberships) > 0) { + if(count($this->memberships) == 1) { + $myMembership = $this->memberships[0]; + $roleSession = new Zend_Session_Namespace('userIDs'); + $roleSession->membershipID = $myMembership['membershipID']; + $roleSession->personID = $myMembership['personID']; + $roleSession->groupID = $myMembership['groupID']; + $roleSession->roleID = $myMembership['roleID']; + $this->_redirect('/user/'); + } elseif(count($this->memberships) > 1) { if(isset($_POST['selectmembership'])) { $roleSession = new Zend_Session_Namespace('userIDs'); $roleSession->membershipID = $_POST['membershipID']; @@ -330,6 +331,7 @@ class user_PersonController extends Zend_Controller_Action $groupMapper = new Application_Model_GroupMapper(); $roleMapper = new Application_Model_RoleMapper(); if(isset($this->memberships)) { + $suspendlist = array(); foreach($this->memberships as $membership) { $group = $groupMapper->find($membership['groupID']); $role = $roleMapper->find($membership['roleID']); @@ -345,8 +347,8 @@ class user_PersonController extends Zend_Controller_Action 'membershipID' => $membership['membershipID'], 'group' => $group->getTitle(), 'role' => $role->getTitle()); - } - + } + } if(count($suspendlist) >=1){ $pbsNotifier = new Pbs_Notifier(); @@ -420,7 +422,7 @@ class user_PersonController extends Zend_Controller_Action $pagination->setPageUrl('/user/person/show/personID/' . $personID .((isset($this->view->search))?'/search/'.$this->view->search:'')); $this->view->groups = $pagination->getElements(); - $this->view->pagination = $pagination->pagination($pageurl); + $this->view->pagination = $pagination->pagination(); $this->view->page = $pagination->getRequestPage(); $this->view->personID = $personID; $this->view->editRight = Pbs_Acl::checkRight('peoa'); @@ -437,7 +439,7 @@ class user_PersonController extends Zend_Controller_Action { if(!Pbs_Acl::checkRight('gdm')) { $this->_redirect('/user'); - } + } $grouprequestID = $this->_request->getParam('grouprequestID'); $grouprequest = $this->groupRequestMapper->find($grouprequestID); try { |
