summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.zfproject.xml5
-rw-r--r--application/controllers/FilterController.php143
-rw-r--r--application/forms/FilterEntriesAdd.php53
-rw-r--r--application/models/FilterEntriesMapper.php9
-rw-r--r--application/views/scripts/filter/addfilterentry.phtml3
-rw-r--r--application/views/scripts/filter/index.phtml21
6 files changed, 174 insertions, 60 deletions
diff --git a/.zfproject.xml b/.zfproject.xml
index b956d27..4c88021 100644
--- a/.zfproject.xml
+++ b/.zfproject.xml
@@ -28,6 +28,7 @@
<actionMethod actionName="addfilter"/>
<actionMethod actionName="removefilter"/>
<actionMethod actionName="editfilter"/>
+ <actionMethod actionName="addfilterentry"/>
</controllerFile>
</controllersDirectory>
<formsDirectory>
@@ -38,6 +39,7 @@
<formFile formName="AuthDelete"/>
<formFile formName="FilterAdd"/>
<formFile formName="FilterEdit"/>
+ <formFile formName="FilterEntriesAdd"/>
</formsDirectory>
<layoutsDirectory enabled="false"/>
<modelsDirectory>
@@ -152,6 +154,9 @@
<viewControllerScriptsDirectory forControllerName="Filter">
<viewScriptFile forActionName="editfilter"/>
</viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Filter">
+ <viewScriptFile forActionName="addfilterentry"/>
+ </viewControllerScriptsDirectory>
</viewScriptsDirectory>
<viewHelpersDirectory/>
<viewFiltersDirectory enabled="false"/>
diff --git a/application/controllers/FilterController.php b/application/controllers/FilterController.php
index 09f4081..6acaae8 100644
--- a/application/controllers/FilterController.php
+++ b/application/controllers/FilterController.php
@@ -8,89 +8,96 @@ 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";
+ $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();
-
- $filterentries = new Application_Model_FilterEntriesMapper();
-
- $this->view->filterentries = $filterentries->fetchAll();
-
- }catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
- }
+ $this->_filtermapper = new Application_Model_FilterMapper();
+ $this->view->filters = $this->_filtermapper->fetchAll();
+
+ $filterentries = new Application_Model_FilterEntriesMapper();
+
+ $this->view->filterentries = $filterentries->fetchAll();
+
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
+ }
}
public function addfilterAction()
{
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";
- }
- }
+ $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 removefilterAction()
- {
- echo 'test';
- print_r($_GET);
- $filterID = $this->_request->getParam('filterID');
- // TODO: ACL implementieren ob er den filter löschen darf
- if(is_numeric($filterID)){
- // TODO: lösche den aktuellen eintrag
- $deletefilter = new Application_Model_Filter();
- $deletefilter->setID($filterID);
- $filtermapper = new Application_Model_FilterMapper();
- $filtermapper->delete($deletefilter);
- }
- $this->_redirect('/filter');
+ {
+ echo 'test';
+ print_r($_GET);
+ $filterID = $this->_request->getParam('filterID');
+ // TODO: ACL implementieren ob er den filter löschen darf
+ if(is_numeric($filterID)){
+ // TODO: lösche den aktuellen eintrag
+ $deletefilter = new Application_Model_Filter();
+ $deletefilter->setID($filterID);
+ $filtermapper = new Application_Model_FilterMapper();
+ $filtermapper->delete($deletefilter);
+ }
+ $this->_redirect('/filter');
}
public function editfilterAction()
{
- // TODO: ACL implementieren ob er editieren darf
+ // TODO: ACL implementieren ob er editieren darf
+ // TODO: korrigieren, damit man einen filter (priorität und namen ändern kann)
+ }
+
+ public function addfilterentryAction()
+ {
+ // TODO: ACL implementieren ob er editieren darf
if (!isset($_POST["add"])){
echo "case1";
try{
- $editfilterform = new Application_Form_FilterEdit(array('filterID' => $this->_request->getParam('filterID')));
- $this->view->editfilterform=$editfilterform;
+ $editfilterform = new Application_Form_FilterEntriesAdd(array('filterID' => $this->_request->getParam('filterID')));
+ $this->view->editfilterform = $editfilterform;
+ echo "case 1.1";
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
} else{
- $editfilterform = new Application_Form_FilterEdit($_POST);
+ $editfilterform = new Application_Form_FilterEntriesAdd($_POST);
echo "case2";
if ($editfilterform->isValid($_POST)) {
@@ -108,6 +115,28 @@ class FilterController extends Zend_Controller_Action
$this->_redirect('/filter');
}
}
+ public function editfilterentryAction()
+ {
+
+ }
+ public function removefilterentryAction()
+ {
+ echo 'test';
+ $filterID = $this->_request->getParam('filterID');
+ $filtertypeID = $this->_request->getParam('filtertypeID');
+ var_dump(array($filterID,$filtertypeID));
+ // TODO: ACL implementieren ob er den filter löschen darf
+ if(is_numeric($filterID)){
+ // TODO: lösche den aktuellen eintrag
+ $deletefilterentry = new Application_Model_FilterEntries();
+ $deletefilterentry->setFilterID($filterID);
+ $deletefilterentry->setFiltertypeID($filtertypeID);
+
+ $filterentriesmapper = new Application_Model_FilterEntriesMapper();
+ $filterentriesmapper->delete($deletefilterentry);
+ }
+ #$this->_redirect('/filter');
+ }
}
@@ -118,3 +147,5 @@ class FilterController extends Zend_Controller_Action
+
+
diff --git a/application/forms/FilterEntriesAdd.php b/application/forms/FilterEntriesAdd.php
new file mode 100644
index 0000000..8ec5bd9
--- /dev/null
+++ b/application/forms/FilterEntriesAdd.php
@@ -0,0 +1,53 @@
+<?php
+
+class Application_Form_FilterEntriesAdd extends Zend_Form
+{
+
+ private $filterID = null;
+
+ public function init()
+ {
+ $this->setName("Add Filterentry");
+ $this->setMethod('post');
+
+
+ try{
+ $filtertypemapper = new Application_Model_FilterTypeMapper();
+ $filtertype = $filtertypemapper->fetchAll();
+ }catch (Zend_Exception $e) {
+ echo "Error message 1: " . $e->getMessage() . "\n";
+ }
+
+ $filtertypes = $this->createElement('select','filtertype');
+ $filtertypes ->setLabel('Type:');
+ foreach($filtertype as $f){
+ $filtertypes->addMultiOption($f->getID(),$f->getFiltertypename());
+ }
+ $this->addElement($filtertypes);
+
+
+ $this->addElement('text', 'filtervalue1', array(
+ 'label' => 'Value1:'
+ ));
+
+ $this->addElement('text', 'filtervalue2', array(
+ 'label' => 'Value2:'
+ ));
+
+ $this->addElement('hidden', 'filterID', array(
+ 'value' => $this->filterID
+ ));
+
+ $this->addElement('submit', 'add', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => 'Add Filtertype',
+ ));
+ }
+ public function setFilterID($id)
+ {
+ $this->filterID = $id;
+ }
+
+}
+
diff --git a/application/models/FilterEntriesMapper.php b/application/models/FilterEntriesMapper.php
index 09bc627..41f1023 100644
--- a/application/models/FilterEntriesMapper.php
+++ b/application/models/FilterEntriesMapper.php
@@ -50,10 +50,15 @@ class Application_Model_FilterEntriesMapper
public function delete(Application_Model_FilterEntries $filterentries)
{
- if (null === ($id = $filterentries->getID()) ) {
+ $id1 = $filterentries->getFilterID();
+ $id2 = $filterentries->getFiltertypeID();
+ var_dump(array($id1,$id2));
+ //TODO: Löschen klappt nicht
+ if ((null != $id1) && (null != $id2) &&
+ $this->getDbTable()->find($filterentries->getFilterID(),$filterentries->getFiltertypeID())) {
return;
} else {
- $this->getDbTable()->delete(array('filterentriesID = ?' => $id));
+ $this->getDbTable()->delete(array('filterID = ?' => $id1, 'filtertypeID = ?' => $id2));
}
}
diff --git a/application/views/scripts/filter/addfilterentry.phtml b/application/views/scripts/filter/addfilterentry.phtml
new file mode 100644
index 0000000..8bf501a
--- /dev/null
+++ b/application/views/scripts/filter/addfilterentry.phtml
@@ -0,0 +1,3 @@
+<?php
+$this->editfilterform->setAction($this->url());
+echo $this->editfilterform;
diff --git a/application/views/scripts/filter/index.phtml b/application/views/scripts/filter/index.phtml
index 4e5f8af..b3c3013 100644
--- a/application/views/scripts/filter/index.phtml
+++ b/application/views/scripts/filter/index.phtml
@@ -42,9 +42,17 @@ tr.filter{background-color:#DDD;}
),
'default',
true) ?>">delete filter</a></td>
+ <td><a href="<?php echo $this->url(
+ array(
+ 'controller' => 'filter',
+ 'action' => 'addfilterentry',
+ 'filterID' => $filter->getID()
+ ),
+ 'default',
+ true) ?>">add filterentry</a></td>
</tr>
<tr><td></td>
- <td colspan=4>
+ <td colspan=5>
<table style='width:100%;'>
<?php foreach ($this->filterentries as $filterentry): ?>
<?php
@@ -54,7 +62,16 @@ tr.filter{background-color:#DDD;}
<tr>
<td><?php echo $filterentry->getFiltertypeID();?></td>
<td><?php echo $filterentry->getFiltervalue();?></td>
- <td><?php echo $filterentry->getFiltervalue();?></td>
+ <td><?php echo $filterentry->getFiltervalue();?></td>
+ <td><a href="<?php echo $this->url(
+ array(
+ 'controller' => 'filter',
+ 'action' => 'removefilterentry',
+ 'filterID' => $filter->getID(),
+ 'filtertypeID' => $filterentry->getFiltertypeID()
+ ),
+ 'default',
+ true) ?>">remove filterentry</a>
</tr>
<?php endif; ?>
<?php endforeach ?>