summaryrefslogtreecommitdiffstats
path: root/application/modules/dev/controllers/PoolController.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/modules/dev/controllers/PoolController.php')
-rw-r--r--application/modules/dev/controllers/PoolController.php316
1 files changed, 154 insertions, 162 deletions
diff --git a/application/modules/dev/controllers/PoolController.php b/application/modules/dev/controllers/PoolController.php
index 6f80468..6e31161 100644
--- a/application/modules/dev/controllers/PoolController.php
+++ b/application/modules/dev/controllers/PoolController.php
@@ -1,175 +1,167 @@
-<?php
+<? php
/*
* Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
- * This program is free software distributed under the GPL version 2.
- * See http://gpl.openslx.org/
- *
- * If you have any feedback please consult http://feedback.openslx.org/ and
- * send your suggestions, praise, or complaints to feedback@openslx.org
- *
- * General information about OpenSLX can be found at http://openslx.org/
- */
-
-class dev_PoolController extends Zend_Controller_Action
-{
-
- public function init()
- {
- /* Initialize action controller here */
+* This program is free software distributed under the GPL version 2.
+* See http://gpl.openslx.org/
+*
+* If you have any feedback please consult http://feedback.openslx.org/ and
+* send your suggestions, praise, or complaints to feedback@openslx.org
+*
+* General information about OpenSLX can be found at http://openslx.org/
+*/
+
+class dev_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();
}
-
- 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;
-
+ $assignedclientmapper = new Application_Model_PoolEntriesMapper();
+ $assignedclients = $assignedclientmapper->fetchAll();
+ foreach($assignedclients as $c) {
+ $assignedclientsArray[] = $c->toArray();
}
-
- public function createpoolAction()
- {
- if (!isset($_POST["add"])){
- $addfilterform = new dev_Form_Pool(array('buttontext' => 'Create Pool'));
- $this->view->addpool = $addfilterform;
- }else {
- $addpoolform = new dev_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('/dev/pool');
- return;
- }catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
- }
- }
- $this->view->addpool = $addfilterform;
- }
+ $freeclients = $this->arrayDiff($clientsArray, $assignedclientsArray);
+
+ $this->view->freeclients = $freeclients;
+
+ }
+
+ public function createpoolAction() {
+ if (!isset($_POST["add"])) {
+ $addfilterform = new dev_Form_Pool(array('buttontext' => 'Create Pool'));
+ $this->view->addpool = $addfilterform;
+ } else {
+ $addpoolform = new dev_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('/dev/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('/dev/pool');
+ }
+
+ 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);
}
-
- 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 dev_Form_Pool(array('buttontext' => 'Edit Pool'));
- $editpool->populate($poolArray);
- $this->view->editpoolform = $editpool;
-
- }else {
- $editpoolform = new dev_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');
- }catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
- }
- }
- $this->view->editpoolform = $editpoolform;
- }
+ $this->_redirect('/dev/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 dev_Form_Pool(array('buttontext' => 'Edit Pool'));
+ $editpool->populate($poolArray);
+ $this->view->editpoolform = $editpool;
+
+ } else {
+ $editpoolform = new dev_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');
+ } 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 dev_Form_PoolClient(array('buttontext' => 'Link Client', 'clients' => $freeclients));
+ $this->view->poolclient = $poolclient;
+ } else {
+ $poolclient = new dev_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('/dev/pool');
+ } catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
+ }
+ $this->view->poolclient = $poolclient;
- 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 dev_Form_PoolClient(array('buttontext' => 'Link Client','clients'=> $freeclients));
- $this->view->poolclient = $poolclient;
- }else {
- $poolclient = new dev_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('/dev/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('/dev/pool');
+ }
+ 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('/dev/pool');
+ }
}