From fca04a6dab252eb9e8c0a92ce3b7e14b32e68d1e Mon Sep 17 00:00:00 2001
From: Sebastian Schmelzer
Date: Wed, 11 Jan 2012 14:36:35 +0100
Subject: format source files
---
.../modules/dev/controllers/PersonController.php | 333 ++++++++++-----------
1 file changed, 162 insertions(+), 171 deletions(-)
(limited to 'application/modules/dev/controllers/PersonController.php')
diff --git a/application/modules/dev/controllers/PersonController.php b/application/modules/dev/controllers/PersonController.php
index 25c415a..3119ab9 100644
--- a/application/modules/dev/controllers/PersonController.php
+++ b/application/modules/dev/controllers/PersonController.php
@@ -1,176 +1,167 @@
-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->groupMapper = new Application_Model_GroupMapper();
- $this->groupRequestMapper = new Application_Model_GroupRequestMapper();
- $this->membershipMapper = new Application_Model_MembershipMapper();
- $this->memberships = $this->membershipMapper->findBy("personID",$this->person->getID());
- if(isset($this->memberships)) {
- 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']
- );
- }
- }
- } else {
- $this->_helper->redirector('login', 'auth');
- return;
- }
- }
-
- public function indexAction()
- {
- $this->_helper-> viewRenderer-> setNoRender();
- $this->_helper->redirector('show', 'person');
- return;
- }
-
- public function showAction()
- {
- $this->view->person = $this->person;
- $this->view->groups = $this->groups;
- }
-
- public function editAction()
- {
- $this->view->person = $this->person;
- if (!isset($_POST["save"])){
- $editForm = new dev_Form_PersonEdit();
- } else {
- $editForm = new dev_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) . "
";
- echo "Message: " . $e->getMessage() . "
";
- echo "Email Address already existing.";
- return;
- }
- $this->_helper->redirector('show', 'person');
- return;
- }
- }
- $this->view->editForm = $editForm;
- }
-
- public function requestAction()
- {
- $this->view->person = $this->person;
- $allgroups = $this->groupMapper->fetchAll();
- $groupRequests = $this->groupRequestMapper->findBy(array('personID' => $this->person->getID()),true);
- $count = 0;
- foreach($allgroups as $group) {
- foreach($groupRequests as $groupRequest) {
- if($groupRequest['groupID'] == $group->getID()) {
- $groupsFound[$count] = true;
- } else {
- $groupsFound[$count] = false;
- }
- }
- foreach($this->memberships as $membership) {
- if($membership['groupID'] == $group->getID()) {
- $groupsFound[$count] = true;
- } else {
- if($groupsFound[$count] != true) {
- $groupsFound[$count] = false;
- }
- }
- }
- $count++;
- }
- if(count($groupsFound) > 0) {
- foreach($groupsFound as $k => $v) {
- if($v == true) {
- unset($allgroups[$k]);
- }
- }
- }
- if (!isset($_POST["request"])){
- if(count($allgroups) <= 0) {
- echo "No Groups to choose.";
- }
- $requestForm = new dev_Form_GroupRequest(array('grouplist' => $allgroups));
- } else {
- $requestForm = new dev_Form_GroupRequest(array('grouplist' => $allgroups), $_POST);
- if ($requestForm->isValid($_POST)) {
- $groupRequestMapper = new Application_Model_GroupRequestMapper();
- $groupRequest = new Application_Model_GroupRequest();
- $groupRequest->setGroupID($_POST['groupID']);
- $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;
- }
- $this->_helper->redirector('show', 'person');
- return;
- }
- }
- $this->view->requestForm = $requestForm;
- }
-
- public function leaveAction()
- {
- $this->_helper-> viewRenderer-> setNoRender();
- $this->view->person = $this->person;
- $membershipID = $this->_request->getParam('membershipID');
- if(isset($membershipID)) {
- $membership = $this->membershipMapper->find($membershipID);
- try {
- $this->membershipMapper->delete($membership);
- } catch(Zend_Exception $e)
- {
- echo "Caught exception: " . get_class($e) . "
";
- echo "Message: " . $e->getMessage() . "
";
- return;
- }
- $this->_helper->redirector('show', 'person');
- return;
- }
- }
+* This program is free software distributed under the GPL version 2.
+* See http://gpl.openslx.org/
+*
+* If you have any feedback please consult http://feedback.openslx.org/ and
+* send your suggestions, praise, or complaints to feedback@openslx.org
+*
+* General information about OpenSLX can be found at http://openslx.org/
+*/
+
+class dev_PersonController extends Zend_Controller_Action {
+ protected $person;
+ protected $personmapper;
+ protected $membershipMapper;
+ protected $memberships;
+ protected $groupMapper;
+ protected $groups;
+ protected $groupRequestMapper;
+
+ 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->groupMapper = new Application_Model_GroupMapper();
+ $this->groupRequestMapper = new Application_Model_GroupRequestMapper();
+ $this->membershipMapper = new Application_Model_MembershipMapper();
+ $this->memberships = $this->membershipMapper->findBy("personID", $this->person->getID());
+ if(isset($this->memberships)) {
+ 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']
+ );
+ }
+ }
+ } else {
+ $this->_helper->redirector('login', 'auth');
+ return;
+ }
+ }
+
+ public function indexAction() {
+ $this->_helper-> viewRenderer-> setNoRender();
+ $this->_helper->redirector('show', 'person');
+ return;
+ }
+
+ public function showAction() {
+ $this->view->person = $this->person;
+ $this->view->groups = $this->groups;
+ }
+
+ public function editAction() {
+ $this->view->person = $this->person;
+ if (!isset($_POST["save"])) {
+ $editForm = new dev_Form_PersonEdit();
+ } else {
+ $editForm = new dev_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) . "
";
+ echo "Message: " . $e->getMessage() . "
";
+ echo "Email Address already existing.";
+ return;
+ }
+ $this->_helper->redirector('show', 'person');
+ return;
+ }
+ }
+ $this->view->editForm = $editForm;
+ }
+
+ public function requestAction() {
+ $this->view->person = $this->person;
+ $allgroups = $this->groupMapper->fetchAll();
+ $groupRequests = $this->groupRequestMapper->findBy(array('personID' => $this->person->getID()), true);
+ $count = 0;
+ foreach($allgroups as $group) {
+ foreach($groupRequests as $groupRequest) {
+ if($groupRequest['groupID'] == $group->getID()) {
+ $groupsFound[$count] = true;
+ } else {
+ $groupsFound[$count] = false;
+ }
+ }
+ foreach($this->memberships as $membership) {
+ if($membership['groupID'] == $group->getID()) {
+ $groupsFound[$count] = true;
+ } else {
+ if($groupsFound[$count] != true) {
+ $groupsFound[$count] = false;
+ }
+ }
+ }
+ $count++;
+ }
+ if(count($groupsFound) > 0) {
+ foreach($groupsFound as $k => $v) {
+ if($v == true) {
+ unset($allgroups[$k]);
+ }
+ }
+ }
+ if (!isset($_POST["request"])) {
+ if(count($allgroups) <= 0) {
+ echo "No Groups to choose.";
+ }
+ $requestForm = new dev_Form_GroupRequest(array('grouplist' => $allgroups));
+ } else {
+ $requestForm = new dev_Form_GroupRequest(array('grouplist' => $allgroups), $_POST);
+ if ($requestForm->isValid($_POST)) {
+ $groupRequestMapper = new Application_Model_GroupRequestMapper();
+ $groupRequest = new Application_Model_GroupRequest();
+ $groupRequest->setGroupID($_POST['groupID']);
+ $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;
+ }
+ $this->_helper->redirector('show', 'person');
+ return;
+ }
+ }
+ $this->view->requestForm = $requestForm;
+ }
+
+ public function leaveAction() {
+ $this->_helper-> viewRenderer-> setNoRender();
+ $this->view->person = $this->person;
+ $membershipID = $this->_request->getParam('membershipID');
+ if(isset($membershipID)) {
+ $membership = $this->membershipMapper->find($membershipID);
+ try {
+ $this->membershipMapper->delete($membership);
+ } catch(Zend_Exception $e) {
+ echo "Caught exception: " . get_class($e) . "
";
+ echo "Message: " . $e->getMessage() . "
";
+ return;
+ }
+ $this->_helper->redirector('show', 'person');
+ return;
+ }
+ }
}
--
cgit v1.2.3-55-g7522