summaryrefslogtreecommitdiffstats
path: root/application/controllers/PoolController.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/controllers/PoolController.php')
-rw-r--r--application/controllers/PoolController.php176
1 files changed, 0 insertions, 176 deletions
diff --git a/application/controllers/PoolController.php b/application/controllers/PoolController.php
deleted file mode 100644
index f27ee45..0000000
--- a/application/controllers/PoolController.php
+++ /dev/null
@@ -1,176 +0,0 @@
-<?php
-
-class PoolController extends Zend_Controller_Action
-{
-
- public function init()
- {
- /* Initialize action controller here */
- }
-
- public function indexAction()
- {
- $poolMapper = new Application_Model_PoolMapper();
- $this->view->pools = $poolMapper->fetchAll();
-
- $clientmapper = new Application_Model_ClientMapper();
- $clients = $clientmapper->fetchAll();
- foreach($clients as $c){
- #$client = new Application_Model_Client($c);
- $clientsArray[] = $c->toArray();
- }
- $assignedclientmapper = new Application_Model_PoolEntriesMapper();
- $assignedclients = $assignedclientmapper->fetchAll();
- foreach($assignedclients as $c){
- $assignedclientsArray[] = $c->toArray();
- }
- $freeclients = $this->arrayDiff($clientsArray,$assignedclientsArray);
-
- $this->view->freeclients = $freeclients;
-
- }
-
- public function createpoolAction()
- {
- if (!isset($_POST["add"])){
- $addfilterform = new Application_Form_Pool(array('buttontext' => 'Create Pool'));
- $this->view->addpool = $addfilterform;
- }else {
- $addpoolform = new Application_Form_Pool(array('buttontext' => 'Create Pool'),$_POST);
- if ($addpoolform->isValid($_POST)) {
- try{
- $pool = new Application_Model_Pool($_POST);
- $poolmapper = new Application_Model_PoolMapper();
- $poolmapper->save($pool);
- $this->_redirect('/pool');
- return;
- }catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
- }
- }
- $this->view->addpool = $addfilterform;
- }
- }
-
- public function deletepoolAction()
- {
- $poolID = $this->_request->getParam('poolID');
- // TODO: ACL implementieren ob er den pool löschen darf
- if(is_numeric($poolID)){
- $deletepool = new Application_Model_Pool();
- $deletepool->setID($poolID);
- $poolmapper = new Application_Model_PoolMapper();
- $poolmapper->delete($deletepool);
- }
- $this->_redirect('/pool');
- }
-
- public function editpoolAction()
- {
- if (!isset($_POST["add"])){
- $poolID = $this->_request->getParam('poolID');
-
- $pool = new Application_Model_Pool();
- $poolmapper = new Application_Model_PoolMapper();
- $poolmapper->find($poolID,$pool);
- $poolArray = $pool->toArray();
-
- $editpool = new Application_Form_Pool(array('buttontext' => 'Edit Pool'));
- $editpool->populate($poolArray);
- $this->view->editpoolform = $editpool;
-
- }else {
- $editpoolform = new Application_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('/pool');
- }catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
- }
- }
- $this->view->editpoolform = $editpoolform;
- }
- }
-
- public function linkclientAction()
- {
- $clientID = $this->_request->getParam('clientID');
- $poolID = $this->_request->getParam('poolID');
- if(!isset($_POST['clientID']) && ($clientID == '')){
- $clientmapper = new Application_Model_ClientMapper();
- $clients = $clientmapper->fetchAll();
- foreach($clients as $c){
- $clientsArray[] = $c->toArray();
- }
- $assignedclientmapper = new Application_Model_PoolEntriesMapper();
- $assignedclients = $assignedclientmapper->fetchAll();
- foreach($assignedclients as $c){
- $assignedclientsArray[] = $c->toArray();
- }
- $freeclients = $this->arrayDiff($clientsArray,$assignedclientsArray);
-
- $poolclient = new Application_Form_PoolClient(array('buttontext' => 'Link Client','clients'=> $freeclients));
- $this->view->poolclient = $poolclient;
- }else {
- $poolclient = new Application_Form_PoolClient(array('buttontext' => 'Link Client'),$_POST);
- try{
- $pool = new Application_Model_PoolEntries($_POST);
- $pool->setPoolID($this->_request->getParam('poolID'));
- if($pool->getClientID() == ''){
- $pool->setClientID($this->_request->getParam('clientID'));
- }
- $poolmapper = new Application_Model_PoolEntriesMapper();
- $poolmapper->save($pool);
- $this->_redirect('/pool');
- }catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
- }
- $this->view->poolclient = $poolclient;
-
- }
- }
- private function arrayDiff($a, $b){
- foreach($a as $k1 => $i1){
- foreach($b as $k2 => $i2){
- if($i1['clientID'] == $i2['clientID']){
- unset($a[$k1]);
- }
- }
- }
- return $a;
- }
-
-
- public function unlinkclientAction()
- {
- $poolentriesID = $this->_request->getParam('poolentriesID');
-
- // TODO: ACL implementieren ob er den filter löschen darf
- if(is_numeric($poolentriesID)){
- $deletepoolentries = new Application_Model_PoolEntries();
- $deletepoolentries->setID($poolentriesID);
-
- $deletepoolentriesmapper = new Application_Model_PoolEntriesMapper();
- $deletepoolentriesmapper->delete($deletepoolentries);
- echo "ok";
- }
- $this->_redirect('/pool');
- }
-
-
-}
-
-
-
-
-
-
-
-
-
-
-