diff options
Diffstat (limited to 'application/controllers')
| -rw-r--r-- | application/controllers/SessionController.php | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/application/controllers/SessionController.php b/application/controllers/SessionController.php index 6d0a873..f21335d 100644 --- a/application/controllers/SessionController.php +++ b/application/controllers/SessionController.php @@ -12,7 +12,14 @@ class SessionController extends Zend_Controller_Action { $mapper = new Application_Model_SessionMapper(); $this->view->sessions = $mapper->fetchAll(); + print_a($_SESSION); } + private function getUniqueCode($length = "") + { + $code = md5(uniqid(rand(), true)); + if ($length != "") return substr($code, 0, $length); + else return $code; + } public function createsessionAction() { @@ -25,17 +32,32 @@ class SessionController extends Zend_Controller_Action $bi = new Application_Model_BootIsoMapper(); $bootisos = $bi->fetchAll(); + $bmem = new Application_Model_SessionMapper(); + $bootmenuentries = $bmem->fetchAll(); + + if (!isset($_POST["add"])){ - $createsession = new Application_Form_Session(array('buttontext' => 'Create Session','clients'=>$clients,'bootos'=>$bootos,'bootisos'=>$bootisos)); + $createsession = new Application_Form_Session(array('buttontext' => 'Create Session','bootmenuentries'=>$bootmenuentries,'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(array('buttontext' => 'Create Session','clients'=>$clients,'bootos'=>$bootos,'bootisos'=>$bootisos),$_POST); + $createsession = new Application_Form_Session(array('buttontext' => 'Create Session','bootmenuentries'=>$bootmenuentries,'clients'=>$clients,'bootos'=>$bootos,'bootisos'=>$bootisos),$_POST); print_a($_POST); if ($createsession->isValid($_POST)) { try{ + $uniqid = $this->getUniqueCode(10); + $sm = new Application_Model_SessionMapper(); + while(count($sm->findBy('alphasessionID',$uniqid))>0){ + $uniqid = $this->getUniqueCode(16); + } + $session = new Application_Model_Session($_POST); $session->setTime(strtotime($_POST['time'])); + $session->setAlphasessionID($uniqid); + + // UNIQUE ID IN SESSION SPEICHERN: + $_SESSION['alphasessionID'] = $uniqid; + if($session->getClientID() == ''){ $session->setClientID(null); } @@ -65,6 +87,10 @@ class SessionController extends Zend_Controller_Action $bi = new Application_Model_BootIsoMapper(); $bootisos = $bi->fetchAll(); + + $bmem = new Application_Model_SessionMapper(); + $bootmenuentries = $bmem->fetchAll(); + if (!isset($_POST["add"])){ // TODO: ACL implementieren ob er editieren darf $sessionID = $this->_request->getParam('sessionID'); @@ -76,7 +102,7 @@ class SessionController extends Zend_Controller_Action $session->setTime(date('d.m.Y H:i',$session->getTime())); $session2 = $session->toArray(); - $editsession = new Application_Form_Session(array('buttontext' => 'Edit Session','clients'=>$clients,'bootos'=>$bootos,'bootisos'=>$bootisos)); + $editsession = new Application_Form_Session(array('buttontext' => 'Edit Session','bootmenuentries'=>$bootmenuentries,'clients'=>$clients,'bootos'=>$bootos,'bootisos'=>$bootisos)); $editsession->populate($session2); $this->view->editsession = $editsession; @@ -84,11 +110,11 @@ class SessionController extends Zend_Controller_Action try{ $sessionID = $this->_request->getParam('sessionID'); - $editsession = new Application_Form_Session(array('buttontext' => 'Edit Session','clients'=>$clients,'bootos'=>$bootos,'bootisos'=>$bootisos),$_POST); + $editsession = new Application_Form_Session(array('buttontext' => 'Edit Session','bootmenuentries'=>$bootmenuentries,'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); |
