summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/controllers/SessionController.php36
-rw-r--r--application/forms/Session.php20
-rw-r--r--application/models/Session.php20
-rw-r--r--application/models/SessionMapper.php9
-rw-r--r--application/views/scripts/session/index.phtml2
5 files changed, 78 insertions, 9 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);
diff --git a/application/forms/Session.php b/application/forms/Session.php
index f2175a7..0a7c3ae 100644
--- a/application/forms/Session.php
+++ b/application/forms/Session.php
@@ -11,6 +11,15 @@ class Application_Form_Session extends Zend_Form
{
$this->setName("session");
$this->setMethod('post');
+
+ $this->addElement('text', 'aphasessionID', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 16)),
+ ),
+ 'required' => false,
+ 'label' => 'alphasessionID:',
+ ));
$clientfield = $this->createElement('select','clientID');
$clientfield ->setLabel('Client:');
@@ -23,6 +32,17 @@ class Application_Form_Session extends Zend_Form
$clientfield->setRegisterInArrayValidator(false);
$this->addElement($clientfield);
+ $bootmenuentrieyfield = $this->createElement('select','bootmenuentryID');
+ $bootmenuentrieyfield->setLabel('BootmenuentryID:');
+ $bootmenuentrieyfield->addMultiOption('','');
+ if(count($this->bootmenuentries)>0){
+ foreach($this->bootmenuentries as $id => $g){
+ $bootmenuentrieyfield->addMultiOption($g->getID(), $g->getTitle());
+ }
+ }
+ $bootmenuentrieyfield->setRegisterInArrayValidator(false);
+ $this->addElement($bootmenuentrieyfield);
+
$bootosfield = $this->createElement('select','bootosID');
$bootosfield ->setLabel('BootOs:');
diff --git a/application/models/Session.php b/application/models/Session.php
index ca07ccb..7ae7fe8 100644
--- a/application/models/Session.php
+++ b/application/models/Session.php
@@ -3,7 +3,9 @@
class Application_Model_Session
{
protected $_sessionID;
+ protected $_alphasessionID;
protected $_clientID;
+ protected $_bootmenuentryID;
protected $_bootosID;
protected $_bootisoID;
protected $_time;
@@ -57,6 +59,15 @@ class Application_Model_Session
$this->_sessionID = $_sessionID;
return $this;
}
+ public function getAlphasessionID()
+ {
+ return $this->_alphasessionID;
+ }
+ public function setAlphasessionID($_alphasessionID)
+ {
+ $this->_alphasessionID = $_alphasessionID;
+ return $this;
+ }
public function getClientID()
{
return $this->_clientID;
@@ -66,6 +77,15 @@ class Application_Model_Session
$this->_clientID = $_clientID;
return $this;
}
+ public function getBootmenuentryID()
+ {
+ return $this->_bootmenuentryID;
+ }
+ public function setBootmenuentryID($_bootmenuentryID)
+ {
+ $this->_bootmenuentryID = $_bootmenuentryID;
+ return $this;
+ }
public function getBootosID()
{
return $this->_bootosID;
diff --git a/application/models/SessionMapper.php b/application/models/SessionMapper.php
index f836643..04496a2 100644
--- a/application/models/SessionMapper.php
+++ b/application/models/SessionMapper.php
@@ -48,13 +48,14 @@ class Application_Model_SessionMapper
{
$data = array( 'sessionID'=> $session->getID() ,
+ 'alphasessionID'=> $session->getAlphasessionID(),
'clientID'=> $session->getClientID() ,
+ 'bootmenuentryID'=> $session->getBootmenuentryID(),
'bootosID'=> $session->getBootosID() ,
'bootisoID'=> $session->getBootisoID() ,
'time'=> $session->getTime() ,
'ip'=> $session->getIp() ,
- 'ip6'=> $session->getIp6() );
- print_a($data);
+ 'ip6'=> $session->getIp6() );
if (null === ($id = $session->getID()) ) {
unset($data['sessionID']);
$this->getDbTable()->insert($data);
@@ -81,7 +82,7 @@ class Application_Model_SessionMapper
$row = $result->current();
- $sesion->setID($row->sessionID)->setClientID($row->clientID)->setBootosID($row->bootosID)->setBootisoID($row->bootisoID)->setTime($row->time)->setIp($row->ip)->setIp6($row->ip6);
+ $sesion->setID($row->sessionID)->setAlphasessionID($row->alphasessionID)->setClientID($row->clientID)->setBootmenuentryID($row->bootmenuentryID)->setBootosID($row->bootosID)->setBootisoID($row->bootisoID)->setTime($row->time)->setIp($row->ip)->setIp6($row->ip6);
}
public function fetchAll()
@@ -91,7 +92,7 @@ class Application_Model_SessionMapper
foreach ($resultSet as $row) {
$entry = new Application_Model_Session();
- $entry->setID($row->sessionID)->setClientID($row->clientID)->setBootosID($row->bootosID)->setBootisoID($row->bootisoID)->setTime($row->time)->setIp($row->ip)->setIp6($row->ip6);
+ $entry->setID($row->sessionID)->setAlphasessionID($row->alphasessionID)->setClientID($row->clientID)->setBootmenuentryID($row->bootmenuentryID)->setBootosID($row->bootosID)->setBootisoID($row->bootisoID)->setTime($row->time)->setIp($row->ip)->setIp6($row->ip6);
$entries[] = $entry;
}
diff --git a/application/views/scripts/session/index.phtml b/application/views/scripts/session/index.phtml
index 6e87acf..8d50dd2 100644
--- a/application/views/scripts/session/index.phtml
+++ b/application/views/scripts/session/index.phtml
@@ -16,7 +16,9 @@
<?php foreach ($this->sessions as $session): ?>
<tr class=entry>
<td><?php echo $this->escape($session->getID()) ?></td>
+ <td><?php echo $this->escape($session->getalphasessionID()) ?></td>
<td><?php echo $this->escape($session->getClientID()) ?></td>
+ <td><?php echo $this->escape($session->getBootmenuentryID()) ?></td>
<td><?php echo $this->escape($session->getBootosID()) ?></td>
<td><?php echo $this->escape($session->getBootisoID()) ?></td>
<td><?php echo date('d.m.Y H:i',$this->escape($session->getTime())) ?></td>