summaryrefslogtreecommitdiffstats
path: root/application/controllers/PersonController.php
diff options
context:
space:
mode:
authorSimon2011-03-14 16:09:03 +0100
committerSimon2011-03-14 16:09:03 +0100
commitb5cbdd6b400aa1ec77c9846e9cc8d4257f437e3c (patch)
treefcef50ad1ddf831f457d6aecd83e7fdc63297a1c /application/controllers/PersonController.php
parentfooter bleibt am fensterbottom (diff)
downloadpbs2-b5cbdd6b400aa1ec77c9846e9cc8d4257f437e3c.tar.gz
pbs2-b5cbdd6b400aa1ec77c9846e9cc8d4257f437e3c.tar.xz
pbs2-b5cbdd6b400aa1ec77c9846e9cc8d4257f437e3c.zip
Application in 3 Modules gesplittet, Dev = unsere entwicklungsumgebung, user = die weboberfläche fr anwender mit acl etc, fbgui = für die fbgui truppe - links in dev müssen noch angepasst werden
Diffstat (limited to 'application/controllers/PersonController.php')
-rw-r--r--application/controllers/PersonController.php154
1 files changed, 0 insertions, 154 deletions
diff --git a/application/controllers/PersonController.php b/application/controllers/PersonController.php
deleted file mode 100644
index 0b6db2e..0000000
--- a/application/controllers/PersonController.php
+++ /dev/null
@@ -1,154 +0,0 @@
-<?php
-
-class 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('email', Zend_Auth::getInstance()->getIdentity());
- $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 (
- 'id' => $group->getID(),
- 'title' => $group->getTitle()
- );
- }
- }
- } else {
- $this->_helper->redirector('login', 'auth');
- }
- }
-
- public function indexAction()
- {
- $this->_helper->redirector('show', 'person');
- }
-
- 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 Application_Form_PersonEdit();
- } else {
- $editForm = new Application_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;
- }
- echo "Successfully saved. <br/>";
- }
- }
-
- $this->view->editForm = $editForm;
- }
-
- public function requestAction()
- {
- $this->view->person = $this->person;
- $allgroups = $this->groupMapper->fetchAll();
- $groupRequests = $this->groupRequestMapper->findBy('personID', $this->person->getID());
- $count = 0;
- foreach($allgroups as $group) {
- foreach($groupRequests as $groupRequest) {
- if($groupRequest['groupID'] == $group->getID()) {
- unset($allgroups[$count]);
- }
- }
- $count++;
- }
- if (!isset($_POST["request"])){
- if(count($allgroups) <= 0) {
- echo "No Groups to choose.";
- }
- $requestForm = new Application_Form_GroupRequest(array('grouplist' => $allgroups));
- } else {
- $requestForm = new Application_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) . "<br/>";
- echo "Message: " . $e->getMessage() . "<br/>";
- return;
- }
- echo "Successfully requested. <br />";
- }
- }
- $this->view->requestForm = $requestForm;
- }
-
- public function leaveAction()
- {
- $this->view->person = $this->person;
- if(isset($_POST['groupID'])) {
- if(isset($this->memberships)) {
- foreach($this->memberships as $membership) {
- if($membership['groupID'] == $_POST['groupID']) {
- $membershipObject = $this->membershipMapper->find($membership['membershipID']);
- try {
- $this->membershipMapper->delete($membershipObject);
- } catch(Zend_Exception $e)
- {
- echo "Caught exception: " . get_class($e) . "<br/>";
- echo "Message: " . $e->getMessage() . "<br/>";
- return;
- }
- echo "You have been successfully removed from the chosen group. <br />";
- }
- }
- }
- }
- }
-}
-
-
-
-
-
-
-
-
-
-
-