diff options
| author | michael pereira | 2011-03-08 19:41:07 +0100 |
|---|---|---|
| committer | michael pereira | 2011-03-08 19:41:07 +0100 |
| commit | 6a917fa16d4aabd8e69e1db08867899c860424e1 (patch) | |
| tree | 5aee03f6bf1810ec340110df55fd1edacf44f592 /application/controllers/SessionController.php | |
| parent | BootOs Name anzeigen & Reihenfolge im BootMenu (diff) | |
| parent | ansehnlichere oberfläche && Controller auflistung (diff) | |
| download | pbs2-6a917fa16d4aabd8e69e1db08867899c860424e1.tar.gz pbs2-6a917fa16d4aabd8e69e1db08867899c860424e1.tar.xz pbs2-6a917fa16d4aabd8e69e1db08867899c860424e1.zip | |
Merge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2
Diffstat (limited to 'application/controllers/SessionController.php')
| -rw-r--r-- | application/controllers/SessionController.php | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/application/controllers/SessionController.php b/application/controllers/SessionController.php new file mode 100644 index 0000000..fc3b962 --- /dev/null +++ b/application/controllers/SessionController.php @@ -0,0 +1,105 @@ +<?php + +class SessionController extends Zend_Controller_Action +{ + + public function init() + { + /* Initialize action controller here */ + } + + public function indexAction() + { + $mapper = new Application_Model_SessionMapper(); + $this->view->sessions = $mapper->fetchAll(); + } + + public function createsessionAction() + { + if (!isset($_POST["add"])){ + $createsession = new Application_Form_Session(); + $this->view->createsession = $createsession; + }else { + $createsession = new Application_Form_Session($_POST); + print_a($_POST); + if ($createsession->isValid($_POST)) { + try{ + $session = new Application_Model_Session($_POST); + $sessionmapper = new Application_Model_SessionMapper(); + $sessionmapper->save($session); + + $this->_redirect('/session'); + + }catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + print_a('saved'); + $this->_redirect('/session'); + } + else{ + print_a('not saved'); + } + } + } + + public function editsessionAction() + { + if (!isset($_POST["add"])){ + // TODO: ACL implementieren ob er editieren darf + $sessionID = $this->_request->getParam('sessionID'); + $session = new Application_Model_Session(); + + + $sessionmapper = new Application_Model_SessionMapper(); + $sessionmapper->find($sessionID,$session); + $session2 = $session->toArray(); + + $editsession = new Application_Form_Session(); + $editsession->populate($session2); + $this->view->editsession = $editsession; + + } else{ + try{ + $sessionID = $this->_request->getParam('sessionID'); + + $editsession = new Application_Form_Session($_POST); + + if ($editsession->isValid($_POST)) { + $session = new Application_Model_Session($_POST); + $session->setID($this->_request->getParam('sessionID')); + $sessionmapper = new Application_Model_SessionMapper(); + $sessionmapper->save($session); + echo 'valid'; + } + else + { + echo 'not valid'; + } + }catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + $this->_redirect('/session'); + } + } + + public function deletesessionAction() + { + $sessionID = $this->_request->getParam('sessionID'); + if(is_numeric($sessionID)){ + $deletesession = new Application_Model_Session(); + $deletesession->setID($sessionID); + $sessionmapper = new Application_Model_SessionMapper(); + $sessionmapper->delete($deletesession); + } + $this->_redirect('/session'); + } + + +} + + + + + + + |
