From 8ffb3fe22d10ebbe174e50cad63d9aa2a0130065 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 8 Mar 2011 12:21:28 +0100 Subject: bootisoID in session eingefügt --- application/controllers/FilterController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'application/controllers/FilterController.php') diff --git a/application/controllers/FilterController.php b/application/controllers/FilterController.php index 73b087c..3f9a49d 100644 --- a/application/controllers/FilterController.php +++ b/application/controllers/FilterController.php @@ -310,19 +310,19 @@ class FilterController extends Zend_Controller_Action If client is a specific client */ ######################################################### - // BootIso + // BootIsoID $filtertypID = 4; /* WHERE bootiso = bootiso */ ######################################################### - // Membership + // MembershipID $filtertypID = 5; /* user is in a defined membership */ ######################################################### - // Group + // GroupID $filtertypID = 6; /* user is in a defined groupID -- cgit v1.2.3-55-g7522 From 83fb7e34d99c0006c1c43d58c81ba4e4445f5688 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 8 Mar 2011 14:03:43 +0100 Subject: clients editierbar --- .zfproject.xml | 5 ++ application/controllers/ClientController.php | 89 +++++++++++++++++------ application/controllers/FilterController.php | 17 +++++ application/forms/Client.php | 37 ++++++++++ application/views/scripts/client/addclient.phtml | 4 +- application/views/scripts/client/editclient.phtml | 3 + application/views/scripts/client/index.phtml | 16 +++- 7 files changed, 145 insertions(+), 26 deletions(-) create mode 100644 application/forms/Client.php create mode 100644 application/views/scripts/client/editclient.phtml (limited to 'application/controllers/FilterController.php') diff --git a/.zfproject.xml b/.zfproject.xml index 417a947..8cdb2e0 100644 --- a/.zfproject.xml +++ b/.zfproject.xml @@ -58,6 +58,7 @@ + @@ -92,6 +93,7 @@ + @@ -281,6 +283,9 @@ + + + diff --git a/application/controllers/ClientController.php b/application/controllers/ClientController.php index 336bf9e..ff663ba 100644 --- a/application/controllers/ClientController.php +++ b/application/controllers/ClientController.php @@ -10,39 +10,78 @@ class ClientController extends Zend_Controller_Action public function indexAction() { - $clientMapper = new Application_Model_ClientMapper(); - $this->view->clients = $clientMapper->fetchAll(); + $clientMapper = new Application_Model_ClientMapper(); + $this->view->clients = $clientMapper->fetchAll(); } public function addclientAction() - { - $mac = $this->_request->getParam('mac'); - $hh = $this->_request->getParam('hh'); - - if($mac != '' && $hh != ''){ - $client = new Application_Model_Client(); - $client->setMacadress($mac); - $client->setHardwarehash($hh); - $clientmapper = new Application_Model_ClientMapper(); - $clientmapper->save($client); - print_a('inserted'); - } - else{ - print_a('no insert'); - } + { + $mac = $this->_request->getParam('mac'); + $hh = $this->_request->getParam('hh'); + + if (!isset($_POST["add"])){ + $addclient = new Application_Form_Client(); + $this->view->addclient = $addclient; + } + else{ + $addfilterform = new Application_Form_Client($_POST); + print_a($_POST,$addfilterform->isValid($_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'); + } + else{ + print_a('no insert'); + } + } } 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); + // 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(); + $editclient->populate($data->toArray()); + $this->view->editclient = $editclient; + } + else{ + $addfilterform = new Application_Form_Client($_POST); + if ($addfilterform->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'); + } + else{ + print_a('no update'); + } } - $this->_redirect('/client'); } @@ -52,3 +91,5 @@ class ClientController extends Zend_Controller_Action + + diff --git a/application/controllers/FilterController.php b/application/controllers/FilterController.php index 3f9a49d..df8db07 100644 --- a/application/controllers/FilterController.php +++ b/application/controllers/FilterController.php @@ -265,6 +265,7 @@ class FilterController extends Zend_Controller_Action ######################################################### // IP Adress $filtertypID = 1; + // get it from session_table with session_id from the session $ipAdress = "111.10.10.10"; $ipAdress = str_replace(".","",$this->fillIP($ipAdress)); $select = $db->select() @@ -285,6 +286,7 @@ class FilterController extends Zend_Controller_Action ######################################################### // Mac range $filtertypID = 2; + // get it from session_table with session_id from the session $macAdress = "00:1e:0b:27:f4:99"; $macAdress = str_replace(":","",$this->fillMac($ipAdress)); $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE @@ -300,30 +302,45 @@ class FilterController extends Zend_Controller_Action ######################################################### // PoolID $filtertypID = 3; + // get PoolID from client_ID from session_id from the session + $poolid = 1; + $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE + filtertypeID = ".$filtertypID." AND + filtervalue = '.$poolid.' "); + $result = $stmt->fetchAll(); + foreach($result as $r){ + $set[$filtertypID][] = $r['filterID']; + } + if($showPartResults) + print_a('poolID',$result,$set[$filtertypID]); /* If client comes from a specific pool */ ######################################################### // ClientID $filtertypID = 8; + // get client_ID from session_id from the session /* If client is a specific client */ ######################################################### // BootIsoID $filtertypID = 4; + // get BootIsoID from client_ID from session_id from the session /* WHERE bootiso = bootiso */ ######################################################### // MembershipID $filtertypID = 5; + // get membership from the session /* user is in a defined membership */ ######################################################### // GroupID $filtertypID = 6; + // get membership from the session /* user is in a defined groupID */ diff --git a/application/forms/Client.php b/application/forms/Client.php new file mode 100644 index 0000000..1378349 --- /dev/null +++ b/application/forms/Client.php @@ -0,0 +1,37 @@ +setName("pool"); + $this->setMethod('post'); + + $this->addElement('text', 'macadress', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'MacAdress:', + )); + $this->addElement('text', 'hardwarehash', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Hardwarehash:', + )); + + $this->addElement('submit', 'add', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Save', + )); + } + + +} + diff --git a/application/views/scripts/client/addclient.phtml b/application/views/scripts/client/addclient.phtml index 9d1c04e..e5b0bcf 100644 --- a/application/views/scripts/client/addclient.phtml +++ b/application/views/scripts/client/addclient.phtml @@ -1 +1,3 @@ -View script for controller Client and script/action name addclient \ No newline at end of file +addclient; diff --git a/application/views/scripts/client/editclient.phtml b/application/views/scripts/client/editclient.phtml new file mode 100644 index 0000000..94d6b34 --- /dev/null +++ b/application/views/scripts/client/editclient.phtml @@ -0,0 +1,3 @@ +editclient; diff --git a/application/views/scripts/client/index.phtml b/application/views/scripts/client/index.phtml index 4095a5f..0eb28b8 100644 --- a/application/views/scripts/client/index.phtml +++ b/application/views/scripts/client/index.phtml @@ -1,7 +1,13 @@ Clients clients): ?> - + add client @@ -14,6 +20,14 @@ escape($client->getID()) ?> escape($client->getMacadress()) ?> escape($client->getHardwarehash()) ?> + edit client