summaryrefslogtreecommitdiffstats
path: root/application/modules/user/controllers/ClientController.php
diff options
context:
space:
mode:
authorBjörn Geiger2011-03-27 16:44:55 +0200
committerBjörn Geiger2011-03-27 16:44:55 +0200
commitaaf8275e5ff92504357c5f3167a3f256d0d393ad (patch)
tree1b6faae50f95f7a3bc2c51c452fc33c8f867caa4 /application/modules/user/controllers/ClientController.php
parentCompare Methode bei allen Mappern ergänzt (diff)
downloadpbs2-aaf8275e5ff92504357c5f3167a3f256d0d393ad.tar.gz
pbs2-aaf8275e5ff92504357c5f3167a3f256d0d393ad.tar.xz
pbs2-aaf8275e5ff92504357c5f3167a3f256d0d393ad.zip
Rollenverwaltung User Module
Diffstat (limited to 'application/modules/user/controllers/ClientController.php')
-rw-r--r--application/modules/user/controllers/ClientController.php207
1 files changed, 106 insertions, 101 deletions
diff --git a/application/modules/user/controllers/ClientController.php b/application/modules/user/controllers/ClientController.php
index 30ac2f7..7846d94 100644
--- a/application/modules/user/controllers/ClientController.php
+++ b/application/modules/user/controllers/ClientController.php
@@ -3,24 +3,29 @@
class User_ClientController extends Zend_Controller_Action
{
private $membership;
- public function init()
- {
- $userIDsNamespace = Zend_Session::namespaceGet('userIDs');
- if($userIDsNamespace['membershipID'] ==''){
- $pbsNotifier = new Pbs_Notifier();
- echo $pbsNotifier->notify('No membershipID set','forbidden');
+
+ public function init()
+ {
+ if (Zend_Auth::getInstance()->hasIdentity()) {
+ $userIDsNamespace = Zend_Session::namespaceGet('userIDs');
+ if($userIDsNamespace['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();
+ $membershipMapper->find($userIDsNamespace['membershipID'],$this->membership);
+ } else {
+ $this->_helper->redirector('login', 'auth');
}
- /* Initialize action controller here */
- $membershipMapper = new Application_Model_MembershipMapper();
- $this->membership = new Application_Model_Membership();
- $membershipMapper->find($userIDsNamespace['membershipID'],$this->membership);
- }
-
- public function indexAction()
- {
- // TODO: ACL: is he authorized to see this ?
-
- // Get the Clients which booted with a bootiso of this group
+ }
+
+ public function indexAction()
+ {
+ // TODO: ACL: is he authorized to see this ?
+
+ // Get the Clients which booted with a bootiso of this group
$result = $this->_request->getParam('deleteresult');
if($result != ""){
$pbsNotifier = new Pbs_Notifier();
@@ -36,115 +41,115 @@ class User_ClientController extends Zend_Controller_Action
$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);
-
- $this->view->clients = $clientsInGroup;
-
- }
- public function addclientAction()
- {
- $mac = $this->_request->getParam('mac');
+ $this->view->clients = $clientsInGroup;
+
+ }
+
+ public function addclientAction()
+ {
+ $mac = $this->_request->getParam('mac');
$hh = $this->_request->getParam('hh');
-
+
// TODO: ACL: is he authorized to create new clients?
#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/index/addresult/ok');
- }
- $this->view->addclient = $addclient;
+ 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/index/addresult/ok');
}
+ $this->view->addclient = $addclient;
+ }
#}else{
# $this->_redirect('/user/');
#}
- }
+ }
- public function removeclientAction()
- {
- $clientID = $this->_request->getParam('clientID');
+ public function removeclientAction()
+ {
+ $clientID = $this->_request->getParam('clientID');
// TODO: ACL: is he authorized to delete clients?
#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');
- }
+ $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');
}
- $this->_redirect('/user/client/index/deleteresult/error');
+ else{
+ $this->_redirect('/user/client/index/deleteresult/forbidden');
+ }
+ }
+ $this->_redirect('/user/client/index/deleteresult/error');
#}else{
# $this->_redirect('/user/');
#}
- }
-
- public function editclientAction(){
- // 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');
- }
+ }
+
+ public function editclientAction(){
+ // 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{
- $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);
-
- 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->_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);
+
+ 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/');
#}
- }
+ }
}