diff options
| author | Simon | 2011-03-09 20:49:24 +0100 |
|---|---|---|
| committer | Simon | 2011-03-09 20:49:24 +0100 |
| commit | 5767c4f644a586d5f19e86fdd2de2ad47a21cb1a (patch) | |
| tree | 116914ccf6a4bf492b74682c2fea717e4c4f92e1 /application/controllers/SessionController.php | |
| parent | style angepasst (diff) | |
| download | pbs2-5767c4f644a586d5f19e86fdd2de2ad47a21cb1a.tar.gz pbs2-5767c4f644a586d5f19e86fdd2de2ad47a21cb1a.tar.xz pbs2-5767c4f644a586d5f19e86fdd2de2ad47a21cb1a.zip | |
FilterController Evaluate funktioniert
Diffstat (limited to 'application/controllers/SessionController.php')
| -rw-r--r-- | application/controllers/SessionController.php | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/application/controllers/SessionController.php b/application/controllers/SessionController.php index 21f94fa..09eadc9 100644 --- a/application/controllers/SessionController.php +++ b/application/controllers/SessionController.php @@ -16,16 +16,32 @@ class SessionController extends Zend_Controller_Action public function createsessionAction() { + $cm = new Application_Model_ClientMapper(); + $clients = $cm->fetchAll(); + + $bm = new Application_Model_BootOsMapper(); + $bootos = $bm->fetchAll(); + + $bi = new Application_Model_BootIsoMapper(); + $bootisos = $bi->fetchAll(); + if (!isset($_POST["add"])){ - $createsession = new Application_Form_Session(); + $createsession = new Application_Form_Session(array('clients'=>$clients,'bootos'=>$bootos,'bootisos'=>$bootisos)); $this->view->createsession = $createsession; }else { // TODO extend with normal function not only with post - $createsession = new Application_Form_Session($_POST); + $createsession = new Application_Form_Session(array('clients'=>$clients,'bootos'=>$bootos,'bootisos'=>$bootisos),$_POST); print_a($_POST); if ($createsession->isValid($_POST)) { try{ $session = new Application_Model_Session($_POST); + $session->setTime(strtotime($_POST['time'])); + if($session->getClientID() == ''){ + $session->setClientID(null); + } + if($session->getBootosID() == ''){ + $session->setBootosID(null); + } $sessionmapper = new Application_Model_SessionMapper(); $sessionmapper->save($session); @@ -35,16 +51,22 @@ class SessionController extends Zend_Controller_Action echo "Error message 2: " . $e->getMessage() . "\n"; } print_a('saved'); - $this->_redirect('/session'); - } - else{ - print_a('not saved'); + #$this->_redirect('/session'); } + $this->view->createsession = $createsession; } } public function editsessionAction() { + $cm = new Application_Model_ClientMapper(); + $clients = $cm->fetchAll(); + + $bm = new Application_Model_BootOsMapper(); + $bootos = $bm->fetchAll(); + + $bi = new Application_Model_BootIsoMapper(); + $bootisos = $bi->fetchAll(); if (!isset($_POST["add"])){ // TODO: ACL implementieren ob er editieren darf $sessionID = $this->_request->getParam('sessionID'); @@ -52,10 +74,11 @@ class SessionController extends Zend_Controller_Action $sessionmapper = new Application_Model_SessionMapper(); - $sessionmapper->find($sessionID,$session); + $sessionmapper->find($sessionID,$session); + $session->setTime(date('d.m.Y H:i',$session->getTime())); $session2 = $session->toArray(); - $editsession = new Application_Form_Session(); + $editsession = new Application_Form_Session(array('clients'=>$clients,'bootos'=>$bootos,'bootisos'=>$bootisos)); $editsession->populate($session2); $this->view->editsession = $editsession; @@ -63,11 +86,18 @@ class SessionController extends Zend_Controller_Action try{ $sessionID = $this->_request->getParam('sessionID'); - $editsession = new Application_Form_Session($_POST); + $editsession = new Application_Form_Session(array('clients'=>$clients,'bootos'=>$bootos,'bootisos'=>$bootisos),$_POST); if ($editsession->isValid($_POST)) { $session = new Application_Model_Session($_POST); - $session->setID($this->_request->getParam('sessionID')); + $session->setID($this->_request->getParam('sessionID')); + $session->setTime(strtotime($_POST['time'])); + if($session->getClientID() == ''){ + $session->setClientID(null); + } + if($session->getBootosID() == ''){ + $session->setBootosID(null); + } $sessionmapper = new Application_Model_SessionMapper(); $sessionmapper->save($session); echo 'valid'; |
