summaryrefslogtreecommitdiffstats
path: root/application/controllers
diff options
context:
space:
mode:
authormichael pereira2011-03-07 17:54:01 +0100
committermichael pereira2011-03-07 17:54:01 +0100
commitf122bafccf6a81b87d982956f615e70ceaecfeb3 (patch)
tree98e9960b2fda10f29765d3382d7fd92cfc100f92 /application/controllers
parentBootMenuEntries fertig (diff)
parentdirty hack entfertn durch findBy-Methode (diff)
downloadpbs2-f122bafccf6a81b87d982956f615e70ceaecfeb3.tar.gz
pbs2-f122bafccf6a81b87d982956f615e70ceaecfeb3.tar.xz
pbs2-f122bafccf6a81b87d982956f615e70ceaecfeb3.zip
Merge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2
Diffstat (limited to 'application/controllers')
-rw-r--r--application/controllers/FilterController.php15
-rw-r--r--application/controllers/PoolController.php133
2 files changed, 137 insertions, 11 deletions
diff --git a/application/controllers/FilterController.php b/application/controllers/FilterController.php
index 1305689..73b087c 100644
--- a/application/controllers/FilterController.php
+++ b/application/controllers/FilterController.php
@@ -20,11 +20,6 @@ class FilterController extends Zend_Controller_Action
try{
$this->_filtermapper = new Application_Model_FilterMapper();
$this->view->filters = $this->_filtermapper->fetchAll();
-
- $filterentries = new Application_Model_FilterEntriesMapper();
-
- $this->view->filterentries = $filterentries->fetchAll();
-
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
@@ -309,6 +304,12 @@ class FilterController extends Zend_Controller_Action
If client comes from a specific pool
*/
#########################################################
+ // ClientID
+ $filtertypID = 8;
+ /*
+ If client is a specific client
+ */
+ #########################################################
// BootIso
$filtertypID = 4;
/*
@@ -318,13 +319,13 @@ class FilterController extends Zend_Controller_Action
// Membership
$filtertypID = 5;
/*
-
+ user is in a defined membership
*/
#########################################################
// Group
$filtertypID = 6;
/*
-
+ user is in a defined groupID
*/
#########################################################
// Time
diff --git a/application/controllers/PoolController.php b/application/controllers/PoolController.php
index f9e54be..28bde8e 100644
--- a/application/controllers/PoolController.php
+++ b/application/controllers/PoolController.php
@@ -11,22 +11,143 @@ class PoolController extends Zend_Controller_Action
public function indexAction()
{
$poolMapper = new Application_Model_PoolMapper();
- $this->view->pools = $poolMapper->fetchAll();
+ $this->view->pools = $poolMapper->fetchAll();
+
+ $poolentriesMapper = new Application_Model_PoolEntriesMapper();
+ #print_a($poolentriesMapper->findBy('poolID',1));
+
}
public function createpoolAction()
{
- // action body
+ if (!isset($_POST["add"])){
+ $addfilterform = new Application_Form_Pool();
+ $this->view->addpool = $addfilterform;
+ }else {
+ $addpoolform = new Application_Form_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";
+ }
+ }
+ }
}
public function deletepoolAction()
{
- // action body
+ $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()
{
- // action body
+ 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();
+ $editpool->populate($poolArray);
+ $this->view->editpoolform = $editpool;
+
+ }else {
+ $addpoolform = new Application_Form_Pool($_POST);
+ if ($addpoolform->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";
+ }
+ }
+ }
+ }
+
+ public function linkclientAction()
+ {
+ if(!isset($_POST['clientID'])){
+ print_a($_POST);
+ $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);
+
+ $poolclient = new Application_Form_PoolClient(array('clients'=> $freeclients));
+ $this->view->poolclient = $poolclient;
+ }else {
+ #$_POST['poolID'] = $this->_request->getParam('poolID');
+ $poolclientform = new Application_Form_PoolClient($_POST);
+
+ try{
+ $pool = new Application_Model_PoolEntries($_POST);
+ $pool->setPoolID($this->_request->getParam('poolID'));
+
+ $poolmapper = new Application_Model_PoolEntriesMapper();
+ $poolmapper->save($pool);
+ $this->_redirect('/pool');
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
+ }
+
+ }
+ }
+ 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);
+ echo "<pre style='border:1px solid black;background-color:#F5B800'>";
+ print_r($deletepoolentries);
+ echo "</pre>";
+
+ $deletepoolentriesmapper = new Application_Model_PoolEntriesMapper();
+ $deletepoolentriesmapper->delete($deletepoolentries);
+ echo "ok";
+ }
+# echo "ready";
+ $this->_redirect('/pool');
}
@@ -38,3 +159,7 @@ class PoolController extends Zend_Controller_Action
+
+
+
+