diff options
| author | michael pereira | 2011-03-18 19:27:33 +0100 |
|---|---|---|
| committer | michael pereira | 2011-03-18 19:27:33 +0100 |
| commit | 87b3b1d9c0cecf76d1eb39cf2548072607de59ea (patch) | |
| tree | 5d07af0d68e20a38422a72864b3ca68b1a1b07be /application/modules/user/controllers/ClientController.php | |
| parent | BootOs Update implementiert, BootISO anlegen und some fixes (diff) | |
| parent | User-Oberfläche, FBGui-Oberfläche legt Session&Clients an - für Kiosk-System (diff) | |
| download | pbs2-87b3b1d9c0cecf76d1eb39cf2548072607de59ea.tar.gz pbs2-87b3b1d9c0cecf76d1eb39cf2548072607de59ea.tar.xz pbs2-87b3b1d9c0cecf76d1eb39cf2548072607de59ea.zip | |
newsql geaendert
Diffstat (limited to 'application/modules/user/controllers/ClientController.php')
| -rw-r--r-- | application/modules/user/controllers/ClientController.php | 151 |
1 files changed, 83 insertions, 68 deletions
diff --git a/application/modules/user/controllers/ClientController.php b/application/modules/user/controllers/ClientController.php index bf64102..4bb2b35 100644 --- a/application/modules/user/controllers/ClientController.php +++ b/application/modules/user/controllers/ClientController.php @@ -5,6 +5,10 @@ class User_ClientController extends Zend_Controller_Action private $membership; public function init() { + if($_SESSION['membershipID'] ==''){ + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify('No membershipID set','forbidden'); + } /* Initialize action controller here */ $membershipMapper = new Application_Model_MembershipMapper(); $this->membership = new Application_Model_Membership(); @@ -46,88 +50,99 @@ class User_ClientController extends Zend_Controller_Action $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; - } + #if( he is allowed){ + 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; + } + #}else{ + # $this->_redirect('/user/'); + #} } public function removeclientAction() { $clientID = $this->_request->getParam('clientID'); // TODO: ACL: is he authorized to delete clients? - $clientMapper = new Application_Model_ClientMapper(); - if(is_numeric($clientID)){ - $client = new Application_Model_Client(); - $clientMapper->find($clientID,$client); - // TODO: ACL: Is He authorized to delete - if($client->getGroupID() == $this->membership->getGroupID()){ - $clientMapper = new Application_Model_ClientMapper(); - $clientMapper->delete($client); - $this->_redirect('/user/client/index/deleteresult/ok'); - } - else{ - $this->_redirect('/user/client/index/deleteresult/forbidden'); + #if( he is allowed){ + $clientMapper = new Application_Model_ClientMapper(); + if(is_numeric($clientID)){ + $client = new Application_Model_Client(); + $clientMapper->find($clientID,$client); + if($client->getGroupID() == $this->membership->getGroupID()){ + $clientMapper = new Application_Model_ClientMapper(); + $clientMapper->delete($client); + $this->_redirect('/user/client/index/deleteresult/ok'); + } + else{ + $this->_redirect('/user/client/index/deleteresult/forbidden'); + } } - } - $this->_redirect('/user/client/index/deleteresult/error'); + $this->_redirect('/user/client/index/deleteresult/error'); + #}else{ + # $this->_redirect('/user/'); + #} } 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(); - $mapper = new Application_Model_ClientMapper(); - $mapper->find($clientID,$client); + // TODO: ACL: Is he authorized to edit clients ? + #if( he is allowed){ + 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()){ - $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'),$_POST); - if ($editclient->isValid($_POST) || ($mac != '' && $hh != '') ) { - $client = new Application_Model_Client($_POST); - $client->setID($this->_request->getParam('clientID')); + if($client->getGroupID() == $this->membership->getGroupID()){ + $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'),$_POST); + if ($editclient->isValid($_POST) || ($mac != '' && $hh != '') ) { + $client = new Application_Model_Client($_POST); + $client->setID($this->_request->getParam('clientID')); - $dbclient = new Application_Model_Client(); - $clientMapper = new Application_Model_ClientMapper(); - $clientMapper->find($this->_request->getParam('clientID'),$dbclient); + $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'); + 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; - } + $this->view->editclient = $editclient; + } + #}else{ + # $this->_redirect('/user/'); + #} } |
