summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/controllers/ClientController.php33
-rw-r--r--application/controllers/FilterController.php4
-rw-r--r--application/forms/FilterAdd.php2
-rw-r--r--application/views/scripts/client/index.phtml35
-rw-r--r--application/views/scripts/client/removeclient.phtml1
5 files changed, 70 insertions, 5 deletions
diff --git a/application/controllers/ClientController.php b/application/controllers/ClientController.php
index 6c72fc3..336bf9e 100644
--- a/application/controllers/ClientController.php
+++ b/application/controllers/ClientController.php
@@ -10,12 +10,39 @@ class ClientController extends Zend_Controller_Action
public function indexAction()
{
- // action body
+ $clientMapper = new Application_Model_ClientMapper();
+ $this->view->clients = $clientMapper->fetchAll();
}
public function addclientAction()
{
- // action body
+ $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');
+ }
+ }
+
+ 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');
}
@@ -23,3 +50,5 @@ class ClientController extends Zend_Controller_Action
+
+
diff --git a/application/controllers/FilterController.php b/application/controllers/FilterController.php
index ab24ce2..1305689 100644
--- a/application/controllers/FilterController.php
+++ b/application/controllers/FilterController.php
@@ -25,9 +25,9 @@ class FilterController extends Zend_Controller_Action
$this->view->filterentries = $filterentries->fetchAll();
- }catch (Zend_Exception $e) {
+ }catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
- }
+ }
}
public function addfilterAction()
diff --git a/application/forms/FilterAdd.php b/application/forms/FilterAdd.php
index 43efb71..931bfee 100644
--- a/application/forms/FilterAdd.php
+++ b/application/forms/FilterAdd.php
@@ -21,6 +21,8 @@ class Application_Form_FilterAdd extends Zend_Form
'required' => false,
'label' => 'Description:',
));
+ // TODO: Add target of Filter
+
$this->addElement('text', 'priority', array(
'filters' => array('StringTrim'),
'validators' => array(
diff --git a/application/views/scripts/client/index.phtml b/application/views/scripts/client/index.phtml
index 4f0e6ec..4095a5f 100644
--- a/application/views/scripts/client/index.phtml
+++ b/application/views/scripts/client/index.phtml
@@ -1 +1,34 @@
-<br /><br /><center>View script for controller <b>Client</b> and script/action name <b>index</b></center> \ No newline at end of file
+<h1>Clients</h1>
+
+<?php if ($this->clients): ?>
+
+ <!-- A table of filters. -->
+ <table border=1>
+ <tr>
+ <th>clientID</th>
+ <th>MAC</th>
+ <th>Hardwarehash</th>
+ </tr>
+ <?php foreach ($this->clients as $client): ?>
+ <tr class='client'>
+ <td><?php echo $this->escape($client->getID()) ?></td>
+ <td><?php echo $this->escape($client->getMacadress()) ?></td>
+ <td><?php echo $this->escape($client->getHardwarehash()) ?></td>
+ <td><a href="<?php echo $this->url(
+ array(
+ 'controller' => 'client',
+ 'action' => 'removeclient',
+ 'clientID' => $client->getID()
+ ),
+ 'default',
+ true) ?>">remove client</a></td>
+ </tr>
+ <?php endforeach ?>
+ </table>
+
+<?php else: ?>
+
+
+ <p>There are no clients to display.</p>
+
+<?php endif;?>
diff --git a/application/views/scripts/client/removeclient.phtml b/application/views/scripts/client/removeclient.phtml
new file mode 100644
index 0000000..7b5f64f
--- /dev/null
+++ b/application/views/scripts/client/removeclient.phtml
@@ -0,0 +1 @@
+<br /><br /><center>View script for controller <b>Client</b> and script/action name <b>deleteclient</b></center> \ No newline at end of file