summaryrefslogtreecommitdiffstats
path: root/application/modules/dev
diff options
context:
space:
mode:
authormichael pereira2011-03-16 10:05:20 +0100
committermichael pereira2011-03-16 10:05:20 +0100
commitef1f634b2ec92107137c54e3af32de01135f02c9 (patch)
tree60a5523e14bf7c5831c419f9fc2bf667ebcf06ed /application/modules/dev
parentMerge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2 (diff)
downloadpbs2-ef1f634b2ec92107137c54e3af32de01135f02c9.tar.gz
pbs2-ef1f634b2ec92107137c54e3af32de01135f02c9.tar.xz
pbs2-ef1f634b2ec92107137c54e3af32de01135f02c9.zip
Ressource Controller setzt jetzt die Session fuer ausgewaehltes Bootmenuentry
Diffstat (limited to 'application/modules/dev')
-rw-r--r--application/modules/dev/controllers/ResourceController.php290
-rw-r--r--application/modules/dev/controllers/SessionController.php1
-rw-r--r--application/modules/dev/views/scripts/bootmenu/index.phtml13
-rw-r--r--application/modules/dev/views/scripts/resource/get-bootmenu-entry.phtml0
4 files changed, 142 insertions, 162 deletions
diff --git a/application/modules/dev/controllers/ResourceController.php b/application/modules/dev/controllers/ResourceController.php
index 3bd325f..defab76 100644
--- a/application/modules/dev/controllers/ResourceController.php
+++ b/application/modules/dev/controllers/ResourceController.php
@@ -3,181 +3,151 @@
class dev_ResourceController extends Zend_Controller_Action
{
-
- public function init()
- {
-
- }
-
- public function indexAction()
- {
-
-
- }
-
- public function getinitramfsAction()
- {
- $this->_helper->layout->disableLayout();
- $this->_helper->viewRenderer->setNoRender();
-
- $alphasessionID = $this->_request->getParam('alpha');
- $session = new Application_Model_Session();
- $sm = new Application_Model_SessionMapper();
- $result = $sm->findBy('alphasessionID',$alphasessionID);
- # print_a($result);
- $thisSession = $result[0];
- $bootosID = $thisSession['bootosID'];
-
- if(is_dir("../resources/bootos/$bootosID/initramfs/") && is_numeric($bootosID)){
-
- header('Content-Type: application/x-gzip');
- $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
- header('Content-Disposition: ' . $content_disp . '; filename="initramfs"');
- header('Pragma: no-cache');
- header('Expires: 0');
-
- // create the gzipped tarfile.
- chdir("../resources/bootos/$bootosID/initramfs/");
- passthru( "cat initramfs");
- }
- }
-
- public function getconfigAction()
- {
-
- $this->_helper->layout->disableLayout();
- $this->_helper->viewRenderer->setNoRender();
-
+ private $thisSession;
+
+ public function init()
+ {
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
$alphasessionID = $this->_request->getParam('alpha');
$session = new Application_Model_Session();
$sm = new Application_Model_SessionMapper();
$result = $sm->findBy('alphasessionID',$alphasessionID);
# print_a($result);
- $thisSession = $result[0];
- $bootmenuentryID = $thisSession['bootmenuentryID'];
-
+ $this->thisSession = $session->setOptions($result[0]);
+ $this->thisSession->setID($result[0]['sessionID']);
+ }
+
+ public function indexAction()
+ {
+
+
+ }
+
+ public function getinitramfsAction()
+ {
+
+ $bootosID = $this->thisSession->getBootosID();
+
+ if(is_dir("../resources/bootos/$bootosID/initramfs/") && is_numeric($bootosID)){
+
+ header('Content-Type: application/x-gzip');
+ $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
+ header('Content-Disposition: ' . $content_disp . '; filename="initramfs"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+
+ // create file.
+ chdir("../resources/bootos/$bootosID/initramfs/");
+ passthru( "cat initramfs");
+ }
+ }
+
+ public function getconfigAction()
+ {
+ $bootmenuentryID = $this->thisSession->getBootmenuentryID();
+
$bootmenuentry = new Application_Model_BootMenuEntries();
$bmm = new Application_Model_BootMenuEntriesMapper();
$bmm->find($bootmenuentryID,$bootmenuentry);
# print_a($bootmenuentry);
- $configID = $bootmenuentry->getConfigID();
-
- if(is_dir("../resources/config/$configID/config/") && is_numeric($configID)){
-
- header('Content-Type: application/x-gzip');
- $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
- header('Content-Disposition: ' . $content_disp . '; filename="config.tar.gz"');
- header('Pragma: no-cache');
- header('Expires: 0');
-
- // create the gzipped tarfile.
- chdir("../resources/config/$configID/config/");
- passthru( "tar cz ./");
- }
- }
-
- public function getkernelAction()
- {
- $this->_helper->layout->disableLayout();
- $this->_helper->viewRenderer->setNoRender();
-
- $alphasessionID = $this->_request->getParam('alpha');
- $session = new Application_Model_Session();
- $sm = new Application_Model_SessionMapper();
- $result = $sm->findBy('alphasessionID',$alphasessionID);
- # print_a($result);
- $thisSession = $result[0];
- $bootosID = $thisSession['bootosID'];
-
-
- if(is_dir("../resources/bootos/$bootosID/kernel/") && is_numeric($bootosID)){
-
- header('Content-Type: application/x-gzip');
- $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
- header('Content-Disposition: ' . $content_disp . '; filename="kernel"');
- header('Pragma: no-cache');
- header('Expires: 0');
-
- // create the gzipped tarfile.
- chdir("../resources/bootos/$bootosID/kernel/");
- passthru( "cat kernel");
- }
- }
-
- public function getkclAction()
- {
- $this->_helper->layout->disableLayout();
- $this->_helper->viewRenderer->setNoRender();
-
- $alphasessionID = $this->_request->getParam('alpha');
- $session = new Application_Model_Session();
- $sm = new Application_Model_SessionMapper();
- $result = $sm->findBy('alphasessionID',$alphasessionID);
- # print_a($result);
- $thisSession = $result[0];
- $bmeID = $thisSession['bootmenuentryID'];
- if(is_numeric($bmeID)){
- $bmemapper = new Application_Model_BootMenuEntriesMapper();
+ $configID = $bootmenuentry->getConfigID();
+
+ if(is_dir("../resources/config/$configID/config/") && is_numeric($configID)){
+
+ header('Content-Type: application/x-gzip');
+ $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
+ header('Content-Disposition: ' . $content_disp . '; filename="config.tar.gz"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+
+ // create the gzipped tarfile.
+ chdir("../resources/config/$configID/config/");
+ passthru( "tar cz ./");
+ }
+ }
+
+ public function getkernelAction()
+ {
+ $bootosID = $this->thisSession->getBootosID();
+
+ if(is_dir("../resources/bootos/$bootosID/kernel/") && is_numeric($bootosID)){
+
+ header('Content-Type: application/x-gzip');
+ $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
+ header('Content-Disposition: ' . $content_disp . '; filename="kernel"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+
+ // create the gzipped tarfile.
+ chdir("../resources/bootos/$bootosID/kernel/");
+ passthru( "cat kernel");
+ }
+ }
+
+ public function getkclAction()
+ {
+ $bmeID = $this->thisSession->getBootmenuentryID();
+
+ if(is_numeric($bmeID)){
+
+ $bmemapper = new Application_Model_BootMenuEntriesMapper();
$bme = new Application_Model_BootMenuEntries();
$bmemapper->find($bmeID,$bme);
-
+
if($bme->getKcl() != null){
header('Content-Type: text/html');
- $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
- header('Content-Disposition: ' . $content_disp . '; filename="kcl.txt"');
- header('Pragma: no-cache');
- header('Expires: 0');
- echo $bme->getKcl();
+ $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
+ header('Content-Disposition: ' . $content_disp . '; filename="kcl.txt"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+ echo $bme->getKcl();
}
-
- }
-
- }
-
- public function getbootmenuentryAction()
- {
- // obsolete function (now only for debugging)
- // after selecting the BootOS it will be saved in session
- // so getkclAction, getkernelAction, getconfigAction and getinitramfsAction
- // can be called with session-identifier
-
- $this->_helper->layout->disableLayout();
- $this->_helper->viewRenderer->setNoRender();
-
- $bmeID = $this->_request->getParam('bootmenuentryID');
- $bmeID = 4;
-
- if(isset($_SESSION['alphasessionID'])){
- $sessionmapper = new Application_Model_SessionMapper();
- $session = $sessionmapper->findBy('alphasessionID',$_SESSION['alphasessionID']);
- $session = $session[0];
- if($session['bootmenuentryID'] != null){
- $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"),
- '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')
- );
- }
- }
-
- }
-
- function generateURL($action, $varname, $varvalue, $filename){
- $path = '/resource/'. $action .'/' . $varname .'/' . $varvalue .'/file/' . $filename ;
- $path = "http://" . $_SERVER['SERVER_NAME'] . $path;
- return $path;
- }
+
+ }
+
+ }
+
+ public function getbootmenuentryAction()
+ {
+ // obsolete function (now only for debugging)
+ // 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');
+ $bootosID = $this->_request->getParam('bootosID');
+
+ $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')
+ );
+ }
+ }
+
+ private function generateURL($action, $varname, $varvalue, $filename){
+ $path = '/dev/resource/'. $action .'/' . $varname .'/' . $varvalue .'/file/' . $filename ;
+ $path = "http://" . $_SERVER['SERVER_NAME'] . $path;
+ return $path;
+ }
}
diff --git a/application/modules/dev/controllers/SessionController.php b/application/modules/dev/controllers/SessionController.php
index bb92da9..9686d1d 100644
--- a/application/modules/dev/controllers/SessionController.php
+++ b/application/modules/dev/controllers/SessionController.php
@@ -129,6 +129,7 @@ class dev_SessionController extends Zend_Controller_Action
$editsession = new dev_Form_Session(array('buttontext' => 'Edit Session','bootmenuentries'=>$bootmenuentries,'clients'=>$clients,'bootos'=>$bootos,'bootisos'=>$bootisos,'memberships'=>$memberships),$_POST);
if ($editsession->isValid($_POST)) {
+ $_SESSION['alphasessionID'] = $_POST['alphasessionID'];
$session = new Application_Model_Session($_POST);
$session->setID($this->_request->getParam('sessionID'));
$session->setTime(strtotime($_POST['time']));
diff --git a/application/modules/dev/views/scripts/bootmenu/index.phtml b/application/modules/dev/views/scripts/bootmenu/index.phtml
index b29a5cc..c42a09a 100644
--- a/application/modules/dev/views/scripts/bootmenu/index.phtml
+++ b/application/modules/dev/views/scripts/bootmenu/index.phtml
@@ -75,8 +75,17 @@
<?php $config = $this->configmapper->find($bootmenuentry->getConfigID());?>
<tr>
<td class='action'>
- <a href='/dev/resource/getbootmenuentry/bootmenuentryID/<?php echo $bootmenuentry->getID();?>'>
- <img src='/media/img/play.gif'>
+ <a href="<?php echo $this->url(
+ array(
+ 'module' => 'dev',
+ 'controller' => 'resource',
+ 'action' => 'getbootmenuentry',
+ 'bootmenuentryID' => $bootmenuentry->getID(),
+ 'bootosID' => $bootmenuentry->getBootosID(),
+ 'alpha' => $_SESSION['alphasessionID']
+ ),
+ 'default',
+ true, false) ?>"><img src='/media/img/play.gif'>
</a>
</td>
<td><?php echo $this->escape($bootmenuentry->getID()); ?></td>
diff --git a/application/modules/dev/views/scripts/resource/get-bootmenu-entry.phtml b/application/modules/dev/views/scripts/resource/get-bootmenu-entry.phtml
deleted file mode 100644
index e69de29..0000000
--- a/application/modules/dev/views/scripts/resource/get-bootmenu-entry.phtml
+++ /dev/null