From 5688b750744f8568414dc745961747e5629bd194 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 7 Mar 2011 13:57:04 +0100 Subject: Pool actions zum bearbeiten von Pools hinzugefügt --- application/controllers/PoolController.php | 84 ++++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 3 deletions(-) (limited to 'application/controllers/PoolController.php') diff --git a/application/controllers/PoolController.php b/application/controllers/PoolController.php index f9e54be..27e81a3 100644 --- a/application/controllers/PoolController.php +++ b/application/controllers/PoolController.php @@ -11,24 +11,98 @@ class PoolController extends Zend_Controller_Action public function indexAction() { $poolMapper = new Application_Model_PoolMapper(); - $this->view->pools = $poolMapper->fetchAll(); + $this->view->pools = $poolMapper->fetchAll(); } public function createpoolAction() { - // action body + if (!isset($_POST["add"])){ + $addfilterform = new Application_Form_Pool(); + $this->view->addpool = $addfilterform; + }else { + $addpoolform = new Application_Form_Pool($_POST); + if ($addpoolform->isValid($_POST)) { + try{ + $pool = new Application_Model_Pool($_POST); + $poolmapper = new Application_Model_PoolMapper(); + $poolmapper->save($pool); + $this->_redirect('/pool'); + return; + }catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + } + } } public function deletepoolAction() { - // action body + $poolID = $this->_request->getParam('poolID'); + // TODO: ACL implementieren ob er den pool löschen darf + if(is_numeric($poolID)){ + $deletepool = new Application_Model_Pool(); + $deletepool->setID($poolID); + $poolmapper = new Application_Model_PoolMapper(); + $poolmapper->delete($deletepool); + } + $this->_redirect('/pool'); } public function editpoolAction() + { + if (!isset($_POST["add"])){ + $poolID = $this->_request->getParam('poolID'); + + $pool = new Application_Model_Pool(); + $poolmapper = new Application_Model_PoolMapper(); + $poolmapper->find($poolID,$pool); + $poolArray = $pool->toArray(); + + $editpool = new Application_Form_Pool(); + $editpool->populate($poolArray); + $this->view->editpoolform = $editpool; + + }else { + $addpoolform = new Application_Form_Pool($_POST); + if ($addpoolform->isValid($_POST)) { + try{ + $pool = new Application_Model_Pool($_POST); + $pool->setID($this->_request->getParam('poolID')); + $poolmapper = new Application_Model_PoolMapper(); + $poolmapper->save($pool); + $this->_redirect('/pool'); + }catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + } + } + } + + public function linkclientAction() { // action body } + public function unlinkclientAction() + { + $poolentriesID = $this->_request->getParam('poolentriesID'); + + // TODO: ACL implementieren ob er den filter löschen darf + if(is_numeric($poolentriesID)){ + $deletepoolentries = new Application_Model_PoolEntries(); + $deletepoolentries->setID($poolentriesID); + echo "
";
+				print_r($deletepoolentries);
+				echo "
"; + + $deletepoolentriesmapper = new Application_Model_PoolEntriesMapper(); + $deletepoolentriesmapper->delete($deletepoolentries); + echo "ok"; + } +# echo "ready"; + $this->_redirect('/pool'); + } + } @@ -38,3 +112,7 @@ class PoolController extends Zend_Controller_Action + + + + -- cgit v1.2.3-55-g7522