summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/Bootstrap.php1
-rw-r--r--application/controllers/BootmenuController.php112
-rw-r--r--application/controllers/ClientController.php21
-rw-r--r--application/controllers/FilterController.php563
-rw-r--r--application/controllers/PoolController.php20
-rw-r--r--application/controllers/ResourceController.php292
-rw-r--r--application/controllers/SessionController.php50
-rw-r--r--application/forms/BootmenuEntriesAdd.php22
-rw-r--r--application/forms/BootmenuEntriesEdit.php21
-rw-r--r--application/forms/BootosCreate.php2
-rw-r--r--application/forms/BootosEdit.php2
-rw-r--r--application/forms/FilterAdd.php24
-rw-r--r--application/forms/FilterEvaluate.php123
-rw-r--r--application/forms/Session.php71
-rw-r--r--application/layouts/main.phtml11
-rw-r--r--application/models/BootMenuEntriesMapper.php18
-rw-r--r--application/models/BootOsMapper.php4
-rw-r--r--application/models/ConfigMapper.php13
-rw-r--r--application/models/GroupMapper.php13
-rw-r--r--application/models/MembershipMapper.php13
-rw-r--r--application/models/PersonMapper.php13
-rw-r--r--application/views/scripts/bootmenu/index.phtml9
-rw-r--r--application/views/scripts/filter/index.phtml18
-rw-r--r--application/views/scripts/filter/testevaluate.phtml4
-rw-r--r--application/views/scripts/pool/index.phtml22
-rw-r--r--application/views/scripts/resource/get-bootmenu-entry.phtml0
-rw-r--r--application/views/scripts/resource/index.phtml0
-rw-r--r--application/views/scripts/session/index.phtml2
28 files changed, 1105 insertions, 359 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/BootmenuController.php b/application/controllers/BootmenuController.php
index 93d541d..641b547 100644
--- a/application/controllers/BootmenuController.php
+++ b/application/controllers/BootmenuController.php
@@ -10,26 +10,82 @@ class BootmenuController extends Zend_Controller_Action
public function indexAction()
{
- $bootmenumapper = new Application_Model_BootMenuMapper();
- $bootmenuentriesmapper = new Application_Model_BootMenuEntriesMapper();
- $bootosmapper = new Application_Model_BootOsMapper();
- $configmapper = new Application_Model_ConfigMapper();
- $membershipmapper = new Application_Model_MembershipMapper();
- $groupmapper = new Application_Model_GroupMapper();
- $personmapper = new Application_Model_PersonMapper();
-
- $this->view->bootosmapper = $bootosmapper;
- $this->view->configmapper = $configmapper;
- $this->view->bootmenulist = $bootmenumapper->fetchAll();
-
- $bootmenuentries = array();
- foreach ($this->view->bootmenulist as $bootmenu){
- $bootmenuentries[$bootmenu->getID()] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenu->getID());
- $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle());
- $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname());
- }
-
- $this->view->bootmenuentrylist = $bootmenuentries;
+ $bootmenumapper = new Application_Model_BootMenuMapper();
+ $bootmenuentriesmapper = new Application_Model_BootMenuEntriesMapper();
+ $bootosmapper = new Application_Model_BootOsMapper();
+ $configmapper = new Application_Model_ConfigMapper();
+ $membershipmapper = new Application_Model_MembershipMapper();
+ $groupmapper = new Application_Model_GroupMapper();
+ $personmapper = new Application_Model_PersonMapper();
+
+ $this->view->bootosmapper = $bootosmapper;
+ $this->view->configmapper = $configmapper;
+
+ $bootmenuID = $this->_request->getParam('bootmenuid');
+ $preboot = $this->_request->getParam('preboot');
+
+ if($preboot=="")
+ {
+ if($bootmenuID == "")
+ {
+ $this->view->bootmenulist = $bootmenumapper->fetchAll();
+ $bootmenuentries = array();
+ foreach ($this->view->bootmenulist as $bootmenu){
+ $bootmenuentries[$bootmenu->getID()] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenu->getID());
+ $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle());
+ $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname());
+ }
+ }else{
+ $bootmenu = new Application_Model_BootMenu();
+ $bootmenumapper->find($bootmenuID, $bootmenu);
+
+ $bootmenuentries = array();
+ $bootmenuentries[$bootmenuID] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenuID);
+ $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle());
+ $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname());
+
+ $this->view->bootmenulist = array($bootmenu);
+
+ }
+
+ $this->view->bootmenuentrylist = $bootmenuentries;
+
+ }else{
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ if($bootmenuID == "")
+ {
+ $this->view->bootmenulist = $bootmenumapper->fetchAll();
+ $bootmenuentries = array();
+ foreach ($this->view->bootmenulist as $bootmenu){
+ $bootmenuentries[$bootmenu->getID()] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenu->getID());
+ $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle());
+ $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname());
+ }
+ }else{
+ $bootmenu = new Application_Model_BootMenu();
+ $bootmenumapper->find($bootmenuID, $bootmenu);
+
+ $cc['title'] = $bootmenu->getTitle();
+
+ $bootmenuentries = array();
+ $bootmenuentries = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenuID);
+
+ foreach($bootmenuentries as $bootmenuentry){
+ $ar = array();
+ $ar['title'] = $bootmenuentry->getTitle();
+ $ar['id'] = $bootmenuentry->getID();
+ $cc['data'][] = $ar;
+ }
+
+ echo json_encode($cc);
+
+ //print_a($cc);
+
+ }
+
+ }
}
public function addbootmenuentryAction()
@@ -37,13 +93,13 @@ class BootmenuController extends Zend_Controller_Action
$bootmenuID = $this->_request->getParam('bootmenuID');
$bootosmapper = new Application_Model_BootOsMapper();
$configmapper = new Application_Model_ConfigMapper();
-// $bootmenuentriesmapper = new Application_Model_BootMenuEntriesMapper();
-//
-// $bootoslist = $this->arrayDiff($bootosmapper->fetchAll(), $bootmenuentriesmapper->findBy('bootmenuID',$bootmenuID));
if (!isset($_POST["addbootmenuentry"])){
$addbootmenuentryForm = new Application_Form_BootmenuEntriesAdd(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll()));
$addbootmenuentryForm->populate(array('order' => $this->_request->getParam('maxorder')));
+ unset($_POST['kcl']);
+ unset($_POST['configID']);
+ $addbootmenuentryForm->populate($_POST);
} else {
$addbootmenuentryForm = new Application_Form_BootmenuEntriesAdd(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll()),$_POST);
@@ -137,6 +193,7 @@ class BootmenuController extends Zend_Controller_Action
$bootmenu->setID($bootmenuID);
try {
+
$bootmenumapper->save($bootmenu);
}catch(Zend_Exception $e)
{
@@ -170,7 +227,14 @@ class BootmenuController extends Zend_Controller_Action
$bootmenuentrymapper->find($bootmenuentryID, $bootmenuentry);
$editbootmenuentryForm = new Application_Form_BootmenuEntriesEdit(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder' => $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll()));
- $editbootmenuentryForm->populate($bootmenuentry->toArray());
+ if(!isset($_POST['kcl'])){
+ $editbootmenuentryForm->populate($bootmenuentry->toArray());
+ }
+ else{
+ unset($_POST['kcl']);
+ unset($_POST['configID']);
+ $editbootmenuentryForm->populate($_POST);
+ }
}
}else{
$editbootmenuentryForm = new Application_Form_BootmenuEntriesEdit(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll()),$_POST);
diff --git a/application/controllers/ClientController.php b/application/controllers/ClientController.php
index ff663ba..580eb6e 100644
--- a/application/controllers/ClientController.php
+++ b/application/controllers/ClientController.php
@@ -16,16 +16,15 @@ class ClientController extends Zend_Controller_Action
public function addclientAction()
{
- $mac = $this->_request->getParam('mac');
- $hh = $this->_request->getParam('hh');
+ $mac = $this->_request->getParam('mac');
+ $hh = $this->_request->getParam('hh');
if (!isset($_POST["add"])){
- $addclient = new Application_Form_Client();
- $this->view->addclient = $addclient;
+ $addclient = new Application_Form_Client();
+ $this->view->addclient = $addclient;
}
else{
$addfilterform = new Application_Form_Client($_POST);
- print_a($_POST,$addfilterform->isValid($_POST));
if ($addfilterform->isValid($_POST) || ($mac != '' && $hh != '') ) {
$client = new Application_Model_Client();
$mac = ($mac!='')?$mac:$_POST['macadress'];
@@ -37,9 +36,7 @@ class ClientController extends Zend_Controller_Action
print_a('inserted');
$this->_redirect('/client');
}
- else{
- print_a('no insert');
- }
+ $this->view->addclient = $addclient;
}
}
@@ -69,8 +66,8 @@ class ClientController extends Zend_Controller_Action
$this->view->editclient = $editclient;
}
else{
- $addfilterform = new Application_Form_Client($_POST);
- if ($addfilterform->isValid($_POST) || ($mac != '' && $hh != '') ) {
+ $editclient = new Application_Form_Client($_POST);
+ if ($editclient->isValid($_POST) || ($mac != '' && $hh != '') ) {
$client = new Application_Model_Client($_POST);
$client->setID($this->_request->getParam('clientID'));
$clientmapper = new Application_Model_ClientMapper();
@@ -78,9 +75,7 @@ class ClientController extends Zend_Controller_Action
print_a('updated');
$this->_redirect('/client');
}
- else{
- print_a('no update');
- }
+ $this->view->editclient = $editclient;
}
}
diff --git a/application/controllers/FilterController.php b/application/controllers/FilterController.php
index 54bcb19..9141e10 100644
--- a/application/controllers/FilterController.php
+++ b/application/controllers/FilterController.php
@@ -4,16 +4,18 @@ class FilterController extends Zend_Controller_Action
{
private $_filtermapper = null;
- private $db;
+
+ private $db = null;
+
public function init()
{
try{
-
- $this->_filtermapper = new Application_Model_FilterMapper();
- }catch (Zend_Exception $e) {
- echo "Error message 1: " . $e->getMessage() . "\n";
- }
- $this->db = Zend_Db_Table::getDefaultAdapter();
+
+ $this->_filtermapper = new Application_Model_FilterMapper();
+ }catch (Zend_Exception $e) {
+ echo "Error message 1: " . $e->getMessage() . "\n";
+ }
+ $this->db = Zend_Db_Table::getDefaultAdapter();
}
public function indexAction()
@@ -21,25 +23,25 @@ class FilterController extends Zend_Controller_Action
try{
$this->_filtermapper = new Application_Model_FilterMapper();
$this->view->filters = $this->_filtermapper->fetchAll();
- }catch (Zend_Exception $e) {
+ }catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
- }
- }
+ }
+ }
public function addfilterAction()
{
- if (!isset($_POST["add"])){
- $addfilterform = new Application_Form_FilterAdd();
- $this->view->addfilterform = $addfilterform;
+ $bmmapper = new Application_Model_BootMenuMapper();
+ //TODO get bootmenu by group
+ $bootmenus = $bmmapper->fetchAll();
+ if (!isset($_POST["add"])){
+ $addfilterform = new Application_Form_FilterAdd(array('bootmenus'=>$bootmenus));
+ $this->view->addfilterform = $addfilterform;
}else {
- $addfilterform = new Application_Form_FilterAdd($_POST);
+ $addfilterform = new Application_Form_FilterAdd(array('bootmenus'=>$bootmenus),$_POST);
if ($addfilterform->isValid($_POST)) {
try{
- $newfilter = new Application_Model_Filter();
- $newfilter->setTitle($_POST['title']);
+ $newfilter = new Application_Model_Filter($_POST);
$newfilter->setCreated(time());
- $newfilter->setDescription($_POST['description']);
- $newfilter->setPriority($_POST['priority']);
// TODO: Ändere mit ACL
$newfilter->setGroupID('1');
@@ -54,89 +56,80 @@ class FilterController extends Zend_Controller_Action
echo "Error message 2: " . $e->getMessage() . "\n";
}
}
+ $this->view->addfilterform = $addfilterform;
}
}
public function removefilterAction()
{
-
- $filterID = $this->_request->getParam('filterID');
- // TODO: ACL implementieren ob er den filter löschen darf
- if(is_numeric($filterID)){
- $deletefilter = new Application_Model_Filter();
- $deletefilter->setID($filterID);
- $filtermapper = new Application_Model_FilterMapper();
- $filtermapper->delete($deletefilter);
- }
- $this->_redirect('/filter');
+ $filterID = $this->_request->getParam('filterID');
+ // TODO: ACL implementieren ob er den filter löschen darf
+ if(is_numeric($filterID)){
+ $deletefilter = new Application_Model_Filter();
+ $deletefilter->setID($filterID);
+ $filtermapper = new Application_Model_FilterMapper();
+ $filtermapper->delete($deletefilter);
+ }
+ $this->_redirect('/filter');
}
public function editfilterAction()
{
- if (!isset($_POST["add"])){
- // TODO: ACL implementieren ob er editieren darf
- $filterID = $this->_request->getParam('filterID');
- $filter = new Application_Model_Filter();
-
-
- $filtermapper = new Application_Model_FilterMapper();
- $filtermapper->find($filterID,$filter);
- $filter2 = $filter->toArray();
-
- $editfilterform = new Application_Form_FilterAdd();
- $editfilterform->populate($filter2);
- $this->view->editfilterform = $editfilterform;
-
- } else{
- try{
- $filterID = $this->_request->getParam('filterID');
-
- $editfilterform = new Application_Form_FilterAdd($_POST);
- //TODO: ACL integrieren
- $_POST['groupID'] = 1;
- $_POST['membershipID'] = 1;
- $_POST['created'] = time();
-
- if ($editfilterform->isValid($_POST)) {
- $newfilterenty = new Application_Model_Filter($_POST);
- $newfilterenty->setID($this->_request->getParam('filterID'));
- $newfilter2 = new Application_Model_FilterMapper();
- $newfilter2->save($newfilterenty);
- echo 'valid';
- }
- else
- {
- echo 'not valid';
- }
- }catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
- }
- $this->_redirect('/filter');
- }
+ $bmmapper = new Application_Model_BootMenuMapper();
+ //TODO get bootmenu by group
+ $bootmenus = $bmmapper->fetchAll();
+ if (!isset($_POST["add"])){
+ // TODO: ACL implementieren ob er editieren darf
+ $filterID = $this->_request->getParam('filterID');
+ $filter = new Application_Model_Filter();
+
+
+ $filtermapper = new Application_Model_FilterMapper();
+ $filtermapper->find($filterID,$filter);
+ $filter2 = $filter->toArray();
+
+ $editfilterform = new Application_Form_FilterAdd(array('bootmenus'=>$bootmenus));
+ $editfilterform->populate($filter2);
+ $this->view->editfilterform = $editfilterform;
+
+ } else{
+ try{
+ $filterID = $this->_request->getParam('filterID');
+
+ $editfilterform = new Application_Form_FilterAdd(array('bootmenus'=>$bootmenus),$_POST);
+ //TODO: ACL integrieren
+ $_POST['groupID'] = 1;
+ $_POST['membershipID'] = 1;
+ $_POST['created'] = time();
+
+ if ($editfilterform->isValid($_POST)) {
+ $newfilterenty = new Application_Model_Filter($_POST);
+ $newfilterenty->setID($this->_request->getParam('filterID'));
+ $newfilter2 = new Application_Model_FilterMapper();
+ $newfilter2->save($newfilterenty);
+ echo 'valid';
+ $this->_redirect('/filter');
+ }
+ $this->view->editfilterform = $editfilterform;
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
+ }
+ }
}
public function addfilterentryAction()
{
-
// TODO: ACL implementieren ob er editieren darf
if (!isset($_POST["add"])){
- echo "case1";
try{
$editfilterform = new Application_Form_FilterEntriesAdd(array('filterID' => $this->_request->getParam('filterID')));
$this->view->editfilterform = $editfilterform;
- echo "<pre style='padding:5px;border:1px solid black;background-color:#3CF'>";
- print_r(array('debug','case1'));
- echo "</pre>";
-
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
} else{
- $editfilterform = new Application_Form_FilterEntriesAdd($_POST);
- echo "<pre style='padding:5px;border:1px solid black; background-color:#3CF;'>case2</pre>";
-
- if ($editfilterform->isValid($_POST)) {
- echo "<pre style='padding:5px;border:1px solid black; background-color:#3CF;'>case 2.2</pre>";
+ $editfilterform = new Application_Form_FilterEntriesAdd($_POST);
+ if ($editfilterform->isValid($_POST)) {
$newfilterenty = new Application_Model_FilterEntries();
$newfilterenty->setFilterID($_POST['filterID']);
$newfilterenty->setFiltertypeID($_POST['filtertypeID']);
@@ -151,15 +144,14 @@ class FilterController extends Zend_Controller_Action
}
$newfilter2 = new Application_Model_FilterEntriesMapper();
- echo "<pre style='border:1px solid black;background-color:#F5B800'>";
- print_r($newfilterenty);
- echo "</pre>";
$newfilter2->save($newfilterenty);
+ $this->_redirect('/filter');
}
- $this->_redirect('/filter');
+ $this->view->editfilterform = $editfilterform;
}
}
- public function editfilterentryAction()
+
+ public function editfilterentryAction()
{
if (!isset($_POST["add"])){
echo "case1";
@@ -174,13 +166,9 @@ class FilterController extends Zend_Controller_Action
$editfilterform = new Application_Form_FilterEntriesAdd();
- echo "<pre style='border:1px solid black;background-color:#F5B800'>";
- print_r($filterentry->toArray());
- echo "</pre>";
$editfilterform->populate($filterentry->toArray());
$editfilterform->setFilterID($filterID);
$this->view->editfilterform = $editfilterform;
- echo "case 1.1";
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
@@ -189,8 +177,7 @@ class FilterController extends Zend_Controller_Action
try{
$filterentriesID = $this->_request->getParam('filterentriesID');
$editfilterform = new Application_Form_FilterEntriesAdd($_POST);
- if ($editfilterform->isValid($_POST)) {
- echo "valid\n";
+ if ($editfilterform->isValid($_POST)) {
$newfilterenty = new Application_Model_FilterEntries($_POST);
$newfilterenty->setID($filterentriesID);
if($_POST['filtertypeID'] == 1){
@@ -201,68 +188,94 @@ class FilterController extends Zend_Controller_Action
$newfilterenty->setFiltervalue($_POST['filtervalue']);
$newfilterenty->setFiltervalue2($_POST['filtervalue2']);
}
- echo "<pre style='border:1px solid black;background-color:#F5B800'>";
- print_r($newfilterenty);
- echo "</pre>";
$newfilter2 = new Application_Model_FilterEntriesMapper();
$newfilter2->save($newfilterenty);
+ $this->_redirect('/filter');
}
- else{
- echo 'nö';
- }
+ $this->view->editfilterform = $editfilterform;
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
- }
- $this->_redirect('/filter');
+ }
}
}
- public function removefilterentryAction()
- {
-
- try{
- $filterentriesID = $this->_request->getParam('filterentriesID');
-
- // TODO: ACL implementieren ob er den filter löschen darf
- if(is_numeric($filterentriesID)){
- $deletefilterentry = new Application_Model_FilterEntries();
- $deletefilterentry->setID($filterentriesID);
- echo "<pre style='border:1px solid black;background-color:#F5B800'>";
- print_r($deletefilterentry);
- echo "</pre>";
- $filterentriesmapper = new Application_Model_FilterEntriesMapper();
- $filterentriesmapper->delete($deletefilterentry);
- echo "ok";
+ public function removefilterentryAction()
+ {
+ try{
+ $filterentriesID = $this->_request->getParam('filterentriesID');
+
+ // TODO: ACL implementieren ob er den filter löschen darf
+ if(is_numeric($filterentriesID)){
+ $deletefilterentry = new Application_Model_FilterEntries();
+ $deletefilterentry->setID($filterentriesID);
+ echo "<pre style='border:1px solid black;background-color:#F5B800'>";
+ print_r($deletefilterentry);
+ echo "</pre>";
+
+ $filterentriesmapper = new Application_Model_FilterEntriesMapper();
+ $filterentriesmapper->delete($deletefilterentry);
+ echo "ok";
+ }
+ $this->_redirect('/filter');
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
}
-# echo "ready";
- $this->_redirect('/filter');
- }catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
- }
}
- private function fillIP($ip){
- $ar = explode(".",$ip);
- $representation = array();
- foreach($ar as $part){
- $representation[] = sprintf("%03s",$part);
- }
- return implode(".",$representation);
- }
- private function fillMac($ip){
- $ar = explode(":",$ip);
- $representation = array();
- foreach($ar as $part){
- $representation[] = sprintf("%02s",$part);
+
+ private function fillIP($ip)
+ {
+ $ar = explode(".",$ip);
+ $representation = array();
+ foreach($ar as $part){
+ $representation[] = sprintf("%03s",$part);
+ }
+ return implode(".",$representation);
+ }
+
+ private function fillMac($ip)
+ {
+ $ar = explode(":",$ip);
+ $representation = array();
+ foreach($ar as $part){
+ $representation[] = sprintf("%02s",$part);
+ }
+ return implode(":",$representation);
+ }
+
+ public function evaluateAction()
+ {
+ $db = $this->db;
+ $showPartResults = false;
+ // For Testing Filters
+
+
+ $testFilter = (isset($_POST['submit']))?true:false;
+
+ if($testFilter){
+ $ipAdress = $_POST['ip'];
+ $macAdress = $_POST['mac'];
+ $poolID = $_POST['poolID'];
+ $bootisoID = $_POST['bootisoID'];
+ $membershipID = $_POST['membershipID'];
+ $groupID = $_POST['groupID'];
+ $time = strtotime($_POST['time']);
+ $clientID = $_POST['clientID'];
+ print_a('Input',
+ array('ipAdress'=>$ipAdress,
+ 'macAdress'=>$macAdress,
+ 'poolID' => $poolID,
+ 'bootisoID' => $bootisoID,
+ 'membershipID'=>$membershipID,
+ 'groupID'=>$groupID,
+ 'time'=>$time." - ".date('d.m.Y H:i:s',$time),
+ 'clientID' => $clientID));
}
- return implode(":",$representation);
- }
- public function evaluateAction(){
- $db = $this->db;
- $showPartResults = false;
- try{
-
+
+
+ try{
$mysession = '1';
+ $set = array();
$filtertypID = 8;
$session = new Application_Model_Session();
@@ -272,148 +285,199 @@ class FilterController extends Zend_Controller_Action
// IP Adress
$filtertypID = 1;
// get it from session_table with session_id from the session
- $ipAdress = $session->getIp();
+ if(!$testFilter){
+ $ipAdress = $session->getIp();
+ }
$ipAdress = str_replace(".","",$this->fillIP($ipAdress));
+
$select = $db->select()
- ->from(array('pbs_filterentries')
+ ->from(array('pbs_filterentries')
)
->where('filtertypeID = ?',$filtertypID)
->where('REPLACE(filtervalue,".","") <= ?',$ipAdress)
->where('? <= REPLACE(filtervalue2,".","")',$ipAdress);
-
+
$stmt = $select->query();
$result = $stmt->fetchAll();
foreach($result as $r){
$set[$filtertypID][] = $r['filterID'];
}
+
if($showPartResults)
print_a('ipAdress',$result,$set[$filtertypID]);
+
#########################################################
// Mac range
$filtertypID = 2;
// get it from session_table with session_id from the session
- $client = new Application_Model_Client();
- $clientmapper = new Application_Model_ClientMapper();
- $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'];
+ if(!$testFilter){
+ $client = new Application_Model_Client();
+ $clientmapper = new Application_Model_ClientMapper();
+ $clientmapper->find($session->getClientID(),$client);
+ $macAdress = $client->getMacadress();
}
+ 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]);
+
#########################################################
// PoolID
$filtertypID = 3;
// get PoolID from client_ID from session_id from the session
- $poolentry = new Application_Model_PoolEntries();
- $poolentrymapper = new Application_Model_PoolEntriesMapper();
- $poolentry = $poolentrymapper->findby('clientID',$client->getID());
- $poolentry = $poolentry[0];
-
- $poolID = $poolentry['poolID'];
- print_a($poolentry);
- $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE
- filtertypeID = ".$filtertypID." AND
- filtervalue = ".$poolID." ");
- $result = $stmt->fetchAll();
- foreach($result as $r){
- $set[$filtertypID][] = $r['filterID'];
+ if(!$testFilter){
+ $poolentry = new Application_Model_PoolEntries();
+ $poolentrymapper = new Application_Model_PoolEntriesMapper();
+ $poolentry = $poolentrymapper->findby('clientID',$client->getID());
+ $poolentry = $poolentry[0];
+
+ $poolID = $poolentry['poolID'];
+ }
+
+ 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]);
#########################################################
// ClientID
$filtertypID = 8;
// get client_ID from session_id from the session
- $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE
- filtertypeID = ".$filtertypID." AND
- filtervalue = ".$session->getClientID()." ");
- $result = $stmt->fetchAll();
- foreach($result as $r){
- $set[$filtertypID][] = $r['filterID'];
+
+ if(!$testFilter){
+ $clientID = $session->getClientID();
}
+ 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]);
#########################################################
// BootIsoID
$filtertypID = 4;
- // get BootIsoID from client_ID from session_id from the session
- $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'];
+ // get BootIsoID from client_ID from session_id from the session
+ if(!$testFilter){
+ $bootisoID = $session->getBootisoID();
+ }
+ 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]);
#########################################################
// MembershipID
$filtertypID = 5;
- // get membership from the session
- //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'];
+ if(!$testFilter){
+ // get membership from the session
+ //TODO: GET MEMBERSHIP from SESSION
+ $membershipID = 1;
}
+ 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]);
#########################################################
// GroupID
$filtertypID = 6;
- // get membership from the session
- //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'];
+ if(!$testFilter){
+ // get membership from the session
+ //TODO: GET GROUP from SESSION
+ $groupID = 1;
}
+ 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]);
#########################################################
// Time
$filtertypID = 7;
- $nowShort = date('H-i',time());
- $nowLong = date('Y-m-d-H-i',time());
+ if(!$testFilter){
+ $time = time();
+ }
+
+ $nowShort = date('H-i',$time);
+ $nowLong = date('Y-m-d-H-i',$time);
$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);
-
- $stmt = $select->query();
- $result = $stmt->fetchAll();
- foreach($result as $r){
- $set[$filtertypID][] = $r['filterID'];
+ 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'];
+ }
}
+ catch(Exception $e){}
+
if($showPartResults)
print_a('time',$result,$set[$filtertypID]);
########################################
// ErgebnisSet auswerten
print_a('the result sets of the filtertypes',$set);
-
+
// Merging of the resultsets of the filter
$kk = array();
foreach($set as $myset){
@@ -421,18 +485,21 @@ class FilterController extends Zend_Controller_Action
}
$set = $kk;
// counting how often a filter is evaluated at database
+ $a = array();
foreach($set as $k=> $s){
$a[$s] += 1;
}
-
+ print_a('Übereinstimmungen pro Filter',$a);
// Get the number of filtertypes every filter has
$stmt = $db->query('SELECT filterID, COUNT(filtertypeID) as num FROM pbs_filterentries GROUP BY filterID');
$resultset = $stmt->fetchAll();
foreach($resultset as $d){
$database[$d['filterID']] = $d['num'];
}
-
+ print_a('Anzahl Filterentries in Datenbank',$database);
+
// remove all filters from resultset, which to few filtertypes satisfied
+ $result = array();
foreach($a as $i=>$b){
if($a[$i] < $database[$i]){
unset($a[$i]);
@@ -441,8 +508,8 @@ class FilterController extends Zend_Controller_Action
$result[] = $i;
}
}
-
- print_a('result set of filterIDs',$result);
+
+ print_a('True Filters',$result);
// now selecting the filter with the highest priority
$query = 'SELECT filterID, bootmenuID, priority
FROM pbs_filter WHERE ';
@@ -451,16 +518,58 @@ class FilterController extends Zend_Controller_Action
}
$query .= implode(" OR ", $queryTmp);
$query .= 'ORDER BY priority DESC LIMIT 0,1';
- $stmt = $db->query($query);
- $resultset = $stmt->fetchAll();
- print_a($resultset);
- echo "<h1>".$resultset[0]['bootmenuID']."</h1>";
-
+ $bootmenuID = 'null';
+ try{
+ $stmt = $db->query($query);
+ $resultset = $stmt->fetchAll();
+ $bootmenuID = $resultset[0]['bootmenuID'];
+ }
+ 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>";
+ }
+
}catch (Zend_Exception $e) {
echo "class: ".get_class($e)."<br>\n";
- echo "Error message 2: " . $e->getMessage() . "\n";
+ echo "Error message 2: " . $e->getMessage() . "\n";
}
- }
+ }
+
+ public function testevaluateAction()
+ {
+ $pm = new Application_Model_PoolMapper();
+ $pools = $pm->fetchAll();
+
+ $bim = new Application_Model_BootIsoMapper();
+ $bootisos = $bim->fetchAll();
+
+ $mm = new Application_Model_MembershipMapper();
+ $memberships = $mm->fetchAll();
+
+ $gm = new Application_Model_GroupMapper();
+ $groups = $gm->fetchAll();
+
+ $cm = new Application_Model_ClientMapper();
+ $clients = $cm->fetchAll();
+
+ $filterevaluate = new Application_Form_FilterEvaluate(
+ array( 'pools' => $pools,
+ 'bootisos' => $bootisos,
+ 'memberships' => $memberships,
+ 'groups' => $groups,
+ 'clients' => $clients,
+
+ ));
+ $this->view->filterevaluate = $filterevaluate;
+ }
+
}
@@ -472,3 +581,5 @@ class FilterController extends Zend_Controller_Action
+
+
diff --git a/application/controllers/PoolController.php b/application/controllers/PoolController.php
index cb38a80..7c5092e 100644
--- a/application/controllers/PoolController.php
+++ b/application/controllers/PoolController.php
@@ -25,7 +25,6 @@ class PoolController extends Zend_Controller_Action
$assignedclientsArray[] = $c->toArray();
}
$freeclients = $this->arrayDiff($clientsArray,$assignedclientsArray);
- #print_a($freeclients);
$this->view->freeclients = $freeclients;
@@ -49,6 +48,7 @@ class PoolController extends Zend_Controller_Action
echo "Error message 2: " . $e->getMessage() . "\n";
}
}
+ $this->view->addpool = $addfilterform;
}
}
@@ -80,8 +80,8 @@ class PoolController extends Zend_Controller_Action
$this->view->editpoolform = $editpool;
}else {
- $addpoolform = new Application_Form_Pool($_POST);
- if ($addpoolform->isValid($_POST)) {
+ $editpoolform = new Application_Form_Pool($_POST);
+ if ($editpoolform->isValid($_POST)) {
try{
$pool = new Application_Model_Pool($_POST);
$pool->setID($this->_request->getParam('poolID'));
@@ -92,6 +92,7 @@ class PoolController extends Zend_Controller_Action
echo "Error message 2: " . $e->getMessage() . "\n";
}
}
+ $this->view->editpoolform = $editpoolform;
}
}
@@ -99,10 +100,8 @@ class PoolController extends Zend_Controller_Action
{
$clientID = $this->_request->getParam('clientID');
$poolID = $this->_request->getParam('poolID');
- print_a($clientID,$poolID);
if(!isset($_POST['clientID']) && ($clientID == '' && $poolID == '')){
- print_a($_POST);
$clientmapper = new Application_Model_ClientMapper();
$clients = $clientmapper->fetchAll();
foreach($clients as $c){
@@ -117,10 +116,8 @@ class PoolController extends Zend_Controller_Action
$poolclient = new Application_Form_PoolClient(array('clients'=> $freeclients));
$this->view->poolclient = $poolclient;
- }else {
- #$_POST['poolID'] = $this->_request->getParam('poolID');
- $poolclientform = new Application_Form_PoolClient($_POST);
-
+ }else {
+ $poolclient = new Application_Form_PoolClient($_POST);
try{
$pool = new Application_Model_PoolEntries($_POST);
$pool->setPoolID($this->_request->getParam('poolID'));
@@ -133,6 +130,7 @@ class PoolController extends Zend_Controller_Action
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
+ $this->view->poolclient = $poolclient;
}
}
@@ -156,15 +154,11 @@ class PoolController extends Zend_Controller_Action
if(is_numeric($poolentriesID)){
$deletepoolentries = new Application_Model_PoolEntries();
$deletepoolentries->setID($poolentriesID);
- echo "<pre style='border:1px solid black;background-color:#F5B800'>";
- print_r($deletepoolentries);
- echo "</pre>";
$deletepoolentriesmapper = new Application_Model_PoolEntriesMapper();
$deletepoolentriesmapper->delete($deletepoolentries);
echo "ok";
}
-# echo "ready";
$this->_redirect('/pool');
}
diff --git a/application/controllers/ResourceController.php b/application/controllers/ResourceController.php
new file mode 100644
index 0000000..b70c589
--- /dev/null
+++ b/application/controllers/ResourceController.php
@@ -0,0 +1,292 @@
+<?php
+
+class ResourceController extends Zend_Controller_Action
+{
+
+ private $startval = 878923467;
+ private $pass = array('lsfks_!$fks', 'un!fr€iburg', '0pen$lx_rulez', 'rand0mText');
+
+ public function init()
+ {
+
+ }
+
+ public function indexAction()
+ {
+
+
+ }
+
+ public function getinitramfsAction()
+ {
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ $bootosID = $this->_request->getParam('bootosID');
+ $bootosID = $this->alphaID($bootosID, true, false, $this->pass[0]);
+ $bootosID -= $this->startval;
+
+ 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.tar.gz"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+
+ // create the gzipped tarfile.
+ chdir("../resources/bootos/$bootosID/initramfs/");
+ passthru( "tar cz ./");
+ }
+ }
+
+ public function getconfigAction()
+ {
+
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ $configID = $this->_request->getParam('configID');
+ $configID = $this->alphaID($configID, true, false, $this->pass[1]);
+ $configID -= $this->startval;
+
+ 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();
+
+ $bootosID = $this->_request->getParam('bootosID');
+ $bootosID = $this->alphaID($bootosID, true, false, $this->pass[2]);
+ $bootosID -= $this->startval;
+
+ 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.tar.gz"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+
+ // create the gzipped tarfile.
+ chdir("../resources/bootos/$bootosID/kernel/");
+ passthru( "tar cz ./");
+ }
+ }
+
+ public function getkclAction()
+ {
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ $bmeID = $this->_request->getParam('bootmenuentryID');
+ $bmeID = $this->alphaID($bmeID, true, false, $this->pass[3]);
+ $bmeID -= $this->startval;
+
+ if(is_numeric($bmeID)){
+ $bmemapper = new Application_Model_BootMenuEntriesMapper();
+ $bme = new Application_Model_BootMenuEntries();
+ $bmemapper->find($bmeID,$bme);
+
+ if($bme->getKcl() != null){
+ echo $bme->getKcl();
+ }
+
+ }
+
+ }
+
+ public function getbootmenuentryAction()
+ {
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ $bmeID = $this->_request->getParam('bootmenuentryID');
+
+ if(is_numeric($bmeID)){
+ $bmemapper = new Application_Model_BootMenuEntriesMapper();
+ $bme = new Application_Model_BootMenuEntries();
+
+ $bootosmapper = new Application_Model_BootOsMapper();
+ $bootos = new Application_Model_BootOs();
+
+ $bmemapper->find($bmeID, $bme);
+ if($bme->getBootosID() != null){
+ $bootos = $bootosmapper->find($bme->getBootosID());
+
+ $alpha_init_bootos = $this->alphaID($bootos->getID()+$this->startval, false, false, $this->pass[0]);
+ $alpha_kernel_bootos = $this->alphaID($bootos->getID()+$this->startval, false, false, $this->pass[2]);
+ $alpha_bmeID = $this->alphaID($bmeID+$this->startval, false, false, $this->pass[3]);
+ $alpha_config = $this->alphaID($bme->getConfigID()+$this->startval, false, false, $this->pass[1]);
+
+ $return_val =
+ array(
+ 'kernel' => $this->generateURL('getkernel', 'bootosID', $alpha_kernel_bootos),
+ 'initramfs' => $this->generateURL('getinitramfs', 'bootosID', $alpha_init_bootos),
+ 'kcl' => $this->generateURL('getkcl', 'bootmenuentryID', $alpha_bmeID),
+ 'config' => $alpha_config
+ );
+
+ echo json_encode($return_val);
+ }
+ }
+
+ }
+
+ function generateURL($action, $varname, $varvalue){
+ $path = '/resource/'. $action .'/' . $varname .'/' . $varvalue;
+ $path = "http://" . $_SERVER['SERVER_NAME'] . $path;
+ return $path;
+ }
+
+/**
+ * Translates a number to a short alhanumeric version
+ *
+ * Translated any number up to 9007199254740992
+ * to a shorter version in letters e.g.:
+ * 9007199254740989 --> PpQXn7COf
+ *
+ * specifiying the second argument true, it will
+ * translate back e.g.:
+ * PpQXn7COf --> 9007199254740989
+ *
+ * this function is based on any2dec && dec2any by
+ * fragmer[at]mail[dot]ru
+ * see: http://nl3.php.net/manual/en/function.base-convert.php#52450
+ *
+ * If you want the alphaID to be at least 3 letter long, use the
+ * $pad_up = 3 argument
+ *
+ * In most cases this is better than totally random ID generators
+ * because this can easily avoid duplicate ID's.
+ * For example if you correlate the alpha ID to an auto incrementing ID
+ * in your database, you're done.
+ *
+ * The reverse is done because it makes it slightly more cryptic,
+ * but it also makes it easier to spread lots of IDs in different
+ * directories on your filesystem. Example:
+ * $part1 = substr($alpha_id,0,1);
+ * $part2 = substr($alpha_id,1,1);
+ * $part3 = substr($alpha_id,2,strlen($alpha_id));
+ * $destindir = "/".$part1."/".$part2."/".$part3;
+ * // by reversing, directories are more evenly spread out. The
+ * // first 26 directories already occupy 26 main levels
+ *
+ * more info on limitation:
+ * - http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/165372
+ *
+ * if you really need this for bigger numbers you probably have to look
+ * at things like: http://theserverpages.com/php/manual/en/ref.bc.php
+ * or: http://theserverpages.com/php/manual/en/ref.gmp.php
+ * but I haven't really dugg into this. If you have more info on those
+ * matters feel free to leave a comment.
+ *
+ * @author Kevin van Zonneveld <kevin@vanzonneveld.net>
+ * @author Simon Franz
+ * @author Deadfish
+ * @copyright 2008 Kevin van Zonneveld (http://kevin.vanzonneveld.net)
+ * @license http://www.opensource.org/licenses/bsd-license.php New BSD Licence
+ * @version SVN: Release: $Id: alphaID.inc.php 344 2009-06-10 17:43:59Z kevin $
+ * @link http://kevin.vanzonneveld.net/
+ *
+ * @param mixed $in String or long input to translate
+ * @param boolean $to_num Reverses translation when true
+ * @param mixed $pad_up Number or boolean padds the result up to a specified length
+ * @param string $passKey Supplying a password makes it harder to calculate the original ID
+ *
+ * @return mixed string or long
+ */
+
+private function alphaID($in, $to_num = false, $pad_up = false, $passKey = null)
+{
+ $index = "abcdefghijklmnopqrstuvwxyz0123456789";
+ if ($passKey !== null) {
+ // Although this function's purpose is to just make the
+ // ID short - and not so much secure,
+ // with this patch by Simon Franz (http://blog.snaky.org/)
+ // you can optionally supply a password to make it harder
+ // to calculate the corresponding numeric ID
+
+ for ($n = 0; $n<strlen($index); $n++) {
+ $i[] = substr( $index,$n ,1);
+ }
+
+ $passhash = hash('sha256',$passKey);
+ $passhash = (strlen($passhash) < strlen($index))
+ ? hash('sha512',$passKey)
+ : $passhash;
+
+ for ($n=0; $n < strlen($index); $n++) {
+ $p[] = substr($passhash, $n ,1);
+ }
+
+ array_multisort($p, SORT_DESC, $i);
+ $index = implode($i);
+ }
+
+ $base = strlen($index);
+
+ if ($to_num) {
+ // Digital number <<-- alphabet letter code
+ $in = strrev($in);
+ $out = 0;
+ $len = strlen($in) - 1;
+ for ($t = 0; $t <= $len; $t++) {
+ $bcpow = bcpow($base, $len - $t);
+ $out = $out + strpos($index, substr($in, $t, 1)) * $bcpow;
+ }
+
+ if (is_numeric($pad_up)) {
+ $pad_up--;
+ if ($pad_up > 0) {
+ $out -= pow($base, $pad_up);
+ }
+ }
+ $out = sprintf('%F', $out);
+ $out = substr($out, 0, strpos($out, '.'));
+ } else {
+ // Digital number -->> alphabet letter code
+ if (is_numeric($pad_up)) {
+ $pad_up--;
+ if ($pad_up > 0) {
+ $in += pow($base, $pad_up);
+ }
+ }
+
+ $out = "";
+ for ($t = floor(log($in, $base)); $t >= 0; $t--) {
+ $bcp = bcpow($base, $t);
+ $a = floor($in / $bcp) % $base;
+ $out = $out . substr($index, $a, 1);
+ $in = $in - ($a * $bcp);
+ }
+ $out = strrev($out); // reverse
+ }
+
+ return $out;
+}
+}
+
+
+
+
+
+
+
+
+
+
+
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/BootmenuEntriesAdd.php b/application/forms/BootmenuEntriesAdd.php
index 0f2109e..6981619 100644
--- a/application/forms/BootmenuEntriesAdd.php
+++ b/application/forms/BootmenuEntriesAdd.php
@@ -8,7 +8,6 @@ class Application_Form_BootmenuEntriesAdd extends Zend_Form
public function setBootoslist($bootoslist){
$this->bootoslist = $bootoslist;
-
}
public function setMaxorder($maxorder){
@@ -21,9 +20,15 @@ class Application_Form_BootmenuEntriesAdd extends Zend_Form
}
-
+
public function init()
{
+
+ if(!isset($_POST['bootosID'])){
+ $firstbootos = array_slice($this->bootoslist,0,1);
+ $_POST['bootosID'] = $firstbootos[0]->getID();
+ }
+
$this->setName("BootMenuEntryAdd");
$this->setMethod('post');
@@ -38,6 +43,7 @@ class Application_Form_BootmenuEntriesAdd extends Zend_Form
$bootosfield = $this->createElement('select','bootosID');
$bootosfield ->setLabel('BootOs:');
+ $bootosfield->setAttrib('onChange', "document.getElementById('BootMenuEntryAdd').submit();");
if(count($this->bootoslist)>0){
foreach($this->bootoslist as $bootos => $b){
@@ -45,6 +51,7 @@ class Application_Form_BootmenuEntriesAdd extends Zend_Form
}
}
$bootosfield->setRegisterInArrayValidator(false);
+
$this->addElement($bootosfield);
$this->addElement('textarea', 'kcl', array(
@@ -52,21 +59,26 @@ class Application_Form_BootmenuEntriesAdd extends Zend_Form
'validators' => array(
array('StringLength', false, array(0, 50)),
),
- 'required' => true,
+ 'required' => false,
'cols' => 50,
'rows' => 5,
'label' => 'KCL:',
+ 'value' => $this->bootoslist[$_POST['bootosID']]->getDefaultkcl()
));
+ $defaultconfigid = $this->bootoslist[$_POST['bootosID']]->getConfigID();
$configfield = $this->createElement('select','configID');
- $configfield ->setLabel('Config:');
+ $configfield->setLabel('Config:');
+ $configfield->addMultiOption($defaultconfigid, 'default');
if(count($this->configlist)>0){
foreach($this->configlist as $config => $c){
- $configfield->addMultiOption($c->getID(), $c->getTitle());
+ if($c->getID() != $defaultconfigid)
+ $configfield->addMultiOption($c->getID(), $c->getTitle());
}
}
+
$configfield->setRegisterInArrayValidator(false);
$this->addElement($configfield);
diff --git a/application/forms/BootmenuEntriesEdit.php b/application/forms/BootmenuEntriesEdit.php
index 7fd97fe..6dc1aab 100644
--- a/application/forms/BootmenuEntriesEdit.php
+++ b/application/forms/BootmenuEntriesEdit.php
@@ -24,6 +24,12 @@ class Application_Form_BootmenuEntriesEdit extends Zend_Form
public function init()
{
+
+ if(!isset($_POST['bootosID'])){
+ $firstbootos = array_slice($this->bootoslist,0,1);
+ $_POST['bootosID'] = $firstbootos[0]->getID();
+ }
+
$this->setName("BootMenuEntryAdd");
$this->setMethod('post');
@@ -37,7 +43,9 @@ class Application_Form_BootmenuEntriesEdit extends Zend_Form
));
$bootosfield = $this->createElement('select','bootosID');
- $bootosfield ->setLabel('BootOs:');
+ $bootosfield->setLabel('BootOs:');
+ $bootosfield->setAttrib('onChange', "document.getElementById('BootMenuEntryAdd').submit();");
+
if(count($this->bootoslist)>0){
foreach($this->bootoslist as $bootos => $b){
@@ -52,18 +60,23 @@ class Application_Form_BootmenuEntriesEdit extends Zend_Form
'validators' => array(
array('StringLength', false, array(0, 50)),
),
- 'required' => true,
+ 'required' => false,
'cols' => 50,
'rows' => 5,
'label' => 'KCL:',
+ 'value' => $this->bootoslist[$_POST['bootosID']]->getDefaultkcl()
));
+ $defaultconfigid = $this->bootoslist[$_POST['bootosID']]->getConfigID();
$configfield = $this->createElement('select','configID');
- $configfield ->setLabel('Config:');
+ $configfield->setLabel('Config:');
+ $configfield->addMultiOption($defaultconfigid, 'default');
+
if(count($this->configlist)>0){
foreach($this->configlist as $config => $c){
- $configfield->addMultiOption($c->getID(), $c->getTitle());
+ if($c->getID() != $defaultconfigid)
+ $configfield->addMultiOption($c->getID(), $c->getTitle());
}
}
$configfield->setRegisterInArrayValidator(false);
diff --git a/application/forms/BootosCreate.php b/application/forms/BootosCreate.php
index a6d74c6..8f699ce 100644
--- a/application/forms/BootosCreate.php
+++ b/application/forms/BootosCreate.php
@@ -78,7 +78,7 @@ class Application_Form_BootosCreate extends Zend_Form
'validators' => array(
array('StringLength', false, array(0, 50)),
),
- 'required' => true,
+ 'required' => false,
'rows' => 5,
'cols' => 50,
'label' => 'Default-KCL:',
diff --git a/application/forms/BootosEdit.php b/application/forms/BootosEdit.php
index 572e712..641429d 100644
--- a/application/forms/BootosEdit.php
+++ b/application/forms/BootosEdit.php
@@ -86,7 +86,7 @@ class Application_Form_BootosEdit extends Zend_Form
'validators' => array(
array('StringLength', false, array(0, 50)),
),
- 'required' => true,
+ 'required' => false,
'rows' => 5,
'cols' => 50,
'label' => 'Default-KCL:',
diff --git a/application/forms/FilterAdd.php b/application/forms/FilterAdd.php
index af4f9b2..091eb37 100644
--- a/application/forms/FilterAdd.php
+++ b/application/forms/FilterAdd.php
@@ -2,6 +2,7 @@
class Application_Form_FilterAdd extends Zend_Form
{
+ private $bootmenus;
public function init()
{
@@ -22,14 +23,16 @@ class Application_Form_FilterAdd extends Zend_Form
'label' => 'Description:',
));
- $this->addElement('text', 'bootmenuID', array(
- 'filters' => array('StringTrim'),
- 'validators' => array(
- array('StringLength', false, array(0, 50)),
- ),
- 'required' => true,
- 'label' => 'bootmenuID:',
- ));
+ $bootmenufield = $this->createElement('select','bootmenuID');
+ $bootmenufield ->setLabel('Bootmenu:');
+
+ if(count($this->bootmenus)>0){
+ foreach($this->bootmenus as $id => $g){
+ $bootmenufield->addMultiOption($g->getID(), $g->getTitle());
+ }
+ }
+ $bootmenufield->setRegisterInArrayValidator(false);
+ $this->addElement($bootmenufield);
$this->addElement('text', 'priority', array(
'filters' => array('StringTrim'),
@@ -45,7 +48,10 @@ class Application_Form_FilterAdd extends Zend_Form
'label' => 'Save',
));
}
-
+ function setBootmenus($val){
+ $this->bootmenus = $val;
+ return;
+ }
}
diff --git a/application/forms/FilterEvaluate.php b/application/forms/FilterEvaluate.php
new file mode 100644
index 0000000..2c93aef
--- /dev/null
+++ b/application/forms/FilterEvaluate.php
@@ -0,0 +1,123 @@
+<?php
+
+class Application_Form_FilterEvaluate extends Zend_Form
+{
+ private $pools;
+ private $bootisos;
+ private $memberships;
+ private $groups;
+ private $clients;
+
+ public function init()
+ {
+ $this->setName("Test Filter");
+ $this->setMethod('post');
+ $this->setAction('/filter/evaluate');
+
+ $this->addElement('text', 'ip', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => false,
+ 'label' => 'IP:',
+ ));
+ ######################################
+ $this->addElement('text', 'mac', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => false,
+ 'label' => 'Mac:',
+ ));
+ ######################################
+ $poolfield = $this->createElement('select','poolID');
+ $poolfield ->setLabel('Pool:');
+ $poolfield->addMultiOption('','');
+ if(count($this->pools)>0){
+ foreach($this->pools as $id => $g){
+ $poolfield->addMultiOption($g->getID(), $g->getTitle());
+ }
+ }
+ $poolfield->setRegisterInArrayValidator(false);
+ $this->addElement($poolfield);
+ ######################################
+ $bootisofield = $this->createElement('select','bootisoID');
+ $bootisofield ->setLabel('BootIso:');
+ $bootisofield->addMultiOption('','');
+ if(count($this->bootisos)>0){
+ foreach($this->bootisos as $id => $g){
+ $bootisofield->addMultiOption($g->getID(), $g->getTitle());
+ }
+ }
+ $bootisofield->setRegisterInArrayValidator(false);
+ $this->addElement($bootisofield);
+ ######################################
+ $membershipfield = $this->createElement('select','membershipID');
+ $membershipfield ->setLabel('Membership:');
+ $membershipfield->addMultiOption('','');
+ if(count($this->memberships)>0){
+ foreach($this->memberships as $id => $g){
+ $membershipfield->addMultiOption($g->getID(), $g->getPersonID());
+ }
+ }
+ $membershipfield->setRegisterInArrayValidator(false);
+ $this->addElement($membershipfield);
+ ######################################
+ $groupfield = $this->createElement('select','groupID');
+ $groupfield ->setLabel('Group:');
+ $groupfield->addMultiOption('','');
+ if(count($this->groups)>0){
+ foreach($this->groups as $id => $g){
+ $groupfield->addMultiOption($g->getID(), $g->getTitle());
+ }
+ }
+ $groupfield->setRegisterInArrayValidator(false);
+ $this->addElement($groupfield);
+ ######################################
+ $this->addElement('text', 'time', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => false,
+ 'label' => 'Time:',
+ ));
+ ######################################
+ $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);
+
+ $this->addElement('submit', 'submit', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => 'Get It On!',
+ ));
+ }
+ function setPools($v){
+ $this->pools = $v;
+ }
+ function setBootisos($v){
+ $this->bootisos = $v;
+ }
+ function setMemberships($v){
+ $this->memberships = $v;
+ }
+ function setGroups($v){
+ $this->groups = $v;
+ }
+ function setClients($v){
+ $this->clients = $v;
+ }
+
+
+}
+
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 3d95f2f..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";
@@ -32,6 +35,14 @@ echo $this->headScript()."\n";
</div>
<div id='innerwrapper'>
<?php echo $this->layout()->content; ?>
+ <div class='clear footer'><?php
+if (Zend_Auth::getInstance()->hasIdentity()) {
+ //TODO: Display Auth info
+ // echo "<b>angemeldet</b>";
+ // echo " - <a href='/auth/logout'>logout</a>";
+}
+?></div>
</div>
</div>
+
</body></html>
diff --git a/application/models/BootMenuEntriesMapper.php b/application/models/BootMenuEntriesMapper.php
index 7a2da59..a0a5309 100644
--- a/application/models/BootMenuEntriesMapper.php
+++ b/application/models/BootMenuEntriesMapper.php
@@ -30,6 +30,24 @@ class Application_Model_BootMenuEntriesMapper
echo "Error message 2: " . $e->getMessage() . "\n";
}
}
+
+ public function findByArray($criteria, $value)
+ {
+ try{
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $select = $this->getDbTable()->select()
+ ->from($this->_dbTable)
+ ->where($criteria . ' = ?', $value)
+ ->order('order');
+ $stmt = $select->query();
+ $result = $stmt->fetchAll();
+
+ return $result;
+
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
+ }
+ }
public function setDbTable($dbTable)
{
diff --git a/application/models/BootOsMapper.php b/application/models/BootOsMapper.php
index a6e9a7f..66de08d 100644
--- a/application/models/BootOsMapper.php
+++ b/application/models/BootOsMapper.php
@@ -14,7 +14,9 @@ class Application_Model_BootOsMapper
->where($criteria . ' = ?', $value);
$stmt = $select->query();
$result = $stmt->fetchAll();
+
return $result;
+
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
@@ -87,7 +89,7 @@ class Application_Model_BootOsMapper
$entry->setID($row->bootosID)->setConfigID($row->configID)->setGroupID($row->groupID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_init($row->path_init)->setPath_kernel($row->path_kernel)->setDefaultkcl($row->defaultkcl)->setCreated($row->created)->setDescription($row->description)->setExpires($row->expires)->setPublic($row->public);
- $entries[] = $entry;
+ $entries[$row->bootosID] = $entry;
}
return $entries;
}
diff --git a/application/models/ConfigMapper.php b/application/models/ConfigMapper.php
index da7a073..d8a23c4 100644
--- a/application/models/ConfigMapper.php
+++ b/application/models/ConfigMapper.php
@@ -66,9 +66,14 @@ class Application_Model_ConfigMapper
}
}
- public function find($id)
+ public function find($id, Application_Model_Config $config = null)
{
- $config = new Application_Model_Config();
+ if($config == null){
+ $return = true;
+ }
+ if($return){
+ $config = new Application_Model_Config();
+ }
$result = $this->getDbTable()->find($id);
if (0 == count($result)) {
return;
@@ -77,7 +82,9 @@ class Application_Model_ConfigMapper
$row = $result->current();
$config->setID($row->configID)->setGroupID($row->groupID)->setMembershipID($row->membershipID)->setCreated($row->created)->setShellscript($row->shellscript)->setTitle($row->title);
- return $config;
+ if($return){
+ return $config;
+ }
}
public function fetchAll()
diff --git a/application/models/GroupMapper.php b/application/models/GroupMapper.php
index d43b3f1..463f3d1 100644
--- a/application/models/GroupMapper.php
+++ b/application/models/GroupMapper.php
@@ -66,9 +66,14 @@ class Application_Model_GroupMapper
}
}
- public function find($id)
+ public function find($id,Application_Model_Group $group = null)
{
- $group = new Application_Model_Group();
+ if($group == null){
+ $return = true;
+ }
+ if($return){
+ $group = new Application_Model_Group();
+ }
$result = $this->getDbTable()->find($id);
if (0 == count($result)) {
return;
@@ -77,7 +82,9 @@ class Application_Model_GroupMapper
$row = $result->current();
$group->setID($row->groupID)->setTitle($row->title)->setDescription($row->description);
- return $group;
+ if($return){
+ return $group;
+ }
}
public function fetchAll()
diff --git a/application/models/MembershipMapper.php b/application/models/MembershipMapper.php
index 2a6e57d..313248c 100644
--- a/application/models/MembershipMapper.php
+++ b/application/models/MembershipMapper.php
@@ -66,9 +66,14 @@ class Application_Model_MembershipMapper
}
}
- public function find($id)
+ public function find($id, Application_Model_Membership $membership = null)
{
- $membership = new Application_Model_Membership();
+ if($membership == null){
+ $return = true;
+ }
+ if($return){
+ $membership = new Application_Model_Membership();
+ }
$result = $this->getDbTable()->find($id);
if (0 == count($result)) {
return;
@@ -77,7 +82,9 @@ class Application_Model_MembershipMapper
$row = $result->current();
$membership->setID($row->membershipID)->setGroupID($row->groupID)->setRoleID($row->roleID)->setPersonID($row->personID);
- return $membership;
+ if($return){
+ return $membership;
+ }
}
public function fetchAll()
diff --git a/application/models/PersonMapper.php b/application/models/PersonMapper.php
index 038670d..b2cbf39 100644
--- a/application/models/PersonMapper.php
+++ b/application/models/PersonMapper.php
@@ -66,9 +66,14 @@ class Application_Model_PersonMapper
}
}
- public function find($id)
+ public function find($id,Application_Model_Person $person = null)
{
- $person = new Application_Model_Person();
+ if($person == null){
+ $return = true;
+ }
+ if($return){
+ $person = new Application_Model_Person();
+ }
$result = $this->getDbTable()->find($id);
if (0 == count($result)) {
return;
@@ -77,7 +82,9 @@ class Application_Model_PersonMapper
$row = $result->current();
$person->setID($row->personID)->setTitle($row->title)->setName($row->name)->setFirstname($row->firstname)->setStreet($row->street)->setHousenumber($row->housenumber)->setCity($row->city)->setPostalcode($row->postalcode)->setLogindate($row->logindate)->setRegisterdate($row->registerdate)->setEmail($row->email)->setLogin($row->login)->setPassword($row->password)->setPasswordSalt($row->password_salt);
- return $person;
+ if($return){
+ return $person;
+ }
}
public function fetchAll()
diff --git a/application/views/scripts/bootmenu/index.phtml b/application/views/scripts/bootmenu/index.phtml
index 6fb55e4..fa722e4 100644
--- a/application/views/scripts/bootmenu/index.phtml
+++ b/application/views/scripts/bootmenu/index.phtml
@@ -55,7 +55,7 @@
<td colspan=7>
<table>
<tr>
-
+ <th></th>
<th>ID</th>
<th>Title</th>
<!-- <th>BootmenuID</th>-->
@@ -70,7 +70,12 @@
<?php foreach ($this->bootmenuentrylist[$bootmenu->getID()] as $bootmenuentry): ?>
<?php $bootos = $this->bootosmapper->find($bootmenuentry->getBootosID());?>
<?php $config = $this->configmapper->find($bootmenuentry->getConfigID());?>
- <tr>
+ <tr>
+ <td class='action'>
+ <a href='/resource/getbootmenuentry/bootmenuentryID/<?php echo $bootmenuentry->getID();?>'>
+ <img src='/media/img/play.gif'>
+ </a>
+ </td>
<td><?php echo $this->escape($bootmenuentry->getID()); ?></td>
<td><?php echo $this->escape($bootmenuentry->getTitle()); ?></td>
<!--<td><?php echo $this->escape($bootmenuentry->getBootmenuID()); ?></td>
diff --git a/application/views/scripts/filter/index.phtml b/application/views/scripts/filter/index.phtml
index 6f98b4c..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(
@@ -43,13 +45,17 @@
'default',
true) ?>"><img src='/media/img/add.png' alt='Add Filterentry'/></a></td>
</tr>
+ <?php
+ $fe = new Application_Model_FilterEntriesMapper();
+ # print_a($erg = $fe->findBy('filterID',$filter->getID()));
+ $erg = $fe->findBy('filterID',$filter->getID());
+ ?>
+ <?php if (count($erg)>0): ?>
<tr class=detail>
<td class=arrowtop>↳</td>
- <td colspan=6>
+ <td colspan=7>
<?php
- $fe = new Application_Model_FilterEntriesMapper();
- # print_a($erg = $fe->findBy('filterID',$filter->getID()));
- $erg = $fe->findBy('filterID',$filter->getID());
+
?>
<table>
<tr>
@@ -96,6 +102,7 @@
</table>
</td>
</tr>
+ <?php endif;?>
<?php endforeach ?>
</table>
@@ -105,3 +112,6 @@
<p>There are no filters to display.</p>
<?php endif;?>
+<?php echo $this->formButton('createconfig', 'Test Filters', array(
+ 'onclick' => 'self.location="/filter/testevaluate"',
+ 'class' => 'addbutton'))?>
diff --git a/application/views/scripts/filter/testevaluate.phtml b/application/views/scripts/filter/testevaluate.phtml
new file mode 100644
index 0000000..8a10629
--- /dev/null
+++ b/application/views/scripts/filter/testevaluate.phtml
@@ -0,0 +1,4 @@
+<h1>Test Filters</h1>
+
+<?php
+echo $this->filterevaluate;
diff --git a/application/views/scripts/pool/index.phtml b/application/views/scripts/pool/index.phtml
index f89dbc9..2c6ba16 100644
--- a/application/views/scripts/pool/index.phtml
+++ b/application/views/scripts/pool/index.phtml
@@ -43,6 +43,11 @@
'default',
true) ?>"><img src='/media/img/add.png' alt='Link Client'/></a></td>
</tr>
+ <?php
+ $poolentriesMapper = new Application_Model_PoolEntriesMapper();
+ $clients = $poolentriesMapper->findBy('poolID',$pool->getID());
+ ?>
+ <?php if (count($clients)>0): ?>
<tr class=detail>
<td class=arrowtop>↳</td>
<td colspan=6>
@@ -54,8 +59,6 @@
<th>Actions</th>
</tr>
<?php
- $poolentriesMapper = new Application_Model_PoolEntriesMapper();
- $clients = $poolentriesMapper->findBy('poolID',$pool->getID());
foreach ($clients as $client): ?>
<tr>
<td><?php echo $client['clientID'];?></td>
@@ -77,14 +80,18 @@
</tr>
<?php endforeach ?>
</table>
+ </td>
+ </tr>
+ <?php endif;?>
<?php endforeach ?>
</table>
<h2>Free clients</h2>
<table >
-<tr><th>ClientID</th><th>MacAdress</th><th>Hardwarehash</th>
-<?php foreach ($this->pools as $pool): ?>
- <th><?php echo $this->escape($pool->getTitle()) ?></th>
- <?php endforeach ?>
+<tr>
+<th>ClientID</th>
+<th>MacAdress</th>
+<th>Hardwarehash</th>
+<th>Actions</th>
</tr>
<?php
foreach ($this->freeclients as $client): ?>
@@ -92,7 +99,8 @@ foreach ($this->freeclients as $client): ?>
<td><?php echo $client['clientID']; ?></td>
<td><?php echo $client['macadress']; ?></td>
<td><?php echo $client['hardwarehash']; ?></td>
- <td><select>
+ <td><select onChange="location.href=this.options[this.selectedIndex].value">
+ <option></option>
<?php foreach ($this->pools as $pool): ?>
<option value="<?php echo $this->url(
array(
diff --git a/application/views/scripts/resource/get-bootmenu-entry.phtml b/application/views/scripts/resource/get-bootmenu-entry.phtml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/application/views/scripts/resource/get-bootmenu-entry.phtml
diff --git a/application/views/scripts/resource/index.phtml b/application/views/scripts/resource/index.phtml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/application/views/scripts/resource/index.phtml
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(