summaryrefslogtreecommitdiffstats
path: root/application/controllers/SessionController.php
diff options
context:
space:
mode:
authormichael pereira2011-03-09 20:54:27 +0100
committermichael pereira2011-03-09 20:54:27 +0100
commitfbff9df0469ee998389fa263d8638cc3bf3618b5 (patch)
tree04adfd6a021e574055469ce6d0469988cb4684bd /application/controllers/SessionController.php
parentKCL und BootMenuFilter (diff)
parentFilterController Evaluate funktioniert (diff)
downloadpbs2-fbff9df0469ee998389fa263d8638cc3bf3618b5.tar.gz
pbs2-fbff9df0469ee998389fa263d8638cc3bf3618b5.tar.xz
pbs2-fbff9df0469ee998389fa263d8638cc3bf3618b5.zip
Merge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2
Diffstat (limited to 'application/controllers/SessionController.php')
-rw-r--r--application/controllers/SessionController.php51
1 files changed, 41 insertions, 10 deletions
diff --git a/application/controllers/SessionController.php b/application/controllers/SessionController.php
index fc3b962..09eadc9 100644
--- a/application/controllers/SessionController.php
+++ b/application/controllers/SessionController.php
@@ -16,15 +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 {
- $createsession = new Application_Form_Session($_POST);
+ // TODO extend with normal function not only with 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);
@@ -34,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');
@@ -51,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;
@@ -62,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';