summaryrefslogtreecommitdiffstats
path: root/application/modules/user/controllers
diff options
context:
space:
mode:
authormichael pereira2011-03-18 19:27:33 +0100
committermichael pereira2011-03-18 19:27:33 +0100
commit87b3b1d9c0cecf76d1eb39cf2548072607de59ea (patch)
tree5d07af0d68e20a38422a72864b3ca68b1a1b07be /application/modules/user/controllers
parentBootOs Update implementiert, BootISO anlegen und some fixes (diff)
parentUser-Oberfläche, FBGui-Oberfläche legt Session&Clients an - für Kiosk-System (diff)
downloadpbs2-87b3b1d9c0cecf76d1eb39cf2548072607de59ea.tar.gz
pbs2-87b3b1d9c0cecf76d1eb39cf2548072607de59ea.tar.xz
pbs2-87b3b1d9c0cecf76d1eb39cf2548072607de59ea.zip
newsql geaendert
Diffstat (limited to 'application/modules/user/controllers')
-rw-r--r--application/modules/user/controllers/ClientController.php151
-rw-r--r--application/modules/user/controllers/FilterController.php103
-rw-r--r--application/modules/user/controllers/PoolController.php149
3 files changed, 313 insertions, 90 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/');
+ #}
}
diff --git a/application/modules/user/controllers/FilterController.php b/application/modules/user/controllers/FilterController.php
index 2704309..8ceefe3 100644
--- a/application/modules/user/controllers/FilterController.php
+++ b/application/modules/user/controllers/FilterController.php
@@ -2,13 +2,100 @@
class User_FilterController extends Zend_Controller_Action
{
-
+ protected $filterMapper;
+ protected $membershipMapper;
public function init()
{
- /* Initialize action controller here */
+ if($_SESSION['membershipID'] ==''){
+ $pbsNotifier = new Pbs_Notifier();
+ echo $pbsNotifier->notify('No membershipID set','forbidden');
+ }
+ $this->filterMapper = new Application_Model_FilterMapper();
+
+ $membershipMapper = new Application_Model_MembershipMapper();
+ $this->membership = new Application_Model_Membership();
+ $membershipMapper->find($_SESSION['membershipID'],$this->membership);
+
+ $this->db = Zend_Db_Table::getDefaultAdapter();
}
public function indexAction()
+ {
+ // TODO: ACL: is he authorized to see this?
+
+ $result = $this->_request->getParam('addresult');
+ if($result != ""){
+ $pbsNotifier = new Pbs_Notifier();
+ $this->view->notification = $pbsNotifier->notify('create',$result);
+ }
+
+ $filters = $this->filterMapper->findBy('groupID',$this->membership->getGroupID());
+ foreach($filters as $filter){
+ $ff = new Application_Model_Filter();
+ $ff->setOptions($filter);
+ $ff->setID($filter['filterID']);
+ $allFilter[] = $ff;
+ }
+ $this->view->filters = $allFilter;
+ }
+
+ public function addfilterAction()
+ {
+ // TODO: ACL: is he authorized to add a filter?
+ $bmmapper = new Application_Model_BootMenuMapper();
+ $result = $bmmapper->findBy('groupID',$this->membership->getGroupID());
+ foreach($result as $rr){
+ $bm = new Application_Model_BootMenu();
+ $bm->setOptions($rr);
+ $bm->setID($rr['bootmenuID']);
+ $bootmenus[] = $bm;
+ }
+ $this->view->bootmenus = $bootmenus;
+
+ if (!isset($_POST["add"])){
+ $addfilterform = new user_Form_Filter(array('buttontext' => 'Create Filter','bootmenus'=>$bootmenus));
+ $this->view->addfilterform = $addfilterform;
+ }else {
+ $addfilterform = new user_Form_Filter(array('buttontext' => 'Create Filter','bootmenus'=>$bootmenus),$_POST);
+ if ($addfilterform->isValid($_POST)) {
+ try{
+ $newfilter = new Application_Model_Filter($_POST);
+ $newfilter->setCreated(time());
+ $newfilter->setGroupID($this->membership->getGroupID());
+ $newfilter->setMembershipID($this->membership->getID());
+ $newfilter2 = new Application_Model_FilterMapper();
+ $newfilter2->save($newfilter);
+ $this->_redirect('/user/filter/index/addresult/ok');
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
+ $this->_redirect('/user/filter/index/addresult/error');
+ }
+ }
+ $this->view->addfilterform = $addfilterform;
+ }
+ }
+
+ public function removefilterAction()
+ {
+ // action body
+ }
+
+ public function editfilterAction()
+ {
+ // action body
+ }
+
+ public function addfilterentryAction()
+ {
+ // action body
+ }
+
+ public function editfilterentryAction()
+ {
+ // action body
+ }
+
+ public function removefilterentryAction()
{
// action body
}
@@ -16,3 +103,15 @@ class User_FilterController extends Zend_Controller_Action
}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/application/modules/user/controllers/PoolController.php b/application/modules/user/controllers/PoolController.php
index 01b5a2a..f786aa8 100644
--- a/application/modules/user/controllers/PoolController.php
+++ b/application/modules/user/controllers/PoolController.php
@@ -5,6 +5,11 @@ class User_PoolController extends Zend_Controller_Action
private $membership;
public function init()
{
+ if($_SESSION['membershipID'] ==''){
+ $pbsNotifier = new Pbs_Notifier();
+ echo $pbsNotifier->notify('No membershipID set','forbidden');
+ }
+
$membershipMapper = new Application_Model_MembershipMapper();
$this->membership = new Application_Model_Membership();
$membershipMapper->find($_SESSION['membershipID'],$this->membership);
@@ -29,10 +34,26 @@ class User_PoolController extends Zend_Controller_Action
$pbsNotifier = new Pbs_Notifier();
$this->view->notification = $pbsNotifier->notify('create',$result);
}
-
+ $result = $this->_request->getParam('linkresult');
+ if($result != ""){
+ $pbsNotifier = new Pbs_Notifier();
+ $this->view->notification = $pbsNotifier->notify('link',$result);
+ }
+ $result = $this->_request->getParam('unlinkresult');
+ if($result != ""){
+ $pbsNotifier = new Pbs_Notifier();
+ $this->view->notification = $pbsNotifier->notify('unlink',$result);
+ }
$poolMapper = new Application_Model_PoolMapper();
- $this->view->pools = $poolMapper->fetchAll();
+ $pools = $poolMapper->findBy('groupID',$this->membership->getGroupID());
+ foreach($pools as $pool){
+ $ff = new Application_Model_Pool();
+ $ff->setOptions($pool);
+ $ff->setID($pool['poolID']);
+ $yourpools[] = $ff;
+ }
+ $this->view->pools = $yourpools;
$clientmapper = new Application_Model_ClientMapper();
$clients = $clientmapper->fetchAll();
@@ -70,7 +91,7 @@ class User_PoolController extends Zend_Controller_Action
$this->_redirect('/dev/pool/index/addresult/error');
}
}
- $this->view->addpool = $addfilterform;
+ $this->view->addpool = $addpoolform;
}
}
@@ -95,36 +116,49 @@ class User_PoolController extends Zend_Controller_Action
}
$this->_redirect('/user/pool/index/deleteresult/error');
#}else{
- # $this->_redirect('/user/pool/index/deleteresult/forbidden');
+ # $this->_redirect('/user/');
#}
}
public function editpoolAction()
{
// TODO: ACL: is he allowed to edit a pool?
- // TODO: is he allowed to edit this pool?
if (!isset($_POST["add"])){
- $poolID = $this->_request->getParam('poolID');
+ $poolID = $this->_request->getParam('poolID');
$pool = new Application_Model_Pool();
$poolmapper = new Application_Model_PoolMapper();
- $poolmapper->find($poolID,$pool);
- $poolArray = $pool->toArray();
- $editpool = new user_Form_Pool(array('buttontext' => 'Edit Pool'));
- $editpool->populate($poolArray);
- $this->view->editpool = $editpool;
-
+ $poolmapper->find($poolID,$pool);
+ if($pool->getGroupID() == $this->membership->getGroupID()){
+ $poolArray = $pool->toArray();
+ $editpool = new user_Form_Pool(array('buttontext' => 'Edit Pool'));
+ $editpool->populate($poolArray);
+ $this->view->editpool = $editpool;
+ }
+ else{
+ $this->_redirect('/user/pool/index/modifyresult/forbidden');
+ }
}else {
$editpoolform = new user_Form_Pool(array('buttontext' => 'Edit Pool'),$_POST);
if ($editpoolform->isValid($_POST)) {
try{
- $pool = new Application_Model_Pool($_POST);
- $pool->setID($this->_request->getParam('poolID'));
$poolmapper = new Application_Model_PoolMapper();
- $poolmapper->save($pool);
- $this->_redirect('/dev/pool/index/modifyresult/ok');
+ $poolID = $this->_request->getParam('poolID');
+ $pooldb = new Application_Model_Pool();
+ $poolmapper->find($poolID,$pooldb);
+ print_a($pooldb->getGroupID(), $this->membership->getGroupID());
+ if($pooldb->getGroupID() == $this->membership->getGroupID()){
+ $pool = new Application_Model_Pool($_POST);
+ $pool->setID($poolID);
+ $pool->setGroupID($this->membership->getGroupID());
+ $poolmapper->save($pool);
+ $this->_redirect('/user/pool/index/modifyresult/ok');
+ }
+ else{
+ $this->_redirect('/user/pool/index/modifyresult/forbidden');
+ }
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
- $this->_redirect('/dev/pool/index/modifyresult/error');
+ $this->_redirect('/user/pool/index/modifyresult/error');
}
}
$this->view->editpool = $editpoolform;
@@ -132,13 +166,88 @@ class User_PoolController extends Zend_Controller_Action
}
public function linkclientAction()
- {
- // action body
+ {
+ $clientID = $this->_request->getParam('clientID');
+ $poolID = $this->_request->getParam('poolID');
+
+ // TODO: ACL: Is he allowed to link clients to pools?
+ if(!isset($_POST['clientID']) && ($clientID == '')){
+ $clientmapper = new Application_Model_ClientMapper();
+ $clients = $clientmapper->findBy('groupID',$this->membership->getGroupID());
+ $assignedclientmapper = new Application_Model_PoolEntriesMapper();
+ $assignedclients = $assignedclientmapper->fetchAll();
+ foreach($assignedclients as $c){
+ $assignedclientsArray[] = $c->toArray();
+ }
+ $freeclients = $this->arrayDiff($clients,$assignedclientsArray);
+
+ $poolclient = new user_Form_PoolClient(array('buttontext' => 'Link Client','clients'=> $freeclients));
+ $this->view->poolclient = $poolclient;
+ }else {
+ $poolclient = new dev_Form_PoolClient(array('buttontext' => 'Link Client'),$_POST);
+ try{
+ $poolID = $this->_request->getParam('poolID');
+ $poolmapper = new Application_Model_PoolMapper();
+ $pooldb = new Application_Model_Pool();
+ $poolmapper->find($poolID,$pooldb);
+ $clientmapper = new Application_Model_ClientMapper();
+ $clientdb = new Application_Model_Client();
+ $clientmapper->find($clientID,$clientdb);
+
+ if($pooldb->getGroupID() == $this->membership->getGroupID() && $clientdb->getGroupID() == $this->membership->getGroupID()){
+ $poolentriesmapper = new Application_Model_PoolEntriesMapper();
+ $poolentry = new Application_Model_PoolEntries($_POST);
+ $poolentry->setPoolID($poolID);
+ if($poolentry->getClientID() == ''){
+ $poolentry->setClientID($clientID);
+ }
+ $poolentriesmapper->save($poolentry);
+ $this->_redirect('/user/pool/index/linkresult/ok');
+ }
+ else{
+ $this->_redirect('/user/pool/index/linkresult/forbidden');
+ }
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
+ $this->_redirect('/user/pool/index/linkresult/error');
+ }
+ $this->view->poolclient = $poolclient;
+ }
}
public function unlinkclientAction()
{
- // action body
+ $poolentriesID = $this->_request->getParam('poolentriesID');
+
+ // TODO: ACL: Is he allowed to unlink clients from pools?
+ if(is_numeric($poolentriesID)){
+ $poolentriesMapper = new Application_Model_PoolEntriesMapper();
+ $poolentry = new Application_Model_PoolEntries();
+ $poolentriesMapper->find($poolentriesID,$poolentry);
+ $clientMapper = new Application_Model_ClientMapper();
+ $client = new Application_Model_Client();
+
+ $poolMapper = new Application_Model_PoolMapper();
+ $pool = new Application_Model_Pool();
+
+ $clientMapper->find($poolentry->getClientID(),$client);
+ $poolMapper->find($poolentry->getPoolID(),$pool);
+
+
+ if($pool->getGroupID() == $this->membership->getGroupID() && $client->getGroupID() == $this->membership->getGroupID()){
+ $deletepoolentries = new Application_Model_PoolEntries();
+ $deletepoolentries->setID($poolentriesID);
+ $deletepoolentriesmapper = new Application_Model_PoolEntriesMapper();
+ $deletepoolentriesmapper->delete($deletepoolentries);
+ $this->_redirect('/user/pool/index/unlinkresult/ok');
+ }
+ else{
+ $this->_redirect('/user/pool/index/unlinkresult/forbidden');
+ }
+ }
+ else{
+ $this->_redirect('/user/pool/index/unlinkresult/error');
+ }
}
// creates an array of two arrays