summaryrefslogtreecommitdiffstats
path: root/application/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'application/controllers')
-rw-r--r--application/controllers/AuthController.php70
-rw-r--r--application/controllers/FilterController.php75
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
+
+
+
+