diff options
| author | Simon | 2011-03-09 16:31:58 +0100 |
|---|---|---|
| committer | Simon | 2011-03-09 16:31:58 +0100 |
| commit | 3d04fb75a980dba20e51dc91afd49f0eb9ee43fe (patch) | |
| tree | 11a095d4a8a372a4042d3c18e2fc15d780a76a95 /application/controllers | |
| parent | datenbankfehler behoben (diff) | |
| download | pbs2-3d04fb75a980dba20e51dc91afd49f0eb9ee43fe.tar.gz pbs2-3d04fb75a980dba20e51dc91afd49f0eb9ee43fe.tar.xz pbs2-3d04fb75a980dba20e51dc91afd49f0eb9ee43fe.zip | |
Form-Verhalten geändert & Datenbank korrigiert
Diffstat (limited to 'application/controllers')
| -rw-r--r-- | application/controllers/ClientController.php | 21 | ||||
| -rw-r--r-- | application/controllers/FilterController.php | 78 | ||||
| -rw-r--r-- | application/controllers/PoolController.php | 20 |
3 files changed, 44 insertions, 75 deletions
diff --git a/application/controllers/ClientController.php b/application/controllers/ClientController.php index ff663ba..580eb6e 100644 --- a/application/controllers/ClientController.php +++ b/application/controllers/ClientController.php @@ -16,16 +16,15 @@ class ClientController extends Zend_Controller_Action public function addclientAction() { - $mac = $this->_request->getParam('mac'); - $hh = $this->_request->getParam('hh'); + $mac = $this->_request->getParam('mac'); + $hh = $this->_request->getParam('hh'); if (!isset($_POST["add"])){ - $addclient = new Application_Form_Client(); - $this->view->addclient = $addclient; + $addclient = new Application_Form_Client(); + $this->view->addclient = $addclient; } else{ $addfilterform = new Application_Form_Client($_POST); - print_a($_POST,$addfilterform->isValid($_POST)); if ($addfilterform->isValid($_POST) || ($mac != '' && $hh != '') ) { $client = new Application_Model_Client(); $mac = ($mac!='')?$mac:$_POST['macadress']; @@ -37,9 +36,7 @@ class ClientController extends Zend_Controller_Action print_a('inserted'); $this->_redirect('/client'); } - else{ - print_a('no insert'); - } + $this->view->addclient = $addclient; } } @@ -69,8 +66,8 @@ class ClientController extends Zend_Controller_Action $this->view->editclient = $editclient; } else{ - $addfilterform = new Application_Form_Client($_POST); - if ($addfilterform->isValid($_POST) || ($mac != '' && $hh != '') ) { + $editclient = new Application_Form_Client($_POST); + if ($editclient->isValid($_POST) || ($mac != '' && $hh != '') ) { $client = new Application_Model_Client($_POST); $client->setID($this->_request->getParam('clientID')); $clientmapper = new Application_Model_ClientMapper(); @@ -78,9 +75,7 @@ class ClientController extends Zend_Controller_Action print_a('updated'); $this->_redirect('/client'); } - else{ - print_a('no update'); - } + $this->view->editclient = $editclient; } } diff --git a/application/controllers/FilterController.php b/application/controllers/FilterController.php index 54bcb19..2853706 100644 --- a/application/controllers/FilterController.php +++ b/application/controllers/FilterController.php @@ -19,27 +19,27 @@ class FilterController extends Zend_Controller_Action public function indexAction() { try{ - $this->_filtermapper = new Application_Model_FilterMapper(); - $this->view->filters = $this->_filtermapper->fetchAll(); + $this->_filtermapper = new Application_Model_FilterMapper(); + $this->view->filters = $this->_filtermapper->fetchAll(); }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; + echo "Error message 2: " . $e->getMessage() . "\n"; } } public function addfilterAction() { - if (!isset($_POST["add"])){ - $addfilterform = new Application_Form_FilterAdd(); - $this->view->addfilterform = $addfilterform; + $bmmapper = new Application_Model_BootMenuMapper(); + //TODO get bootmenu by group + $bootmenus = $bmmapper->fetchAll(); + if (!isset($_POST["add"])){ + $addfilterform = new Application_Form_FilterAdd(array('bootmenus'=>$bootmenus)); + $this->view->addfilterform = $addfilterform; }else { - $addfilterform = new Application_Form_FilterAdd($_POST); + $addfilterform = new Application_Form_FilterAdd(array('bootmenus'=>$bootmenus),$_POST); if ($addfilterform->isValid($_POST)) { try{ - $newfilter = new Application_Model_Filter(); - $newfilter->setTitle($_POST['title']); + $newfilter = new Application_Model_Filter($_POST); $newfilter->setCreated(time()); - $newfilter->setDescription($_POST['description']); - $newfilter->setPriority($_POST['priority']); // TODO: Ändere mit ACL $newfilter->setGroupID('1'); @@ -54,6 +54,7 @@ class FilterController extends Zend_Controller_Action echo "Error message 2: " . $e->getMessage() . "\n"; } } + $this->view->addfilterform = $addfilterform; } } @@ -73,6 +74,9 @@ class FilterController extends Zend_Controller_Action public function editfilterAction() { + $bmmapper = new Application_Model_BootMenuMapper(); + //TODO get bootmenu by group + $bootmenus = $bmmapper->fetchAll(); if (!isset($_POST["add"])){ // TODO: ACL implementieren ob er editieren darf $filterID = $this->_request->getParam('filterID'); @@ -83,7 +87,7 @@ class FilterController extends Zend_Controller_Action $filtermapper->find($filterID,$filter); $filter2 = $filter->toArray(); - $editfilterform = new Application_Form_FilterAdd(); + $editfilterform = new Application_Form_FilterAdd(array('bootmenus'=>$bootmenus)); $editfilterform->populate($filter2); $this->view->editfilterform = $editfilterform; @@ -91,7 +95,7 @@ class FilterController extends Zend_Controller_Action try{ $filterID = $this->_request->getParam('filterID'); - $editfilterform = new Application_Form_FilterAdd($_POST); + $editfilterform = new Application_Form_FilterAdd(array('bootmenus'=>$bootmenus),$_POST); //TODO: ACL integrieren $_POST['groupID'] = 1; $_POST['membershipID'] = 1; @@ -102,16 +106,13 @@ class FilterController extends Zend_Controller_Action $newfilterenty->setID($this->_request->getParam('filterID')); $newfilter2 = new Application_Model_FilterMapper(); $newfilter2->save($newfilterenty); - echo 'valid'; - } - else - { - echo 'not valid'; - } + echo 'valid'; + $this->_redirect('/filter'); + } + $this->view->editfilterform = $editfilterform; }catch (Zend_Exception $e) { echo "Error message 2: " . $e->getMessage() . "\n"; } - $this->_redirect('/filter'); } } @@ -120,23 +121,15 @@ class FilterController extends Zend_Controller_Action // TODO: ACL implementieren ob er editieren darf if (!isset($_POST["add"])){ - echo "case1"; try{ $editfilterform = new Application_Form_FilterEntriesAdd(array('filterID' => $this->_request->getParam('filterID'))); $this->view->editfilterform = $editfilterform; - echo "<pre style='padding:5px;border:1px solid black;background-color:#3CF'>"; - print_r(array('debug','case1')); - echo "</pre>"; - }catch (Zend_Exception $e) { echo "Error message 2: " . $e->getMessage() . "\n"; } } else{ - $editfilterform = new Application_Form_FilterEntriesAdd($_POST); - echo "<pre style='padding:5px;border:1px solid black; background-color:#3CF;'>case2</pre>"; - - if ($editfilterform->isValid($_POST)) { - echo "<pre style='padding:5px;border:1px solid black; background-color:#3CF;'>case 2.2</pre>"; + $editfilterform = new Application_Form_FilterEntriesAdd($_POST); + if ($editfilterform->isValid($_POST)) { $newfilterenty = new Application_Model_FilterEntries(); $newfilterenty->setFilterID($_POST['filterID']); $newfilterenty->setFiltertypeID($_POST['filtertypeID']); @@ -151,12 +144,10 @@ class FilterController extends Zend_Controller_Action } $newfilter2 = new Application_Model_FilterEntriesMapper(); - echo "<pre style='border:1px solid black;background-color:#F5B800'>"; - print_r($newfilterenty); - echo "</pre>"; $newfilter2->save($newfilterenty); + $this->_redirect('/filter'); } - $this->_redirect('/filter'); + $this->view->editfilterform = $editfilterform; } } public function editfilterentryAction() @@ -174,13 +165,9 @@ class FilterController extends Zend_Controller_Action $editfilterform = new Application_Form_FilterEntriesAdd(); - echo "<pre style='border:1px solid black;background-color:#F5B800'>"; - print_r($filterentry->toArray()); - echo "</pre>"; $editfilterform->populate($filterentry->toArray()); $editfilterform->setFilterID($filterID); $this->view->editfilterform = $editfilterform; - echo "case 1.1"; }catch (Zend_Exception $e) { echo "Error message 2: " . $e->getMessage() . "\n"; @@ -189,8 +176,7 @@ class FilterController extends Zend_Controller_Action try{ $filterentriesID = $this->_request->getParam('filterentriesID'); $editfilterform = new Application_Form_FilterEntriesAdd($_POST); - if ($editfilterform->isValid($_POST)) { - echo "valid\n"; + if ($editfilterform->isValid($_POST)) { $newfilterenty = new Application_Model_FilterEntries($_POST); $newfilterenty->setID($filterentriesID); if($_POST['filtertypeID'] == 1){ @@ -201,20 +187,15 @@ class FilterController extends Zend_Controller_Action $newfilterenty->setFiltervalue($_POST['filtervalue']); $newfilterenty->setFiltervalue2($_POST['filtervalue2']); } - echo "<pre style='border:1px solid black;background-color:#F5B800'>"; - print_r($newfilterenty); - echo "</pre>"; $newfilter2 = new Application_Model_FilterEntriesMapper(); $newfilter2->save($newfilterenty); + $this->_redirect('/filter'); } - else{ - echo 'nö'; - } + $this->view->editfilterform = $editfilterform; }catch (Zend_Exception $e) { echo "Error message 2: " . $e->getMessage() . "\n"; } - $this->_redirect('/filter'); } } public function removefilterentryAction() @@ -260,8 +241,7 @@ class FilterController extends Zend_Controller_Action public function evaluateAction(){ $db = $this->db; $showPartResults = false; - try{ - + try{ $mysession = '1'; $filtertypID = 8; diff --git a/application/controllers/PoolController.php b/application/controllers/PoolController.php index cb38a80..7c5092e 100644 --- a/application/controllers/PoolController.php +++ b/application/controllers/PoolController.php @@ -25,7 +25,6 @@ class PoolController extends Zend_Controller_Action $assignedclientsArray[] = $c->toArray(); } $freeclients = $this->arrayDiff($clientsArray,$assignedclientsArray); - #print_a($freeclients); $this->view->freeclients = $freeclients; @@ -49,6 +48,7 @@ class PoolController extends Zend_Controller_Action echo "Error message 2: " . $e->getMessage() . "\n"; } } + $this->view->addpool = $addfilterform; } } @@ -80,8 +80,8 @@ class PoolController extends Zend_Controller_Action $this->view->editpoolform = $editpool; }else { - $addpoolform = new Application_Form_Pool($_POST); - if ($addpoolform->isValid($_POST)) { + $editpoolform = new Application_Form_Pool($_POST); + if ($editpoolform->isValid($_POST)) { try{ $pool = new Application_Model_Pool($_POST); $pool->setID($this->_request->getParam('poolID')); @@ -92,6 +92,7 @@ class PoolController extends Zend_Controller_Action echo "Error message 2: " . $e->getMessage() . "\n"; } } + $this->view->editpoolform = $editpoolform; } } @@ -99,10 +100,8 @@ class PoolController extends Zend_Controller_Action { $clientID = $this->_request->getParam('clientID'); $poolID = $this->_request->getParam('poolID'); - print_a($clientID,$poolID); if(!isset($_POST['clientID']) && ($clientID == '' && $poolID == '')){ - print_a($_POST); $clientmapper = new Application_Model_ClientMapper(); $clients = $clientmapper->fetchAll(); foreach($clients as $c){ @@ -117,10 +116,8 @@ class PoolController extends Zend_Controller_Action $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); - + }else { + $poolclient = new Application_Form_PoolClient($_POST); try{ $pool = new Application_Model_PoolEntries($_POST); $pool->setPoolID($this->_request->getParam('poolID')); @@ -133,6 +130,7 @@ class PoolController extends Zend_Controller_Action }catch (Zend_Exception $e) { echo "Error message 2: " . $e->getMessage() . "\n"; } + $this->view->poolclient = $poolclient; } } @@ -156,15 +154,11 @@ class PoolController extends Zend_Controller_Action 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'); } |
