diff options
author | Simon | 2011-03-16 17:40:13 +0100 |
---|---|---|
committer | Simon | 2011-03-16 17:40:13 +0100 |
commit | 43e85963bc133666017d2946c03884d2f77a016a (patch) | |
tree | 311a8d33a35a53c8faa63906d76edb6f753e968c /application/modules/user/controllers/ClientController.php | |
parent | Merge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2 (diff) | |
download | pbs2-43e85963bc133666017d2946c03884d2f77a016a.tar.gz pbs2-43e85963bc133666017d2946c03884d2f77a016a.tar.xz pbs2-43e85963bc133666017d2946c03884d2f77a016a.zip |
Client Controller fertig
Diffstat (limited to 'application/modules/user/controllers/ClientController.php')
-rw-r--r-- | application/modules/user/controllers/ClientController.php | 60 |
1 files changed, 52 insertions, 8 deletions
diff --git a/application/modules/user/controllers/ClientController.php b/application/modules/user/controllers/ClientController.php index bae6494..bf64102 100644 --- a/application/modules/user/controllers/ClientController.php +++ b/application/modules/user/controllers/ClientController.php @@ -13,7 +13,7 @@ class User_ClientController extends Zend_Controller_Action public function indexAction() { - // TODO: ACL: is he athorized to see this ? + // TODO: ACL: is he authorized to see this ? // Get the Clients which booted with a bootiso of this group $result = $this->_request->getParam('deleteresult'); @@ -21,6 +21,17 @@ class User_ClientController extends Zend_Controller_Action $pbsNotifier = new Pbs_Notifier(); $this->view->notification = $pbsNotifier->notify('delete',$result); } + $result = $this->_request->getParam('modifyresult'); + if($result != ""){ + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('modify',$result); + } + $result = $this->_request->getParam('addresult'); + if($result != ""){ + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('create',$result); + } + $clientMapper = new Application_Model_ClientMapper(); $clientsInGroup = $clientMapper->findBy('groupID',$this->membership->getGroupID()); # print_a($clientsInGroup); @@ -31,7 +42,30 @@ class User_ClientController extends Zend_Controller_Action public function addclientAction() { - // action body + $mac = $this->_request->getParam('mac'); + $hh = $this->_request->getParam('hh'); + + // TODO: ACL: is he authorized to create new clients? + if (!isset($_POST["add"])){ + $addclient = new user_Form_Client(array('buttontext' => 'Create Client')); + $this->view->addclient = $addclient; + } + else{ + $addclient = new user_Form_Client(array('buttontext' => 'Create Client'),$_POST); + print_a($_POST); + if ($addclient->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); + $client->setGroupID($this->membership->getGroupID()); + $clientmapper = new Application_Model_ClientMapper(); + $clientmapper->save($client); + $this->_redirect('/user/client/addresult/ok'); + } + $this->view->addclient = $addclient; + } } public function removeclientAction() @@ -56,7 +90,7 @@ class User_ClientController extends Zend_Controller_Action } public function editclientAction(){ - + // TODO: ACL: Is he authorized to edit clients ? if (!isset($_POST["add"])){ $clientID = $this->_request->getParam('clientID'); $client = new Application_Model_Client(); @@ -73,14 +107,24 @@ class User_ClientController extends Zend_Controller_Action } } else{ - $editclient = new user_Form_Client(array('buttontext' => 'Edit Client','groups'=>$groups),$_POST); + $editclient = new user_Form_Client(array('buttontext' => 'Edit Client'),$_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'); + + $dbclient = new Application_Model_Client(); + $clientMapper = new Application_Model_ClientMapper(); + $clientMapper->find($this->_request->getParam('clientID'),$dbclient); + + if($dbclient->getGroupID() == $this->membership->getGroupID()){ + $client->setGroupID($this->membership->getGroupID()); + $clientmapper = new Application_Model_ClientMapper(); + $clientmapper->save($client); + $this->_redirect('/user/client/index/modifyresult/ok'); + } + else{ + $this->_redirect('/user/client/index/modifyresult/error'); + } } $this->view->editclient = $editclient; } |