summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/configs/application.ini2
-rw-r--r--application/controllers/AuthController.php70
-rw-r--r--application/controllers/FilterController.php75
-rw-r--r--application/forms/FilterAdd.php19
-rw-r--r--application/views/scripts/auth/delete.phtml5
-rw-r--r--application/views/scripts/filter/editfilter.phtml1
-rw-r--r--application/views/scripts/filter/index.phtml10
-rw-r--r--application/views/scripts/filter/removefilter.phtml1
8 files changed, 141 insertions, 42 deletions
diff --git a/application/configs/application.ini b/application/configs/application.ini
index 9bfaec2..6970da3 100644
--- a/application/configs/application.ini
+++ b/application/configs/application.ini
@@ -10,7 +10,7 @@ resources.frontController.params.displayExceptions = 0
resources.db.adapter = PDO_MYSQL
resources.db.params.host = localhost
resources.db.params.username = root
-resources.db.params.password = 123456
+resources.db.params.password = lsfks
resources.db.params.dbname = pbs
resources.db.isDefaultTableAdapter = true
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
+
+
+
+
diff --git a/application/forms/FilterAdd.php b/application/forms/FilterAdd.php
index 969f07b..825d3f2 100644
--- a/application/forms/FilterAdd.php
+++ b/application/forms/FilterAdd.php
@@ -5,7 +5,7 @@ class Application_Form_FilterAdd extends Zend_Form
public function init()
{
- $this->setName("Register");
+ $this->setName("Add Filter");
$this->setMethod('post');
$this->addElement('text', 'title', array(
@@ -16,10 +16,23 @@ class Application_Form_FilterAdd extends Zend_Form
'required' => true,
'label' => 'Title:',
));
- $this->addElement('submit', 'register', array(
+ $this->addElement('textarea', 'description', array(
+ 'filters' => array('StringTrim'),
+ 'required' => true,
+ 'label' => 'Description:',
+ ));
+ $this->addElement('text', 'priority', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Priority:',
+ ));
+ $this->addElement('submit', 'add', array(
'required' => false,
'ignore' => true,
- 'label' => 'Login',
+ 'label' => 'Add Filter',
));
}
diff --git a/application/views/scripts/auth/delete.phtml b/application/views/scripts/auth/delete.phtml
index 3b7085d..8f269a0 100644
--- a/application/views/scripts/auth/delete.phtml
+++ b/application/views/scripts/auth/delete.phtml
@@ -1 +1,4 @@
-<br /><br /><center>View script for controller <b>Auth</b> and script/action name <b>deleteAccount</b></center> \ No newline at end of file
+<?php
+$this->deleteForm->setAction($this->url());
+echo $this->deleteForm;
+?>
diff --git a/application/views/scripts/filter/editfilter.phtml b/application/views/scripts/filter/editfilter.phtml
new file mode 100644
index 0000000..452a096
--- /dev/null
+++ b/application/views/scripts/filter/editfilter.phtml
@@ -0,0 +1 @@
+<br /><br /><center>View script for controller <b>Filter</b> and script/action name <b>editfilter</b></center> \ No newline at end of file
diff --git a/application/views/scripts/filter/index.phtml b/application/views/scripts/filter/index.phtml
index 0f9b51e..33043dc 100644
--- a/application/views/scripts/filter/index.phtml
+++ b/application/views/scripts/filter/index.phtml
@@ -13,10 +13,20 @@
<table border=1>
<tr>
<th>filterid</th>
+ <th>filterID</th>
</tr>
<?php foreach ($this->filters as $filter): ?>
<tr>
+ <td><?php echo $this->escape($filter->getID()) ?></td>
<td><?php echo $this->escape($filter->title) ?></td>
+ <td><a href="<?php echo $this->url(
+ array(
+ 'controller' => 'filter',
+ 'action' => 'editfilter',
+ 'filterID' => $filter->getID()
+ ),
+ 'default',
+ true) ?>">edit filter</a></td>
</tr>
<?php endforeach ?>
diff --git a/application/views/scripts/filter/removefilter.phtml b/application/views/scripts/filter/removefilter.phtml
new file mode 100644
index 0000000..a46f9ec
--- /dev/null
+++ b/application/views/scripts/filter/removefilter.phtml
@@ -0,0 +1 @@
+<br /><br /><center>View script for controller <b>Filter</b> and script/action name <b>removefilter</b></center> \ No newline at end of file