From fca04a6dab252eb9e8c0a92ce3b7e14b32e68d1e Mon Sep 17 00:00:00 2001 From: Sebastian Schmelzer Date: Wed, 11 Jan 2012 14:36:35 +0100 Subject: format source files --- .../modules/dev/controllers/ClientController.php | 178 ++++++++++----------- 1 file changed, 85 insertions(+), 93 deletions(-) (limited to 'application/modules/dev/controllers/ClientController.php') diff --git a/application/modules/dev/controllers/ClientController.php b/application/modules/dev/controllers/ClientController.php index b6c202c..d70db4a 100644 --- a/application/modules/dev/controllers/ClientController.php +++ b/application/modules/dev/controllers/ClientController.php @@ -1,101 +1,93 @@ -view->clients = $clientMapper->fetchAll(); + } + + public function addclientAction() { + $mac = $this->_request->getParam('mac'); + $hh = $this->_request->getParam('hh'); + + $groupMapper = new Application_Model_GroupMapper(); + $groups = $groupMapper->fetchAll(); +#print_a($groups);die(); + + if (!isset($_POST["add"])) { + $addclient = new dev_Form_Client(array('buttontext' => 'Create Client', 'groups' => $groups)); + $this->view->addclient = $addclient; + } else { + $addfilterform = new dev_Form_Client(array('buttontext' => 'Create Client', 'groups' => $groups), $_POST); + if ($addfilterform->isValid($_POST) || ($mac != '' && $hh != '') ) { + $client = new Application_Model_Client($_POST); + $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('/dev/client'); + } + $this->view->addclient = $addclient; } - - public function indexAction() - { - $clientMapper = new Application_Model_ClientMapper(); - $this->view->clients = $clientMapper->fetchAll(); - } - - public function addclientAction() - { - $mac = $this->_request->getParam('mac'); - $hh = $this->_request->getParam('hh'); - - $groupMapper = new Application_Model_GroupMapper(); - $groups = $groupMapper->fetchAll(); - #print_a($groups);die(); - - if (!isset($_POST["add"])){ - $addclient = new dev_Form_Client(array('buttontext' => 'Create Client','groups'=>$groups)); - $this->view->addclient = $addclient; - } - else{ - $addfilterform = new dev_Form_Client(array('buttontext' => 'Create Client','groups'=>$groups),$_POST); - if ($addfilterform->isValid($_POST) || ($mac != '' && $hh != '') ) { - $client = new Application_Model_Client($_POST); - $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('/dev/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); } - - 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('/dev/client'); - } - - public function editclientAction() - { - $groupMapper = new Application_Model_GroupMapper(); - $groups = $groupMapper->fetchAll(); - # print_a($this);die(); - - 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 dev_Form_Client(array('buttontext' => 'Edit Client', 'groups'=>$groups)); - $editclient->populate($data->toArray()); - $this->view->editclient = $editclient; - } - else{ - $editclient = new dev_Form_Client(array('buttontext' => 'Edit Client','groups'=>$groups),$_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('/dev/client'); - } - $this->view->editclient = $editclient; - } + $this->_redirect('/dev/client'); + } + + public function editclientAction() { + $groupMapper = new Application_Model_GroupMapper(); + $groups = $groupMapper->fetchAll(); +# print_a($this);die(); + + 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 dev_Form_Client(array('buttontext' => 'Edit Client', 'groups' => $groups)); + $editclient->populate($data->toArray()); + $this->view->editclient = $editclient; + } else { + $editclient = new dev_Form_Client(array('buttontext' => 'Edit Client', 'groups' => $groups), $_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('/dev/client'); + } + $this->view->editclient = $editclient; } + } } -- cgit v1.2.3-55-g7522