From aa1aea290b8034e3187a4f223cacb53ea7837a31 Mon Sep 17 00:00:00 2001 From: michael pereira Date: Sat, 5 Mar 2011 18:59:46 +0100 Subject: BootOS create, edit und delete done --- application/controllers/BootosController.php | 58 ++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 4 deletions(-) (limited to 'application/controllers/BootosController.php') diff --git a/application/controllers/BootosController.php b/application/controllers/BootosController.php index 7ce4ae3..5f096a6 100644 --- a/application/controllers/BootosController.php +++ b/application/controllers/BootosController.php @@ -39,8 +39,7 @@ class BootosController extends Zend_Controller_Action echo "Message: " . $e->getMessage() . "
"; } - echo "BootOS erfolgreich angelegt.
"; - return; + $this->_redirect('/bootos'); } } @@ -49,12 +48,63 @@ class BootosController extends Zend_Controller_Action public function editbootosAction() { - // action body + $bootosID = $this->_request->getParam('bootosID'); + + if (!isset($_POST["editbootos"])){ + $bootosID = $this->_request->getParam('bootosID'); + if (!isset($bootosID)){ + $this->_redirect('/bootos'); + } else { + $bootos = new Application_Model_BootOs(); + $bootosmapper = new Application_Model_BootOsMapper(); + $bootosmapper->find($bootosID, $bootos); + + $editbootosForm = new Application_Form_BootosEdit(); + $editbootosForm->populate($bootos->toArray()); + } + }else{ + $editbootosForm = new Application_Form_BootosEdit($_POST); + + if ($editbootosForm->isValid($_POST)) { + + $bootos = new Application_Model_BootOs($_POST); + if($bootos->getConfigID() == '') + $bootos->setConfigID(NULL); + $bootosmapper = new Application_Model_BootOsMapper(); + $date = new DateTime(); + $bootos->setCreated($date->getTimestamp()); + $bootos->setID($bootosID); + + try { + $bootosmapper->save($bootos); + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "
"; + echo "Message: " . $e->getMessage() . "
"; + } + + $this->_redirect('/bootos'); + } + + } + + $this->view->editbootosForm = $editbootosForm; + } public function deletebootosAction() { - // action body + $bootosID = $this->_request->getParam('bootosID'); + if (!isset($bootosID)){ + $this->_redirect('/bootos'); + } else { + $bootos = new Application_Model_BootOs(); + $bootos->setID($bootosID); + $bootosmapper = new Application_Model_BootOsMapper(); + $bootosmapper->delete($bootos); + } + $this->_redirect('/bootos'); + } -- cgit v1.2.3-55-g7522