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 | |
| parent | datenbankfehler behoben (diff) | |
| download | pbs2-3d04fb75a980dba20e51dc91afd49f0eb9ee43fe.tar.gz pbs2-3d04fb75a980dba20e51dc91afd49f0eb9ee43fe.tar.xz pbs2-3d04fb75a980dba20e51dc91afd49f0eb9ee43fe.zip | |
Form-Verhalten geändert & Datenbank korrigiert
| -rw-r--r-- | application/controllers/ClientController.php | 21 | ||||
| -rw-r--r-- | application/controllers/FilterController.php | 78 | ||||
| -rw-r--r-- | application/controllers/PoolController.php | 20 | ||||
| -rw-r--r-- | application/forms/FilterAdd.php | 24 | ||||
| -rw-r--r-- | application/views/scripts/filter/index.phtml | 11 | ||||
| -rw-r--r-- | application/views/scripts/pool/index.phtml | 22 | ||||
| -rw-r--r-- | pbs-data.sql | 6 | ||||
| -rw-r--r-- | public/media/css/style.css | 5 |
8 files changed, 91 insertions, 96 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'); } diff --git a/application/forms/FilterAdd.php b/application/forms/FilterAdd.php index af4f9b2..091eb37 100644 --- a/application/forms/FilterAdd.php +++ b/application/forms/FilterAdd.php @@ -2,6 +2,7 @@ class Application_Form_FilterAdd extends Zend_Form { + private $bootmenus; public function init() { @@ -22,14 +23,16 @@ class Application_Form_FilterAdd extends Zend_Form 'label' => 'Description:', )); - $this->addElement('text', 'bootmenuID', array( - 'filters' => array('StringTrim'), - 'validators' => array( - array('StringLength', false, array(0, 50)), - ), - 'required' => true, - 'label' => 'bootmenuID:', - )); + $bootmenufield = $this->createElement('select','bootmenuID'); + $bootmenufield ->setLabel('Bootmenu:'); + + if(count($this->bootmenus)>0){ + foreach($this->bootmenus as $id => $g){ + $bootmenufield->addMultiOption($g->getID(), $g->getTitle()); + } + } + $bootmenufield->setRegisterInArrayValidator(false); + $this->addElement($bootmenufield); $this->addElement('text', 'priority', array( 'filters' => array('StringTrim'), @@ -45,7 +48,10 @@ class Application_Form_FilterAdd extends Zend_Form 'label' => 'Save', )); } - + function setBootmenus($val){ + $this->bootmenus = $val; + return; + } } diff --git a/application/views/scripts/filter/index.phtml b/application/views/scripts/filter/index.phtml index 6f98b4c..a3d3efa 100644 --- a/application/views/scripts/filter/index.phtml +++ b/application/views/scripts/filter/index.phtml @@ -43,13 +43,17 @@ 'default', true) ?>"><img src='/media/img/add.png' alt='Add Filterentry'/></a></td> </tr> + <?php + $fe = new Application_Model_FilterEntriesMapper(); + # print_a($erg = $fe->findBy('filterID',$filter->getID())); + $erg = $fe->findBy('filterID',$filter->getID()); + ?> + <?php if (count($erg)>0): ?> <tr class=detail> <td class=arrowtop>↳</td> <td colspan=6> <?php - $fe = new Application_Model_FilterEntriesMapper(); - # print_a($erg = $fe->findBy('filterID',$filter->getID())); - $erg = $fe->findBy('filterID',$filter->getID()); + ?> <table> <tr> @@ -96,6 +100,7 @@ </table> </td> </tr> + <?php endif;?> <?php endforeach ?> </table> diff --git a/application/views/scripts/pool/index.phtml b/application/views/scripts/pool/index.phtml index f89dbc9..2c6ba16 100644 --- a/application/views/scripts/pool/index.phtml +++ b/application/views/scripts/pool/index.phtml @@ -43,6 +43,11 @@ 'default', true) ?>"><img src='/media/img/add.png' alt='Link Client'/></a></td> </tr> + <?php + $poolentriesMapper = new Application_Model_PoolEntriesMapper(); + $clients = $poolentriesMapper->findBy('poolID',$pool->getID()); + ?> + <?php if (count($clients)>0): ?> <tr class=detail> <td class=arrowtop>↳</td> <td colspan=6> @@ -54,8 +59,6 @@ <th>Actions</th> </tr> <?php - $poolentriesMapper = new Application_Model_PoolEntriesMapper(); - $clients = $poolentriesMapper->findBy('poolID',$pool->getID()); foreach ($clients as $client): ?> <tr> <td><?php echo $client['clientID'];?></td> @@ -77,14 +80,18 @@ </tr> <?php endforeach ?> </table> + </td> + </tr> + <?php endif;?> <?php endforeach ?> </table> <h2>Free clients</h2> <table > -<tr><th>ClientID</th><th>MacAdress</th><th>Hardwarehash</th> -<?php foreach ($this->pools as $pool): ?> - <th><?php echo $this->escape($pool->getTitle()) ?></th> - <?php endforeach ?> +<tr> +<th>ClientID</th> +<th>MacAdress</th> +<th>Hardwarehash</th> +<th>Actions</th> </tr> <?php foreach ($this->freeclients as $client): ?> @@ -92,7 +99,8 @@ foreach ($this->freeclients as $client): ?> <td><?php echo $client['clientID']; ?></td> <td><?php echo $client['macadress']; ?></td> <td><?php echo $client['hardwarehash']; ?></td> - <td><select> + <td><select onChange="location.href=this.options[this.selectedIndex].value"> + <option></option> <?php foreach ($this->pools as $pool): ?> <option value="<?php echo $this->url( array( diff --git a/pbs-data.sql b/pbs-data.sql index 01ec4a1..f80c8eb 100644 --- a/pbs-data.sql +++ b/pbs-data.sql @@ -64,8 +64,11 @@ INSERT INTO `pbs_poolentries` (`poolentriesID`, `poolID`, `clientID`) VALUES (10, 3, 10); -- Insert Data for Sessions +INSERT INTO `pbs`.`pbs_config` (`configID`, `title`, `groupID`, `membershipID`, `shellscript`, `created`) VALUES +(NULL, 'Config 1', '1', '1', 'Shellscirpt', UNIX_TIMESTAMP()); + INSERT INTO `pbs`.`pbs_bootos` (`bootosID`, `configID`, `groupID`, `membershipID`, `title`, `description`, `path_init`, `path_kernel`, `defaultkcl`, `created`, `expires`, `public`) VALUES -(1, NULL, 1, 1, 'BootOS 1', 'Description', '', '', '', '', NULL, 0); +(1, 1, 1, 1, 'BootOS 1', 'Description', '', '', '', '', NULL, 0); INSERT INTO `pbs_bootiso` (`bootisoID`, `title`, `membershipID`, `groupID`, `path`, `serialnumber`, `created`, `expires`, `public`) VALUES (1, 'BootISO 1', 1, 1, '', 1337, '', NULL, 1), @@ -75,3 +78,4 @@ INSERT INTO `pbs_person` (`personID`, `title`, `name`, `firstname`, `street`, `h (3, '1', '2', '3', '4', '5', '6', '7', NULL, '1299612370', 'test', NULL, '4207acba08cadccc397e2302a55b339a', 'f21ee663b17bcefc6868694dffda602a'); + diff --git a/public/media/css/style.css b/public/media/css/style.css index fb4177e..ec6fcc7 100644 --- a/public/media/css/style.css +++ b/public/media/css/style.css @@ -60,10 +60,13 @@ color:#000; h1 { display:block; -width:400px; text-align:center; margin:5px auto; } +h2{ + display:block; + text-align:center; +} table { width:100%; |
