From c113eb1ddd0263664b6ddaa22291469b56867a6c Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 8 Mar 2011 18:37:35 +0100 Subject: filtertypes implementiert --- application/controllers/FilterController.php | 94 ++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 25 deletions(-) (limited to 'application/controllers/FilterController.php') diff --git a/application/controllers/FilterController.php b/application/controllers/FilterController.php index df8db07..a8a1636 100644 --- a/application/controllers/FilterController.php +++ b/application/controllers/FilterController.php @@ -262,11 +262,18 @@ class FilterController extends Zend_Controller_Action $db = $this->db; $showPartResults = false; try{ + + $mysession = '1'; + + $filtertypID = 8; + $session = new Application_Model_Session(); + $sessionmapper = new Application_Model_SessionMapper(); + $sessionmapper->find($mysession,$session); ######################################################### // IP Adress $filtertypID = 1; // get it from session_table with session_id from the session - $ipAdress = "111.10.10.10"; + $ipAdress = $session->getIp(); $ipAdress = str_replace(".","",$this->fillIP($ipAdress)); $select = $db->select() ->from(array('pbs_filterentries') @@ -281,13 +288,16 @@ class FilterController extends Zend_Controller_Action $set[$filtertypID][] = $r['filterID']; } if($showPartResults) - print_a('ipAdress',$result,$set[$filtertypID]); - + print_a('ipAdress',$result,$set[$filtertypID]); ######################################################### // Mac range $filtertypID = 2; // get it from session_table with session_id from the session - $macAdress = "00:1e:0b:27:f4:99"; + $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 @@ -303,47 +313,81 @@ class FilterController extends Zend_Controller_Action // PoolID $filtertypID = 3; // get PoolID from client_ID from session_id from the session - $poolid = 1; + $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.' "); + filtervalue = ".$poolID." "); $result = $stmt->fetchAll(); foreach($result as $r){ $set[$filtertypID][] = $r['filterID']; } if($showPartResults) print_a('poolID',$result,$set[$filtertypID]); - /* - If client comes from a specific pool - */ ######################################################### - // ClientID - $filtertypID = 8; - // get client_ID from session_id from the session - /* - If client is a specific client - */ + // 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($showPartResults) + print_a('clientID',$result,$set[$filtertypID]); ######################################################### // BootIsoID $filtertypID = 4; - // get BootIsoID from client_ID from session_id from the session - /* - WHERE bootiso = bootiso - */ + // 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']; + } + if($showPartResults) + print_a('bootisoID',$result,$set[$filtertypID]); ######################################################### // MembershipID $filtertypID = 5; // get membership from the session - /* - user is in a defined membership - */ + //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($showPartResults) + print_a('membership',$result,$set[$filtertypID]); ######################################################### // GroupID $filtertypID = 6; // get membership from the session - /* - user is in a defined groupID - */ + //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($showPartResults) + print_a('membership',$result,$set[$filtertypID]); ######################################################### // Time $filtertypID = 7; -- cgit v1.2.3-55-g7522 From 260b7860bcfcd6ad4d80437bad1d9b885c680e75 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 8 Mar 2011 19:12:36 +0100 Subject: arbeiten zur oberflächenvereinheitlichung --- application/Bootstrap.php | 12 ++++++++++++ application/configs/application.ini.dist | 2 ++ application/controllers/FilterController.php | 4 +--- application/forms/FilterAdd.php | 10 +++++++++- application/layouts/main.phtml | 21 +++++++++++++++++++++ application/media/css/style.css | 3 +++ application/views/scripts/filter/index.phtml | 1 - 7 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 application/layouts/main.phtml create mode 100644 application/media/css/style.css (limited to 'application/controllers/FilterController.php') diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 224ffcb..7f24b84 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -14,6 +14,18 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap $view->headTitle('pbs2') ->setSeparator(' :: '); } + function _initViewHelpers() + { + $this->bootstrap('layout'); + $layout = $this->getResource('layout'); + $view = $layout->getView(); + + $view->doctype('XHTML1_STRICT'); + $view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8'); + $view->headLink()->appendStylesheet('/media/css/styles.css'); + $view->headTitle()->setSeparator(' - '); + $view->headTitle('pbs2'); + } } function print_a(){ $numargs = func_num_args(); diff --git a/application/configs/application.ini.dist b/application/configs/application.ini.dist index 48e29e5..b19bac8 100644 --- a/application/configs/application.ini.dist +++ b/application/configs/application.ini.dist @@ -14,6 +14,8 @@ resources.db.params.password = resources.db.params.dbname = pbs resources.db.isDefaultTableAdapter = true resources.view[] = "" +resources.layout.layoutPath = APPLICATION_PATH "/layouts" +resources.layout.layout = "main" [staging : production] diff --git a/application/controllers/FilterController.php b/application/controllers/FilterController.php index a8a1636..1ebb35e 100644 --- a/application/controllers/FilterController.php +++ b/application/controllers/FilterController.php @@ -42,8 +42,7 @@ class FilterController extends Zend_Controller_Action // TODO: Ändere mit ACL $newfilter->setGroupID('1'); - $newfilter->setMembershipID('1'); - $newfilter->setBootmenuID('1'); + $newfilter->setMembershipID('1'); $newfilter2 = new Application_Model_FilterMapper(); $newfilter2->save($newfilter); @@ -95,7 +94,6 @@ class FilterController extends Zend_Controller_Action //TODO: ACL integrieren $_POST['groupID'] = 1; $_POST['membershipID'] = 1; - $_POST['bootmenuID'] = 1; $_POST['created'] = time(); if ($editfilterform->isValid($_POST)) { diff --git a/application/forms/FilterAdd.php b/application/forms/FilterAdd.php index 931bfee..af4f9b2 100644 --- a/application/forms/FilterAdd.php +++ b/application/forms/FilterAdd.php @@ -21,7 +21,15 @@ class Application_Form_FilterAdd extends Zend_Form 'required' => false, 'label' => 'Description:', )); - // TODO: Add target of Filter + + $this->addElement('text', 'bootmenuID', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'bootmenuID:', + )); $this->addElement('text', 'priority', array( 'filters' => array('StringTrim'), diff --git a/application/layouts/main.phtml b/application/layouts/main.phtml new file mode 100644 index 0000000..51dd89c --- /dev/null +++ b/application/layouts/main.phtml @@ -0,0 +1,21 @@ +doctype(); ?> + + +
+ +headTitle(); +echo $this->headMeta(); +echo $this->headStyle(); +echo $this->headLink(); +echo $this->headScript(); +?> + + + + +layout()->content; ?> + + diff --git a/application/media/css/style.css b/application/media/css/style.css new file mode 100644 index 0000000..b215f86 --- /dev/null +++ b/application/media/css/style.css @@ -0,0 +1,3 @@ +html{ + background-color:#FFCC33; +} diff --git a/application/views/scripts/filter/index.phtml b/application/views/scripts/filter/index.phtml index 0b738e0..5d70735 100644 --- a/application/views/scripts/filter/index.phtml +++ b/application/views/scripts/filter/index.phtml @@ -1,4 +1,3 @@ -headTitle() ?>