summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorSimon2011-03-02 17:17:12 +0100
committerSimon2011-03-02 17:17:12 +0100
commitd0d5a894f4e8219c33599697a1dacad56d1e363f (patch)
tree2675d7ef5936eaf19c88af966486f5f57303b94b /application
parentfixing git (diff)
downloadpbs2-d0d5a894f4e8219c33599697a1dacad56d1e363f.tar.gz
pbs2-d0d5a894f4e8219c33599697a1dacad56d1e363f.tar.xz
pbs2-d0d5a894f4e8219c33599697a1dacad56d1e363f.zip
Neue Filter hinzufügen
Diffstat (limited to 'application')
-rw-r--r--application/controllers/FilterController.php65
-rw-r--r--application/forms/FilterAdd.php19
-rw-r--r--application/views/scripts/filter/editfilter.phtml1
-rw-r--r--application/views/scripts/filter/removefilter.phtml1
4 files changed, 69 insertions, 17 deletions
diff --git a/application/controllers/FilterController.php b/application/controllers/FilterController.php
index da8e404..b0be93d 100644
--- a/application/controllers/FilterController.php
+++ b/application/controllers/FilterController.php
@@ -8,11 +8,9 @@ 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()
@@ -20,19 +18,54 @@ class FilterController extends Zend_Controller_Action
try{
$this->_filtermapper = new Application_Model_FilterMapper();
$this->view->filters = $this->_filtermapper->fetchAll();
-
+
}catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
- }
+ echo "Error message 2: " . $e->getMessage() . "\n";
}
public function addfilterAction()
- {
- $db = Zend_Db_Table::getDefaultAdapter();
-
- $addfilterform = new Application_Form_FilterAdd();
-
- $this->view->addfilterform = $addfilterform;
+ {
+ $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 removefilterAction()
+ {
+ // action body
+ }
+
+ public function editfilterAction()
+ {
+ // action body
}
@@ -40,3 +73,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/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/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