summaryrefslogtreecommitdiffstats
path: root/application/controllers
diff options
context:
space:
mode:
authorSimon2011-03-09 20:49:24 +0100
committerSimon2011-03-09 20:49:24 +0100
commit5767c4f644a586d5f19e86fdd2de2ad47a21cb1a (patch)
tree116914ccf6a4bf492b74682c2fea717e4c4f92e1 /application/controllers
parentstyle angepasst (diff)
downloadpbs2-5767c4f644a586d5f19e86fdd2de2ad47a21cb1a.tar.gz
pbs2-5767c4f644a586d5f19e86fdd2de2ad47a21cb1a.tar.xz
pbs2-5767c4f644a586d5f19e86fdd2de2ad47a21cb1a.zip
FilterController Evaluate funktioniert
Diffstat (limited to 'application/controllers')
-rw-r--r--application/controllers/FilterController.php139
-rw-r--r--application/controllers/SessionController.php50
2 files changed, 121 insertions, 68 deletions
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';