diff options
| author | michael pereira | 2011-03-04 03:21:32 +0100 |
|---|---|---|
| committer | michael pereira | 2011-03-04 03:21:32 +0100 |
| commit | e2db1dc442e9f28fe666537a8af024c810912bb4 (patch) | |
| tree | de16d36dff50a950dd963788689e18576a6db02f /application/controllers | |
| parent | Inserted deleteForm (diff) | |
| parent | Änderungen an den Filtern (diff) | |
| download | pbs2-e2db1dc442e9f28fe666537a8af024c810912bb4.tar.gz pbs2-e2db1dc442e9f28fe666537a8af024c810912bb4.tar.xz pbs2-e2db1dc442e9f28fe666537a8af024c810912bb4.zip | |
Merge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2
Conflicts:
.zfproject.xml
Diffstat (limited to 'application/controllers')
| -rw-r--r-- | application/controllers/AuthController.php | 70 | ||||
| -rw-r--r-- | application/controllers/FilterController.php | 75 |
2 files changed, 108 insertions, 37 deletions
diff --git a/application/controllers/AuthController.php b/application/controllers/AuthController.php index 4264e7b..fd30d82 100644 --- a/application/controllers/AuthController.php +++ b/application/controllers/AuthController.php @@ -3,10 +3,14 @@ class AuthController extends Zend_Controller_Action { - public function loginAction() + public function init() { - $db = Zend_Db_Table::getDefaultAdapter(); - + $db = Zend_Db_Table::getDefaultAdapter(); + + } + + public function loginAction() + { if (!isset($_POST["login"])){ $loginForm = new Application_Form_AuthLogin(); } else { @@ -31,14 +35,12 @@ class AuthController extends Zend_Controller_Action $result = $auth->authenticate($adapter); // TODO: erweiterte fehlerbeschreibung des Users - // siehe http://framework.zend.com/manual/en/zend.auth.introduction.html if ($result->isValid()) { - #$this->_helper->FlashMessenger('Erfolgreich angemeldet'); $this->_redirect('/'); return; } else { - //$this->_helper->FlashMessenger('E-Mail oder Passwort falsch'); + echo "Falsche Email oder Passwort"; } } } @@ -47,25 +49,35 @@ class AuthController extends Zend_Controller_Action } public function registerAction() - { - $db = Zend_Db_Table::getDefaultAdapter(); - + { if (!isset($_POST["register"])){ $registerForm = new Application_Form_AuthRegister(); } else { $registerForm = new Application_Form_AuthRegister($_POST); - + if ($registerForm->isValid($_POST)) { + $person = new Application_Model_Person($_POST); - if ($person != null) { - echo "Erfolgreich registriert"; - var_dump($person); - //$this->_redirect('/auth/login'); - return; - } else { - echo "Die angegebene Email-Adresse existiert bereits"; - } - } + $personmapper = new Application_Model_PersonMapper(); + + $date = new DateTime(); + $person->setRegisterdate($date->getTimestamp()); + $person->setPasswordSalt(MD5($date->getTimestamp())); + $person->setPassword(MD5($person->getPassword() . $person->getPasswordSalt())); + + try { + $personmapper->save($person); + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + echo "Email Adresse bereits vorhanden."; + return; + } + echo "Erfolgreich registriert. <br/>"; + echo "Weiter zum Login: <a href=\""."/auth/login"."\">Login</a>"; + return; + } } $this->view->registerForm = $registerForm; @@ -81,9 +93,25 @@ class AuthController extends Zend_Controller_Action // action body } - public function deleteAccountAction() + public function deleteAction() { - // action body + if (!isset($_POST["delete"])){ + $deleteForm = new Application_Form_AuthDelete(); + } else { + $deleteForm = new Application_Form_AuthDelete($_POST); + + if ($deleteForm->isValid($_POST)) { + + $person = new Application_Model_Person($_POST); + $personmapper = new Application_Model_PersonMapper(); + + + $personmapper->delete($person); + } + } + + $this->view->deleteForm = $deleteForm; + } diff --git a/application/controllers/FilterController.php b/application/controllers/FilterController.php index da8e404..d066c53 100644 --- a/application/controllers/FilterController.php +++ b/application/controllers/FilterController.php @@ -8,31 +8,70 @@ class FilterController extends Zend_Controller_Action public function init() { try{ - $this->_filtermapper = new Application_Model_FilterMapper(); - }catch (Zend_Exception $e) { - echo "Error message 1: " . $e->getMessage() . "\n"; - } - /* Initialize action controller here */ + $this->_filtermapper = new Application_Model_FilterMapper(); + }catch (Zend_Exception $e) { + echo "Error message 1: " . $e->getMessage() . "\n"; + } } public function indexAction() { try{ - $this->_filtermapper = new Application_Model_FilterMapper(); - $this->view->filters = $this->_filtermapper->fetchAll(); - - }catch (Zend_Exception $e) { + $this->_filtermapper = new Application_Model_FilterMapper(); + $this->view->filters = $this->_filtermapper->fetchAll(); + }catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + } + + public function addfilterAction() + { + $db = Zend_Db_Table::getDefaultAdapter(); + if (!isset($_POST["add"])){ + $addfilterform = new Application_Form_FilterAdd(); + $this->view->addfilterform = $addfilterform; + }else { + $addfilterform = new Application_Form_FilterAdd($_POST); + if ($addfilterform->isValid($_POST)) { + try{ + $newfilter = new Application_Model_Filter(); + $newfilter->setTitle($_POST['title']); + $newfilter->setCreated(time()); + $newfilter->setDescription($_POST['description']); + $newfilter->setPriority($_POST['priority']); + + // TODO: Ändere mit ACL + $newfilter->setGroupID('1'); + $newfilter->setMembershipID('1'); + $newfilter->setBootmenuID('1'); + + + + $newfilter2 = new Application_Model_FilterMapper(); + $newfilter2->save($newfilter); + + $this->_redirect('/filter'); + return; + }catch (Zend_Exception $e) { echo "Error message 2: " . $e->getMessage() . "\n"; } + } + } } - public function addfilterAction() - { - $db = Zend_Db_Table::getDefaultAdapter(); - - $addfilterform = new Application_Form_FilterAdd(); - - $this->view->addfilterform = $addfilterform; + public function removefilterAction() + { + $filterID = $_GET['filterID']; + // TODO: ACL implementieren ob er den filter löschen darf + if(is_numeric($filterID)){ + // TODO: lösche den aktuellen eintrag + } + // action body + } + + public function editfilterAction() + { + // action body } @@ -40,3 +79,7 @@ class FilterController extends Zend_Controller_Action + + + + |
