summaryrefslogtreecommitdiffstats
path: root/application/controllers/SessionController.php
diff options
context:
space:
mode:
authorSimon2011-03-08 16:40:30 +0100
committerSimon2011-03-08 16:40:30 +0100
commit90daca1a5ec239dfb7f44e54f1c22cf299181143 (patch)
treea8e91fd36e90e8a5dcedfcaeaa92099b5ca962f8 /application/controllers/SessionController.php
parentsession hinzugefügt (diff)
downloadpbs2-90daca1a5ec239dfb7f44e54f1c22cf299181143.tar.gz
pbs2-90daca1a5ec239dfb7f44e54f1c22cf299181143.tar.xz
pbs2-90daca1a5ec239dfb7f44e54f1c22cf299181143.zip
create, edit, delete session - fehlt noch mit selectboxen && sql-data abgeändert
Diffstat (limited to 'application/controllers/SessionController.php')
-rw-r--r--application/controllers/SessionController.php74
1 files changed, 70 insertions, 4 deletions
diff --git a/application/controllers/SessionController.php b/application/controllers/SessionController.php
index 382e68e..fc3b962 100644
--- a/application/controllers/SessionController.php
+++ b/application/controllers/SessionController.php
@@ -10,22 +10,88 @@ class SessionController extends Zend_Controller_Action
public function indexAction()
{
- // action body
+ $mapper = new Application_Model_SessionMapper();
+ $this->view->sessions = $mapper->fetchAll();
}
public function createsessionAction()
{
- // action body
+ 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()
{
- // action body
+ 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()
{
- // action body
+ $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');
}