From 7a774686bbb10c092854182823126466c0c62d99 Mon Sep 17 00:00:00 2001 From: michael pereira Date: Mon, 4 Apr 2011 03:43:23 +0200 Subject: getRessources bei play wird angezeigt --- application/controllers/ResourceController.php | 85 +++++++++++++++----------- 1 file changed, 48 insertions(+), 37 deletions(-) (limited to 'application/controllers/ResourceController.php') diff --git a/application/controllers/ResourceController.php b/application/controllers/ResourceController.php index 563a603..e36c75a 100644 --- a/application/controllers/ResourceController.php +++ b/application/controllers/ResourceController.php @@ -4,21 +4,46 @@ class ResourceController extends Zend_Controller_Action { private $thisSession; + private $page; public function init() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); - //TODO Error Messages if something failed - - $alphasessionID = $this->_request->getParam('alpha'); $session = new Application_Model_Session(); $sm = new Application_Model_SessionMapper(); - $result = $sm->findBy('alphasessionID',$alphasessionID); - # print_a($result); - $this->thisSession = $session->setOptions($result[0]); - $this->thisSession->setID($result[0]['sessionID']); + + $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); + //TODO Error Messages if something failed + if(!isset($bootmenuentryID)){ + $alphasessionID = $this->_request->getParam('alpha'); + $result = $sm->findBy('alphasessionID',$alphasessionID); + # print_a($result); + $this->thisSession = $session->setOptions($result[0]); + $this->thisSession->setID($result[0]['sessionID']); + } + else{ + $this->page = $this->_request->getParam('page'); + $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); + if(!is_numeric($bootmenuentryID)) + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/json/error'); + + $bootmenuentry = new Application_Model_BootMenuEntries(); + $bootmenuentryMapper = new Application_Model_BootMenuEntriesMapper(); + + $bootmenuentryMapper->find($bootmenuentryID, $bootmenuentry); + + $n = new Pbs_Session(); + + $session->setBootosID($bootmenuentry->getBootosID()) + ->setBootmenuentryID($bootmenuentry->getID()) + ->setTime(time()) + ->setIp($_SERVER['REMOTE_ADDR']); + + $this->thisSession = $n->createSession($session); + } + } public function indexAction() @@ -127,39 +152,25 @@ class ResourceController extends Zend_Controller_Action // after selecting the BootOS it will be saved in session // so getkclAction, getkernelAction, getconfigAction and getinitramfsAction // can be called with session-identifier - $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); - - $bootmenuentryMapper = new Application_Model_BootMenuEntriesMapper(); - $bootmenuentry = new Application_Model_BootMenuEntries(); - $bootmenuentryMapper->find($bootmenuentryID, $bootmenuentry); - $bootosID = $bootmenuentry->getBootosID(); - - $this->thisSession->setBootosID($bootosID)->setBootmenuentryID($bootmenuentryID); - $sessionMapper = new Application_Model_SessionMapper(); - $sessionMapper->save($this->thisSession); - - if($this->thisSession->getBootmenuentryID() != null){ - header('Content-Type: application/json'); - $return_val = - array( - 'info' => 'This function is for debugging purpose only', - 'kernel' => $this->generateURL('getkernel', 'alpha', $_SESSION['alphasessionID'], "kernel"), - 'initramfs' => $this->generateURL('getinitramfs', 'alpha', $_SESSION['alphasessionID'], "initramfs"), - 'kcl' => $this->generateURL('getkcl', 'alpha', $_SESSION['alphasessionID'], "kcl.txt"), - 'config' => $_SESSION['alphasessionID'] - ); - echo json_encode($return_val); - } - else{ - echo json_encode( - array( 'info' => 'This function is for debugging purpose only', - 'error'=> 'your session is out of date') - ); - } + + header('Content-Type: application/json'); + $return_val = + array( + 'info' => 'This function is for debugging purpose only', + 'kernel' => $this->generateURL('getkernel', 'alpha', $this->thisSession->getAlphasessionID(), "kernel"), + 'initramfs' => $this->generateURL('getinitramfs', 'alpha', $this->thisSession->getAlphasessionID(), "initramfs"), + 'kcl' => $this->generateURL('getkcl', 'alpha', $this->thisSession->getAlphasessionID(), "kcl.txt"), + 'config' => $this->thisSession->getAlphasessionID() + ); + + + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/json/'.json_encode($return_val)); + + } private function generateURL($action, $varname, $varvalue, $filename){ - $path = '/dev/resource/'. $action .'/' . $varname .'/' . $varvalue .'/file/' . $filename ; + $path = '/resource/'. $action .'/' . $varname .'/' . $varvalue .'/file/' . $filename ; $path = "http://" . $_SERVER['SERVER_NAME'] . $path; return $path; } -- cgit v1.2.3-55-g7522