From d0d5a894f4e8219c33599697a1dacad56d1e363f Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 2 Mar 2011 17:17:12 +0100 Subject: Neue Filter hinzufügen --- .zfproject.xml | 14 ++++- application/controllers/FilterController.php | 65 +++++++++++++++++----- application/forms/FilterAdd.php | 19 ++++++- application/views/scripts/filter/editfilter.phtml | 1 + .../views/scripts/filter/removefilter.phtml | 1 + simonFilterSqlTests.sql | 6 ++ 6 files changed, 88 insertions(+), 18 deletions(-) create mode 100644 application/views/scripts/filter/editfilter.phtml create mode 100644 application/views/scripts/filter/removefilter.phtml create mode 100644 simonFilterSqlTests.sql diff --git a/.zfproject.xml b/.zfproject.xml index 11ef2f3..4609430 100644 --- a/.zfproject.xml +++ b/.zfproject.xml @@ -25,13 +25,16 @@ + + + - + @@ -137,6 +140,15 @@ + + + + + + + + + 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 @@ +

View script for controller Filter and script/action name editfilter
\ 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 @@ +

View script for controller Filter and script/action name removefilter
\ No newline at end of file diff --git a/simonFilterSqlTests.sql b/simonFilterSqlTests.sql new file mode 100644 index 0000000..95d15ab --- /dev/null +++ b/simonFilterSqlTests.sql @@ -0,0 +1,6 @@ +INSERT INTO `pbs`.`pbs_group` (`groupID` ,`title` ,`description`)VALUES (NULL , 'testgruppe1', NULL); +INSERT INTO `pbs`.`pbs_person` (`personID`, `title`, `name`, `firstname`, `street`, `housenumber`, `city`, `postalcode`, `logindate`, `registerdate`, `email`, `login`, `password`, `password_salt`) VALUES (NULL, 'Mr.Test', 'te', 'st', NULL, NULL, NULL, NULL, NULL, '', '', 'test', '', ''); +INSERT INTO `pbs`.`pbs_role` (`roleID`, `groupID`, `title`, `description`) VALUES (NULL, '1', 'Testrolle', NULL); +INSERT INTO `pbs`.`pbs_membership` (`membershipID`, `groupID`, `roleID`, `personID`) VALUES (NULL, '1', '1', '1'); +INSERT INTO `pbs`.`pbs_bootmenu` (`bootmenuID`, `membershipID`, `title`, `time`) VALUES (NULL, '1', 'TestBootMenu', ''); +INSERT INTO `pbs`.`pbs_filter` (`filterID`, `membershipID`, `groupID`, `bootmenuID`, `title`, `description`, `created`, `priority`) VALUES (NULL, '1', '1', '1', 'TestFilter', NULL, '', '1'); -- cgit v1.2.3-55-g7522