summaryrefslogtreecommitdiffstats
path: root/application/controllers
diff options
context:
space:
mode:
authorSimon2011-03-08 14:03:43 +0100
committerSimon2011-03-08 14:03:43 +0100
commit83fb7e34d99c0006c1c43d58c81ba4e4445f5688 (patch)
tree5bd5b6737312573fc4688899c8c26fb0c394581a /application/controllers
parentpbs-data um beispeildaten ergänzt (diff)
downloadpbs2-83fb7e34d99c0006c1c43d58c81ba4e4445f5688.tar.gz
pbs2-83fb7e34d99c0006c1c43d58c81ba4e4445f5688.tar.xz
pbs2-83fb7e34d99c0006c1c43d58c81ba4e4445f5688.zip
clients editierbar
Diffstat (limited to 'application/controllers')
-rw-r--r--application/controllers/ClientController.php89
-rw-r--r--application/controllers/FilterController.php17
2 files changed, 82 insertions, 24 deletions
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
*/