From b5cbdd6b400aa1ec77c9846e9cc8d4257f437e3c Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 14 Mar 2011 16:09:03 +0100 Subject: Application in 3 Modules gesplittet, Dev = unsere entwicklungsumgebung, user = die weboberfläche fr anwender mit acl etc, fbgui = für die fbgui truppe - links in dev müssen noch angepasst werden --- .../modules/dev/controllers/ClientController.php | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 application/modules/dev/controllers/ClientController.php (limited to 'application/modules/dev/controllers/ClientController.php') diff --git a/application/modules/dev/controllers/ClientController.php b/application/modules/dev/controllers/ClientController.php new file mode 100644 index 0000000..affa780 --- /dev/null +++ b/application/modules/dev/controllers/ClientController.php @@ -0,0 +1,90 @@ +view->clients = $clientMapper->fetchAll(); + } + + public function addclientAction() + { + $mac = $this->_request->getParam('mac'); + $hh = $this->_request->getParam('hh'); + + if (!isset($_POST["add"])){ + $addclient = new Application_Form_Client(array('buttontext' => 'Create Client')); + $this->view->addclient = $addclient; + } + else{ + $addfilterform = new Application_Form_Client(array('buttontext' => 'Create Client'),$_POST); + if ($addfilterform->isValid($_POST) || ($mac != '' && $hh != '') ) { + $client = new Application_Model_Client(); + $mac = ($mac!='')?$mac:$_POST['macadress']; + $hh = ($hh!='')?$hh:$_POST['hardwarehash']; + $client->setMacadress($mac); + $client->setHardwarehash($hh); + $clientmapper = new Application_Model_ClientMapper(); + $clientmapper->save($client); + print_a('inserted'); + $this->_redirect('/client'); + } + $this->view->addclient = $addclient; + } + } + + public function removeclientAction() + { + $clientID = $this->_request->getParam('clientID'); + // TODO: ACL implementieren ob er den filter löschen darf + if(is_numeric($clientID)){ + $removeClient = new Application_Model_Client(); + $removeClient->setID($clientID); + $clientMapper = new Application_Model_ClientMapper(); + $clientMapper->delete($removeClient); + } + $this->_redirect('/client'); + } + + public function editclientAction() + { + if (!isset($_POST["add"])){ + $clientID = $this->_request->getParam('clientID'); + $data = new Application_Model_Client(); + $mapper = new Application_Model_ClientMapper(); + $mapper->find($clientID,$data); + + $editclient = new Application_Form_Client(array('buttontext' => 'Edit Client')); + $editclient->populate($data->toArray()); + $this->view->editclient = $editclient; + } + else{ + $editclient = new Application_Form_Client(array('buttontext' => 'Edit Client'),$_POST); + if ($editclient->isValid($_POST) || ($mac != '' && $hh != '') ) { + $client = new Application_Model_Client($_POST); + $client->setID($this->_request->getParam('clientID')); + $clientmapper = new Application_Model_ClientMapper(); + $clientmapper->save($client); + print_a('updated'); + $this->_redirect('/client'); + } + $this->view->editclient = $editclient; + } + } + + +} + + + + + + + -- cgit v1.2.3-55-g7522