summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.zfproject.xml1
-rw-r--r--application/Bootstrap.php3
-rw-r--r--application/modules/dev/controllers/ClientController.php2
-rw-r--r--application/modules/user/controllers/ClientController.php55
-rw-r--r--application/modules/user/forms/Client.php46
-rw-r--r--application/modules/user/views/scripts/client/addclient.phtml4
-rw-r--r--application/modules/user/views/scripts/client/editclient.phtml4
-rw-r--r--application/modules/user/views/scripts/client/index.phtml1
-rw-r--r--library/Pbs/Notifier.php54
9 files changed, 147 insertions, 23 deletions
diff --git a/.zfproject.xml b/.zfproject.xml
index 5724941..c0eba40 100644
--- a/.zfproject.xml
+++ b/.zfproject.xml
@@ -264,6 +264,7 @@
</controllersDirectory>
<formsDirectory>
<formFile formName="Login"/>
+ <formFile formName="Client"/>
</formsDirectory>
<layoutsDirectory enabled="false"/>
<modelsDirectory>
diff --git a/application/Bootstrap.php b/application/Bootstrap.php
index db7b4e0..cfa09f5 100644
--- a/application/Bootstrap.php
+++ b/application/Bootstrap.php
@@ -12,7 +12,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
'basePath' => APPLICATION_PATH,
'resourceTypes' => array(
'form' => array(
- 'path' => 'forms/',
+ 'path' => 'forms',
'namespace' => 'Form',
)
)
@@ -42,7 +42,6 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
$layout = $this->getResource('layout');
$view = $layout->getView();
- # print_a($layout);
$view->doctype('XHTML1_STRICT');
$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
$view->headLink()->appendStylesheet('/media/css/style.css');
diff --git a/application/modules/dev/controllers/ClientController.php b/application/modules/dev/controllers/ClientController.php
index 27b8a08..aa66a96 100644
--- a/application/modules/dev/controllers/ClientController.php
+++ b/application/modules/dev/controllers/ClientController.php
@@ -61,7 +61,7 @@ class dev_ClientController extends Zend_Controller_Action
{
$groupMapper = new Application_Model_GroupMapper();
$groups = $groupMapper->fetchAll();
- # print_a($groups);die();
+ # print_a($this);die();
if (!isset($_POST["add"])){
$clientID = $this->_request->getParam('clientID');
diff --git a/application/modules/user/controllers/ClientController.php b/application/modules/user/controllers/ClientController.php
index bd111cf..f5f1810 100644
--- a/application/modules/user/controllers/ClientController.php
+++ b/application/modules/user/controllers/ClientController.php
@@ -16,17 +16,10 @@ class User_ClientController extends Zend_Controller_Action
// TODO: ACL: is he athorized to see this ?
// Get the Clients which booted with a bootiso of this group
- $result = $this->_request->getParam('result');
- switch($result){
- case "forbidden":
- echo "<div class='errorbox'>Not allowed to delete this</div>";
- break;
- case "ok":
- echo "<div class='checkbox'>Delete sucessful</div>";
- break;
- case "error":
- echo "<div class='warningbox'>There was an error deleting</div>";
- break;
+ $result = $this->_request->getParam('deleteresult');
+ if($result != ""){
+ $pbsNotifier = new Pbs_Notifier();
+ $this->view->notification = $pbsNotifier->notify('delete',$result);
}
$clientMapper = new Application_Model_ClientMapper();
$clientsInGroup = $clientMapper->findBy('groupID',$this->membership->getGroupID());
@@ -53,19 +46,45 @@ class User_ClientController extends Zend_Controller_Action
if($client->getGroupID() == $this->membership->getGroupID()){
$clientMapper = new Application_Model_ClientMapper();
$clientMapper->delete($client);
- $this->_redirect('/user/client/index/result/ok');
+ $this->_redirect('/user/client/index/deleteresult/ok');
}
else{
- $this->_redirect('/user/client/index/result/forbidden');
+ $this->_redirect('/user/client/index/deleteresult/forbidden');
}
}
- $this->_redirect('/user/client/index/result/error');
- // action body
+ $this->_redirect('/user/client/index/deleteresult/error');
}
- public function editclientAction()
- {
- // action body
+ public function editclientAction(){
+
+ if (!isset($_POST["add"])){
+ $clientID = $this->_request->getParam('clientID');
+ $client = new Application_Model_Client();
+ $mapper = new Application_Model_ClientMapper();
+ $mapper->find($clientID,$client);
+
+ if($client->getGroupID() == $this->membership->getGroupID()){
+ # print_a($this);die();
+ $editclient = new user_Form_Client(array('buttontext' => 'Edit Client'));
+ $editclient->populate($client->toArray());
+ $this->view->editclient = $editclient;
+ }
+ else{
+ $this->_redirect('/user/client/index/modifyresult/error');
+ }
+ }
+ else{
+ $editclient = new user_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;
+ }
}
diff --git a/application/modules/user/forms/Client.php b/application/modules/user/forms/Client.php
new file mode 100644
index 0000000..a79ede1
--- /dev/null
+++ b/application/modules/user/forms/Client.php
@@ -0,0 +1,46 @@
+<?php
+
+class user_Form_Client extends Zend_Form
+{
+
+ public function init()
+ {
+ $this->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' => $this->buttontext,
+ ));
+
+ $this->addElement('button', 'Cancel', array(
+ 'onclick' => 'self.location="/user/client"'
+ ));
+ }
+ private $buttontext = 'Save';
+ private $groups;
+ function setButtontext($v){
+ $this->buttontext = $v;
+ }
+
+
+}
+
diff --git a/application/modules/user/views/scripts/client/addclient.phtml b/application/modules/user/views/scripts/client/addclient.phtml
index 9d1c04e..13511fb 100644
--- a/application/modules/user/views/scripts/client/addclient.phtml
+++ b/application/modules/user/views/scripts/client/addclient.phtml
@@ -1 +1,3 @@
-<br /><br /><center>View script for controller <b>Client</b> and script/action name <b>addclient</b></center> \ No newline at end of file
+<?php
+echo $this->addclient;
+?>
diff --git a/application/modules/user/views/scripts/client/editclient.phtml b/application/modules/user/views/scripts/client/editclient.phtml
index 5092e5b..2753a0f 100644
--- a/application/modules/user/views/scripts/client/editclient.phtml
+++ b/application/modules/user/views/scripts/client/editclient.phtml
@@ -1 +1,3 @@
-<br /><br /><center>View script for controller <b>Client</b> and script/action name <b>editclient</b></center> \ No newline at end of file
+<?php
+echo $this->editclient;
+?>
diff --git a/application/modules/user/views/scripts/client/index.phtml b/application/modules/user/views/scripts/client/index.phtml
index e79b208..dd791ad 100644
--- a/application/modules/user/views/scripts/client/index.phtml
+++ b/application/modules/user/views/scripts/client/index.phtml
@@ -1,4 +1,5 @@
<h1>Clients</h1>
+<?php if($this->notification != ''){echo $this->notification;} ?>
<?php echo $this->formButton('createbootos', 'Create Client', array(
'onclick' => 'self.location="/user/client/addclient"',
'class' => 'addbutton'))?>
diff --git a/library/Pbs/Notifier.php b/library/Pbs/Notifier.php
new file mode 100644
index 0000000..f2f889b
--- /dev/null
+++ b/library/Pbs/Notifier.php
@@ -0,0 +1,54 @@
+<?php
+
+class Pbs_Notifier{
+
+
+ public function notify($action,$result){
+
+ switch($action){
+ case "delete":
+ switch($result){
+ case "forbidden":
+ $result = "<div class='errorbox'>Not allowed to delete this</div>";
+ break;
+ case "ok":
+ $result = "<div class='checkbox'>Delete sucessful</div>";
+ break;
+ case "error":
+ $result = "<div class='warningbox'>Delete failed</div>";
+ break;
+ }
+ break;
+ case "modify":
+ switch($result){
+ case "forbidden":
+ $result = "<div class='errorbox'>Not allowed to modify this</div>";
+ break;
+ case "ok":
+ $result = "<div class='checkbox'>Modify sucessful</div>";
+ break;
+ case "error":
+ $result = "<div class='warningbox'>Modify failed</div>";
+ break;
+ }
+ break;
+ case "create":
+ switch($result){
+ case "forbidden":
+ $result = "<div class='errorbox'>Not allowed to create this</div>";
+ break;
+ case "ok":
+ $result = "<div class='checkbox'>Creation sucessful</div>";
+ break;
+ case "error":
+ $result = "<div class='warningbox'>Creation failed</div>";
+ break;
+ }
+ break;
+ }
+ return $result;
+
+ }
+}
+
+?>