summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorSimon2011-03-09 20:49:24 +0100
committerSimon2011-03-09 20:49:24 +0100
commit5767c4f644a586d5f19e86fdd2de2ad47a21cb1a (patch)
tree116914ccf6a4bf492b74682c2fea717e4c4f92e1 /application
parentstyle angepasst (diff)
downloadpbs2-5767c4f644a586d5f19e86fdd2de2ad47a21cb1a.tar.gz
pbs2-5767c4f644a586d5f19e86fdd2de2ad47a21cb1a.tar.xz
pbs2-5767c4f644a586d5f19e86fdd2de2ad47a21cb1a.zip
FilterController Evaluate funktioniert
Diffstat (limited to 'application')
-rw-r--r--application/Bootstrap.php1
-rw-r--r--application/controllers/FilterController.php139
-rw-r--r--application/controllers/SessionController.php50
-rw-r--r--application/forms/Session.php71
-rw-r--r--application/layouts/main.phtml3
-rw-r--r--application/views/scripts/filter/index.phtml4
-rw-r--r--application/views/scripts/session/index.phtml2
7 files changed, 174 insertions, 96 deletions
diff --git a/application/Bootstrap.php b/application/Bootstrap.php
index c286ad1..f0fe7d3 100644
--- a/application/Bootstrap.php
+++ b/application/Bootstrap.php
@@ -22,7 +22,6 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
$view->doctype('XHTML1_STRICT');
$view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
$view->headLink()->appendStylesheet('/media/css/style.css');
- $view->headTitle()->setSeparator(' - ');
$view->headTitle('pbs²')
->setSeparator(' :: ');
}
diff --git a/application/controllers/FilterController.php b/application/controllers/FilterController.php
index d17aceb..9141e10 100644
--- a/application/controllers/FilterController.php
+++ b/application/controllers/FilterController.php
@@ -316,15 +316,18 @@ class FilterController extends Zend_Controller_Action
$clientmapper->find($session->getClientID(),$client);
$macAdress = $client->getMacadress();
}
- $macAdress = str_replace(":","",$this->fillMac($ipAdress));
- $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE
- filtertypeID = ".$filtertypID." AND
- CONV(HEX('filtervalue'),16,10) <= CONV(HEX('".$macAdress."'),16,10) AND
- CONV(HEX('".$macAdress."'),16,10) <= CONV(HEX('filtervalue2'),16,10)");
- $result = $stmt->fetchAll();
- foreach($result as $r){
- $set[$filtertypID][] = $r['filterID'];
+ try{
+ $macAdress = str_replace(":","",$this->fillMac($ipAdress));
+ $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE
+ filtertypeID = ".$filtertypID." AND
+ CONV(HEX('filtervalue'),16,10) <= CONV(HEX('".$macAdress."'),16,10) AND
+ CONV(HEX('".$macAdress."'),16,10) <= CONV(HEX('filtervalue2'),16,10)");
+ $result = $stmt->fetchAll();
+ foreach($result as $r){
+ $set[$filtertypID][] = $r['filterID'];
+ }
}
+ catch(Exception $e){}
if($showPartResults)
print_a('macAdress',$result,$set[$filtertypID]);
@@ -341,16 +344,18 @@ class FilterController extends Zend_Controller_Action
$poolID = $poolentry['poolID'];
}
-
- $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE
- filtertypeID = ".$filtertypID." AND
- filtervalue = ".$poolID." ");
- $result = $stmt->fetchAll();
- if(count($result)>0){
- foreach($result as $r){
- $set[$filtertypID][] = $r['filterID'];
+ try{
+ $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE
+ filtertypeID = ".$filtertypID." AND
+ filtervalue = ".$poolID." ");
+ $result = $stmt->fetchAll();
+ if(count($result)>0){
+ foreach($result as $r){
+ $set[$filtertypID][] = $r['filterID'];
+ }
}
}
+ catch(Exception $e){}
if($showPartResults)
print_a('poolID',$result,$set[$filtertypID]);
@@ -362,14 +367,16 @@ class FilterController extends Zend_Controller_Action
if(!$testFilter){
$clientID = $session->getClientID();
}
-
- $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE
- filtertypeID = ".$filtertypID." AND
- filtervalue = ".$clientID." ");
- $result = $stmt->fetchAll();
- foreach($result as $r){
- $set[$filtertypID][] = $r['filterID'];
+ try{
+ $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE
+ filtertypeID = ".$filtertypID." AND
+ filtervalue = ".$clientID." ");
+ $result = $stmt->fetchAll();
+ foreach($result as $r){
+ $set[$filtertypID][] = $r['filterID'];
+ }
}
+ catch(Exception $e){}
if($showPartResults)
print_a('clientID',$result,$set[$filtertypID]);
@@ -380,14 +387,16 @@ class FilterController extends Zend_Controller_Action
if(!$testFilter){
$bootisoID = $session->getBootisoID();
}
-
- $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE
- filtertypeID = ".$filtertypID." AND
- filtervalue = ".$bootisoID." ");
- $result = $stmt->fetchAll();
- foreach($result as $r){
- $set[$filtertypID][] = $r['filterID'];
+ try{
+ $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE
+ filtertypeID = ".$filtertypID." AND
+ filtervalue = ".$bootisoID." ");
+ $result = $stmt->fetchAll();
+ foreach($result as $r){
+ $set[$filtertypID][] = $r['filterID'];
+ }
}
+ catch(Exception $e){}
if($showPartResults)
print_a('bootisoID',$result,$set[$filtertypID]);
@@ -400,14 +409,16 @@ class FilterController extends Zend_Controller_Action
//TODO: GET MEMBERSHIP from SESSION
$membershipID = 1;
}
-
- $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE
- filtertypeID = ".$filtertypID." AND
- filtervalue = ".$membershipID." ");
- $result = $stmt->fetchAll();
- foreach($result as $r){
- $set[$filtertypID][] = $r['filterID'];
+ try{
+ $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE
+ filtertypeID = ".$filtertypID." AND
+ filtervalue = ".$membershipID." ");
+ $result = $stmt->fetchAll();
+ foreach($result as $r){
+ $set[$filtertypID][] = $r['filterID'];
+ }
}
+ catch(Exception $e){}
if($showPartResults)
print_a('membership',$result,$set[$filtertypID]);
@@ -420,14 +431,16 @@ class FilterController extends Zend_Controller_Action
//TODO: GET GROUP from SESSION
$groupID = 1;
}
-
- $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE
- filtertypeID = ".$filtertypID." AND
- filtervalue = ".$groupID." ");
- $result = $stmt->fetchAll();
- foreach($result as $r){
- $set[$filtertypID][] = $r['filterID'];
+ try{
+ $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE
+ filtertypeID = ".$filtertypID." AND
+ filtervalue = ".$groupID." ");
+ $result = $stmt->fetchAll();
+ foreach($result as $r){
+ $set[$filtertypID][] = $r['filterID'];
+ }
}
+ catch(Exception $e){}
if($showPartResults)
print_a('membership',$result,$set[$filtertypID]);
@@ -443,19 +456,21 @@ class FilterController extends Zend_Controller_Action
$nowShort = str_replace("-","",$nowShort);
$nowLong = str_replace("-","",$nowLong);
-
- $select = $db->select()
- ->from(array('pbs_filterentries')
- )
- ->where('filtertypeID = ?',$filtertypID)
- ->where('REPLACE(filtervalue,"-","") <= ? AND ? <= REPLACE(filtervalue2,"-","")',$nowShort)
- ->orWhere('REPLACE(filtervalue,"-","") <= ? AND ? <= REPLACE(filtervalue2,"-","")',$nowLong);
+ try{
+ $select = $db->select()
+ ->from(array('pbs_filterentries')
+ )
+ ->where('filtertypeID = ?',$filtertypID)
+ ->where('REPLACE(filtervalue,"-","") <= ? AND ? <= REPLACE(filtervalue2,"-","")',$nowShort)
+ ->orWhere('REPLACE(filtervalue,"-","") <= ? AND ? <= REPLACE(filtervalue2,"-","")',$nowLong);
- $stmt = $select->query();
- $result = $stmt->fetchAll();
- foreach($result as $r){
- $set[$filtertypID][] = $r['filterID'];
+ $stmt = $select->query();
+ $result = $stmt->fetchAll();
+ foreach($result as $r){
+ $set[$filtertypID][] = $r['filterID'];
+ }
}
+ catch(Exception $e){}
if($showPartResults)
print_a('time',$result,$set[$filtertypID]);
@@ -511,9 +526,16 @@ class FilterController extends Zend_Controller_Action
}
catch(Exception $e){
}
+ if($bootmenuID != 'null'){
+ $bm = new Application_Model_BootMenu();
+ $bmmapper = new Application_Model_BootMenuMapper();
+ $bmmapper->find($bootmenuID,$bm);
+ echo "<h1><a href='/bootmenu/index/bootmenuID/".$bootmenuID."'>Goto BootmenuID: ".$bootmenuID."</a></h1>";
+ }
+ else{
+ echo "<h1>No Result :-(</h1>";
+ }
- echo "<h1>Redirected BootmenuID: ".$bootmenuID."</h1>";
-
}catch (Zend_Exception $e) {
echo "class: ".get_class($e)."<br>\n";
echo "Error message 2: " . $e->getMessage() . "\n";
@@ -542,7 +564,8 @@ class FilterController extends Zend_Controller_Action
'bootisos' => $bootisos,
'memberships' => $memberships,
'groups' => $groups,
- 'clients' => $clients
+ 'clients' => $clients,
+
));
$this->view->filterevaluate = $filterevaluate;
}
diff --git a/application/controllers/SessionController.php b/application/controllers/SessionController.php
index 21f94fa..09eadc9 100644
--- a/application/controllers/SessionController.php
+++ b/application/controllers/SessionController.php
@@ -16,16 +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 {
// TODO extend with normal function not only with post
- $createsession = new Application_Form_Session($_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);
@@ -35,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');
@@ -52,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;
@@ -63,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';
diff --git a/application/forms/Session.php b/application/forms/Session.php
index f094676..30aefda 100644
--- a/application/forms/Session.php
+++ b/application/forms/Session.php
@@ -3,36 +3,48 @@
class Application_Form_Session extends Zend_Form
{
+ private $clients;
+ private $bootos;
+ private $bootisos;
+
public function init()
{
$this->setName("session");
$this->setMethod('post');
- $this->addElement('text', 'clientID', array(
- 'filters' => array('StringTrim'),
- 'validators' => array(
- array('StringLength', false, array(0, 50)),
- ),
- 'required' => true,
- 'label' => 'clientID:',
- ));
+ $clientfield = $this->createElement('select','clientID');
+ $clientfield ->setLabel('Client:');
+ $clientfield->addMultiOption('','');
+ if(count($this->clients)>0){
+ foreach($this->clients as $id => $g){
+ $clientfield->addMultiOption($g->getID(), $g->getMacadress());
+ }
+ }
+ $clientfield->setRegisterInArrayValidator(false);
+ $this->addElement($clientfield);
+
+
+ $bootosfield = $this->createElement('select','bootosID');
+ $bootosfield ->setLabel('BootOs:');
+ $bootosfield->addMultiOption('','');
+ if(count($this->bootos)>0){
+ foreach($this->bootos as $id => $g){
+ $bootosfield->addMultiOption($g->getID(), $g->getTitle());
+ }
+ }
+ $bootosfield->setRegisterInArrayValidator(false);
+ $this->addElement($bootosfield);
+
+ $bootisofield = $this->createElement('select','bootisoID');
+ $bootisofield ->setLabel('BootIso:');
+ if(count($this->bootisos)>0){
+ foreach($this->bootisos as $id => $g){
+ $bootisofield->addMultiOption($g->getID(), $g->getTitle());
+ }
+ }
+ $bootisofield->setRegisterInArrayValidator(false);
+ $this->addElement($bootisofield);
- $this->addElement('text', 'bootosID', array(
- 'filters' => array('StringTrim'),
- 'validators' => array(
- array('StringLength', false, array(0, 50)),
- ),
- 'required' => true,
- 'label' => 'bootosID:',
- ));
-$this->addElement('text', 'bootisoID', array(
- 'filters' => array('StringTrim'),
- 'validators' => array(
- array('StringLength', false, array(0, 50)),
- ),
- 'required' => true,
- 'label' => 'bootisoID:',
- ));
$this->addElement('text', 'time', array(
'filters' => array('StringTrim'),
'validators' => array(
@@ -64,7 +76,16 @@ $this->addElement('text', 'ip6', array(
'label' => 'Save',
));
}
-
+ function setClients($v){
+ $this->clients = $v;
+ }
+ function setBootos($v){
+ $this->bootos = $v;
+ }
+ function setBootisos($v){
+ $this->bootisos = $v;
+ }
+
}
diff --git a/application/layouts/main.phtml b/application/layouts/main.phtml
index 483d267..57d09c7 100644
--- a/application/layouts/main.phtml
+++ b/application/layouts/main.phtml
@@ -4,6 +4,9 @@
<head>
<?php
+$request = Zend_Controller_Front::getInstance()->getRequest();
+$this->headTitle()->append(ucwords($request->getControllerName()));
+$this->headTitle()->append(ucwords($request->getActionName()));
echo $this->headTitle()."\n";
echo $this->headMeta()."\n";
echo $this->headStyle()."\n";
diff --git a/application/views/scripts/filter/index.phtml b/application/views/scripts/filter/index.phtml
index c14bf51..188bed3 100644
--- a/application/views/scripts/filter/index.phtml
+++ b/application/views/scripts/filter/index.phtml
@@ -8,6 +8,7 @@
<tr>
<th>ID</th>
<th>Title</th>
+ <th>Description</th>
<th>Priority</th>
<th>TargetBootMenu</th>
<th colspan=3>Actions</th>
@@ -16,6 +17,7 @@
<tr class='entry'>
<td><?php echo $this->escape($filter->getID()) ?></td>
<td><?php echo $this->escape($filter->title) ?></td>
+ <td><?php echo $this->escape($filter->Description) ?></td>
<td><?php echo $this->escape($filter->priority) ?></td>
<td><?php echo $this->escape($filter->bootmenuID) ?></td>
<td class='action'><a href="<?php echo $this->url(
@@ -51,7 +53,7 @@
<?php if (count($erg)>0): ?>
<tr class=detail>
<td class=arrowtop>↳</td>
- <td colspan=6>
+ <td colspan=7>
<?php
?>
diff --git a/application/views/scripts/session/index.phtml b/application/views/scripts/session/index.phtml
index 0ff255d..6e87acf 100644
--- a/application/views/scripts/session/index.phtml
+++ b/application/views/scripts/session/index.phtml
@@ -19,7 +19,7 @@
<td><?php echo $this->escape($session->getClientID()) ?></td>
<td><?php echo $this->escape($session->getBootosID()) ?></td>
<td><?php echo $this->escape($session->getBootisoID()) ?></td>
- <td><?php echo $this->escape($session->getTime()) ?></td>
+ <td><?php echo date('d.m.Y H:i',$this->escape($session->getTime())) ?></td>
<td><?php echo $this->escape($session->getIp()) ?></td>
<td><?php echo $this->escape($session->getIp6()) ?></td>
<td class='action'><a href="<?php echo $this->url(