From 3a57892f9145bfadac4cf3bf4392020f99e0d541 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 5 Mar 2011 17:41:24 +0100 Subject: filter-oberffäche fertig, nun zur auswahl des bootmenus && funktion toArray bei jedem Mapper hinzugefügt, um populate bei Formularen nutzen zu können --- .gitignore | 3 +- application/controllers/FilterController.php | 191 +++++++++++++++------ application/forms/FilterAdd.php | 4 +- application/forms/FilterEdit.php | 35 ---- application/forms/FilterEntriesAdd.php | 6 +- application/models/BootIso.php | 34 ++++ application/models/BootMenu.php | 34 ++++ application/models/BootMenuEntries.php | 34 ++++ application/models/BootOs.php | 34 ++++ application/models/Client.php | 34 ++++ application/models/Config.php | 34 ++++ application/models/Filter.php | 34 ++++ application/models/FilterEntries.php | 34 ++++ application/models/FilterEntriesMapper.php | 34 +++- application/models/FilterMapper.php | 20 ++- application/models/FilterType.php | 34 ++++ application/models/Group.php | 34 ++++ application/models/GroupGroups.php | 34 ++++ application/models/GroupRequest.php | 34 ++++ application/models/Membership.php | 34 ++++ application/models/Person.php | 34 ++++ application/models/Pool.php | 34 ++++ application/models/PoolEntries.php | 34 ++++ application/models/PoolFilters.php | 34 ++++ application/models/Right.php | 34 ++++ application/models/RightRoles.php | 34 ++++ application/models/Role.php | 34 ++++ application/models/Session.php | 34 ++++ application/views/scripts/filter/editfilter.phtml | 1 + .../views/scripts/filter/editfilterentry.phtml | 3 + application/views/scripts/filter/index.phtml | 48 ++++-- .../views/scripts/filter/removefilterentry.phtml | 0 32 files changed, 933 insertions(+), 126 deletions(-) create mode 100644 application/views/scripts/filter/editfilterentry.phtml create mode 100644 application/views/scripts/filter/removefilterentry.phtml diff --git a/.gitignore b/.gitignore index 3743eb5..3184cc6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ library/ +.gitignore .metadata/ .project .buildpath .settings/ -application/config/application.ini +application/configs/application.ini diff --git a/application/controllers/FilterController.php b/application/controllers/FilterController.php index 6acaae8..3f7fa73 100644 --- a/application/controllers/FilterController.php +++ b/application/controllers/FilterController.php @@ -32,55 +32,86 @@ class FilterController extends Zend_Controller_Action public function addfilterAction() { if (!isset($_POST["add"])){ - $addfilterform = new Application_Form_FilterAdd(); - $this->view->addfilterform = $addfilterform; - }else { - $addfilterform = new Application_Form_FilterAdd($_POST); - if ($addfilterform->isValid($_POST)) { - try{ - $newfilter = new Application_Model_Filter(); - $newfilter->setTitle($_POST['title']); - $newfilter->setCreated(time()); - $newfilter->setDescription($_POST['description']); - $newfilter->setPriority($_POST['priority']); - - // TODO: Ändere mit ACL - $newfilter->setGroupID('1'); - $newfilter->setMembershipID('1'); - $newfilter->setBootmenuID('1'); - - $newfilter2 = new Application_Model_FilterMapper(); - $newfilter2->save($newfilter); - - $this->_redirect('/filter'); - return; - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - } - } + $addfilterform = new Application_Form_FilterAdd(); + $this->view->addfilterform = $addfilterform; + }else { + $addfilterform = new Application_Form_FilterAdd($_POST); + if ($addfilterform->isValid($_POST)) { + try{ + $newfilter = new Application_Model_Filter(); + $newfilter->setTitle($_POST['title']); + $newfilter->setCreated(time()); + $newfilter->setDescription($_POST['description']); + $newfilter->setPriority($_POST['priority']); + + // TODO: Ändere mit ACL + $newfilter->setGroupID('1'); + $newfilter->setMembershipID('1'); + $newfilter->setBootmenuID('1'); + + $newfilter2 = new Application_Model_FilterMapper(); + $newfilter2->save($newfilter); + + $this->_redirect('/filter'); + return; + }catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + } } } public function removefilterAction() { - echo 'test'; - print_r($_GET); - $filterID = $this->_request->getParam('filterID'); - // TODO: ACL implementieren ob er den filter löschen darf - if(is_numeric($filterID)){ - // TODO: lösche den aktuellen eintrag - $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() { - // TODO: ACL implementieren ob er editieren darf - // TODO: korrigieren, damit man einen filter (priorität und namen ändern kann) + 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{ + echo "
";print_r($_POST);echo ""; + $editfilterform = new Application_Form_FilterAdd(); + //TODO: ACL integrieren + $_POST['groupID'] = 1; + $_POST['membershipID'] = 1; + $_POST['bootmenuID'] = 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); + } + + }catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + $this->_redirect('/filter'); + } } public function addfilterentryAction() @@ -104,8 +135,8 @@ class FilterController extends Zend_Controller_Action $newfilterenty = new Application_Model_FilterEntries(); $newfilterenty->setFilterID($_POST['filterID']); - $newfilterenty->setFiltertypeID($_POST['filtertype']); - $newfilterenty->setFiltervalue($_POST['filtervalue1']); + $newfilterenty->setFiltertypeID($_POST['filtertypeID']); + $newfilterenty->setFiltervalue($_POST['filtervalue']); $newfilterenty->setFiltervalue2($_POST['filtervalue2']); $newfilter2 = new Application_Model_FilterEntriesMapper(); @@ -117,25 +148,71 @@ class FilterController extends Zend_Controller_Action } public function editfilterentryAction() { - + if (!isset($_POST["add"])){ + echo "case1"; + try{ + $filterID = $this->_request->getParam('filterID'); + $filtertypeID = $this->_request->getParam('filtertypeID'); + + + $filterentry = new Application_Model_FilterEntries(); + + $filterentriesmapper = new Application_Model_FilterEntriesMapper(); + $filterentriesmapper->find($filterID,$filtertypeID,$filterentry); + + $editfilterform = new Application_Form_FilterEntriesAdd(); + echo "
"; + print_r($filterentry->toArray()); + echo ""; + $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"; + } + } else{ + $editfilterform = new Application_Form_FilterEntriesAdd($_POST); + echo "case2"; + echo "
"; + print_r($_POST); + echo ""; + if ($editfilterform->isValid($_POST)) { + echo "valid\n"; + $newfilterenty = new Application_Model_FilterEntries($_POST); + $newfilter2 = new Application_Model_FilterEntriesMapper(); + $newfilter2->save($newfilterenty); + + } + else{ + echo 'nö'; + } + $this->_redirect('/filter'); + } } public function removefilterentryAction() { - echo 'test'; - $filterID = $this->_request->getParam('filterID'); - $filtertypeID = $this->_request->getParam('filtertypeID'); - var_dump(array($filterID,$filtertypeID)); - // TODO: ACL implementieren ob er den filter löschen darf - if(is_numeric($filterID)){ - // TODO: lösche den aktuellen eintrag - $deletefilterentry = new Application_Model_FilterEntries(); - $deletefilterentry->setFilterID($filterID); - $deletefilterentry->setFiltertypeID($filtertypeID); - - $filterentriesmapper = new Application_Model_FilterEntriesMapper(); - $filterentriesmapper->delete($deletefilterentry); + + try{ + $filterID = $this->_request->getParam('filterID'); + $filtertypeID = $this->_request->getParam('filtertypeID'); + echo "
"; + var_dump(array($filterID,$filtertypeID)); + echo ""; + // TODO: ACL implementieren ob er den filter löschen darf + if(is_numeric($filterID)){ + $deletefilterentry = new Application_Model_FilterEntries(); + $deletefilterentry->setFilterID($filterID); + $deletefilterentry->setFiltertypeID($filtertypeID); + + $filterentriesmapper = new Application_Model_FilterEntriesMapper(); + $filterentriesmapper->delete($deletefilterentry); + } + $this->_redirect('/filter'); + }catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; } - #$this->_redirect('/filter'); } diff --git a/application/forms/FilterAdd.php b/application/forms/FilterAdd.php index 825d3f2..c3395c6 100644 --- a/application/forms/FilterAdd.php +++ b/application/forms/FilterAdd.php @@ -29,10 +29,10 @@ class Application_Form_FilterAdd extends Zend_Form 'required' => true, 'label' => 'Priority:', )); - $this->addElement('submit', 'add', array( + $submit = $this->addElement('submit', 'add', array( 'required' => false, 'ignore' => true, - 'label' => 'Add Filter', + 'label' => 'Save', )); } diff --git a/application/forms/FilterEdit.php b/application/forms/FilterEdit.php index 5d5a242..ee4f637 100644 --- a/application/forms/FilterEdit.php +++ b/application/forms/FilterEdit.php @@ -6,42 +6,7 @@ class Application_Form_FilterEdit extends Zend_Form public function init() { - $this->setName("Add Filter"); - $this->setMethod('post'); - - - try{ - $filtertypemapper = new Application_Model_FilterTypeMapper(); - $filtertype = $filtertypemapper->fetchAll(); - }catch (Zend_Exception $e) { - echo "Error message 1: " . $e->getMessage() . "\n"; - } - - $filtertypes = $this->createElement('select','filtertype'); - $filtertypes ->setLabel('Type:'); - foreach($filtertype as $f){ - $filtertypes->addMultiOption($f->getID(),$f->getFiltertypename()); - } - $this->addElement($filtertypes); - - $this->addElement('text', 'filtervalue1', array( - 'label' => 'Value1:' - )); - - $this->addElement('text', 'filtervalue2', array( - 'label' => 'Value2:' - )); - - $this->addElement('hidden', 'filterID', array( - 'value' => $this->filterID - )); - - $this->addElement('submit', 'add', array( - 'required' => false, - 'ignore' => true, - 'label' => 'Add Filtertype', - )); } public function setFilterID($id) { diff --git a/application/forms/FilterEntriesAdd.php b/application/forms/FilterEntriesAdd.php index 8ec5bd9..2fd19ae 100644 --- a/application/forms/FilterEntriesAdd.php +++ b/application/forms/FilterEntriesAdd.php @@ -18,7 +18,7 @@ class Application_Form_FilterEntriesAdd extends Zend_Form echo "Error message 1: " . $e->getMessage() . "\n"; } - $filtertypes = $this->createElement('select','filtertype'); + $filtertypes = $this->createElement('select','filtertypeID'); $filtertypes ->setLabel('Type:'); foreach($filtertype as $f){ $filtertypes->addMultiOption($f->getID(),$f->getFiltertypename()); @@ -26,7 +26,7 @@ class Application_Form_FilterEntriesAdd extends Zend_Form $this->addElement($filtertypes); - $this->addElement('text', 'filtervalue1', array( + $this->addElement('text', 'filtervalue', array( 'label' => 'Value1:' )); @@ -41,7 +41,7 @@ class Application_Form_FilterEntriesAdd extends Zend_Form $this->addElement('submit', 'add', array( 'required' => false, 'ignore' => true, - 'label' => 'Add Filtertype', + 'label' => 'Save', )); } public function setFilterID($id) diff --git a/application/models/BootIso.php b/application/models/BootIso.php index 706a0a2..0fce948 100644 --- a/application/models/BootIso.php +++ b/application/models/BootIso.php @@ -124,5 +124,39 @@ class Application_Model_BootIso $this->_bootisoID = $_bootisoID; return $this; } + /** + * Returns current data as associative array using ReflectionClass + * + * @return array Returns associative array containing model data + * If "get"-method not available (our primary keys) the function getID() is called + */ + public function toArray() + { + $reflectionClass = new ReflectionClass($this); + $properties = $reflectionClass->getProperties(); + $result = array(); + foreach ($properties as $property) { + $key = $property->name; + if (substr($key, 0, 1) != '_' && $this->$key !== null) { + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + } else { + $result[$key] = $this->$key; + } + } + elseif(substr($key, 0, 1) == '_' && $this->$key !== null) { + $key = substr($key, 1); + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + }else{ + $result[$key] = $this->getID(); + } + + } + } + return $result; + } } diff --git a/application/models/BootMenu.php b/application/models/BootMenu.php index 5a3e8b9..09a5c0d 100644 --- a/application/models/BootMenu.php +++ b/application/models/BootMenu.php @@ -80,5 +80,39 @@ class Application_Model_BootMenu $this->_time = $_time; return $this; } + /** + * Returns current data as associative array using ReflectionClass + * + * @return array Returns associative array containing model data + * If "get"-method not available (our primary keys) the function getID() is called + */ + public function toArray() + { + $reflectionClass = new ReflectionClass($this); + $properties = $reflectionClass->getProperties(); + $result = array(); + foreach ($properties as $property) { + $key = $property->name; + if (substr($key, 0, 1) != '_' && $this->$key !== null) { + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + } else { + $result[$key] = $this->$key; + } + } + elseif(substr($key, 0, 1) == '_' && $this->$key !== null) { + $key = substr($key, 1); + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + }else{ + $result[$key] = $this->getID(); + } + + } + } + return $result; + } } diff --git a/application/models/BootMenuEntries.php b/application/models/BootMenuEntries.php index 0b88402..9b6985c 100644 --- a/application/models/BootMenuEntries.php +++ b/application/models/BootMenuEntries.php @@ -89,6 +89,40 @@ class Application_Model_BootMenuEntries $this->_order = $_order; return $this; } + /** + * Returns current data as associative array using ReflectionClass + * + * @return array Returns associative array containing model data + * If "get"-method not available (our primary keys) the function getID() is called + */ + public function toArray() + { + $reflectionClass = new ReflectionClass($this); + $properties = $reflectionClass->getProperties(); + $result = array(); + foreach ($properties as $property) { + $key = $property->name; + if (substr($key, 0, 1) != '_' && $this->$key !== null) { + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + } else { + $result[$key] = $this->$key; + } + } + elseif(substr($key, 0, 1) == '_' && $this->$key !== null) { + $key = substr($key, 1); + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + }else{ + $result[$key] = $this->getID(); + } + + } + } + return $result; + } } diff --git a/application/models/BootOs.php b/application/models/BootOs.php index a2eea2f..b61be41 100644 --- a/application/models/BootOs.php +++ b/application/models/BootOs.php @@ -151,5 +151,39 @@ class Application_Model_BootOs $this->_public = $_public; return $this; } + /** + * Returns current data as associative array using ReflectionClass + * + * @return array Returns associative array containing model data + * If "get"-method not available (our primary keys) the function getID() is called + */ + public function toArray() + { + $reflectionClass = new ReflectionClass($this); + $properties = $reflectionClass->getProperties(); + $result = array(); + foreach ($properties as $property) { + $key = $property->name; + if (substr($key, 0, 1) != '_' && $this->$key !== null) { + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + } else { + $result[$key] = $this->$key; + } + } + elseif(substr($key, 0, 1) == '_' && $this->$key !== null) { + $key = substr($key, 1); + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + }else{ + $result[$key] = $this->getID(); + } + + } + } + return $result; + } } diff --git a/application/models/Client.php b/application/models/Client.php index 9216b20..a27c3b3 100644 --- a/application/models/Client.php +++ b/application/models/Client.php @@ -71,5 +71,39 @@ class Application_Model_Client $this->_hardwarehash = $_hardwarehash; return $this; } + /** + * Returns current data as associative array using ReflectionClass + * + * @return array Returns associative array containing model data + * If "get"-method not available (our primary keys) the function getID() is called + */ + public function toArray() + { + $reflectionClass = new ReflectionClass($this); + $properties = $reflectionClass->getProperties(); + $result = array(); + foreach ($properties as $property) { + $key = $property->name; + if (substr($key, 0, 1) != '_' && $this->$key !== null) { + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + } else { + $result[$key] = $this->$key; + } + } + elseif(substr($key, 0, 1) == '_' && $this->$key !== null) { + $key = substr($key, 1); + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + }else{ + $result[$key] = $this->getID(); + } + + } + } + return $result; + } } diff --git a/application/models/Config.php b/application/models/Config.php index 94ff256..b9a29dc 100644 --- a/application/models/Config.php +++ b/application/models/Config.php @@ -71,5 +71,39 @@ class Application_Model_Config $this->_shellscript = $_shellscript; return $this; } + /** + * Returns current data as associative array using ReflectionClass + * + * @return array Returns associative array containing model data + * If "get"-method not available (our primary keys) the function getID() is called + */ + public function toArray() + { + $reflectionClass = new ReflectionClass($this); + $properties = $reflectionClass->getProperties(); + $result = array(); + foreach ($properties as $property) { + $key = $property->name; + if (substr($key, 0, 1) != '_' && $this->$key !== null) { + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + } else { + $result[$key] = $this->$key; + } + } + elseif(substr($key, 0, 1) == '_' && $this->$key !== null) { + $key = substr($key, 1); + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + }else{ + $result[$key] = $this->getID(); + } + + } + } + return $result; + } } diff --git a/application/models/Filter.php b/application/models/Filter.php index f90c985..b77cf97 100644 --- a/application/models/Filter.php +++ b/application/models/Filter.php @@ -121,5 +121,39 @@ class Application_Model_Filter $this->_priority = $_priority; return $this; } + /** + * Returns current data as associative array using ReflectionClass + * + * @return array Returns associative array containing model data + * If "get"-method not available (our primary keys) the function getID() is called + */ + public function toArray() + { + $reflectionClass = new ReflectionClass($this); + $properties = $reflectionClass->getProperties(); + $result = array(); + foreach ($properties as $property) { + $key = $property->name; + if (substr($key, 0, 1) != '_' && $this->$key !== null) { + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + } else { + $result[$key] = $this->$key; + } + } + elseif(substr($key, 0, 1) == '_' && $this->$key !== null) { + $key = substr($key, 1); + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + }else{ + $result[$key] = $this->getID(); + } + + } + } + return $result; + } } diff --git a/application/models/FilterEntries.php b/application/models/FilterEntries.php index 63aa864..59f62e5 100644 --- a/application/models/FilterEntries.php +++ b/application/models/FilterEntries.php @@ -81,5 +81,39 @@ class Application_Model_FilterEntries $this->_filtervalue2 = $_filtervalue2; return $this; } + /** + * Returns current data as associative array using ReflectionClass + * + * @return array Returns associative array containing model data + * If "get"-method not available (our primary keys) the function getID() is called + */ + public function toArray() + { + $reflectionClass = new ReflectionClass($this); + $properties = $reflectionClass->getProperties(); + $result = array(); + foreach ($properties as $property) { + $key = $property->name; + if (substr($key, 0, 1) != '_' && $this->$key !== null) { + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + } else { + $result[$key] = $this->$key; + } + } + elseif(substr($key, 0, 1) == '_' && $this->$key !== null) { + $key = substr($key, 1); + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + }else{ + $result[$key] = $this->getID(); + } + + } + } + return $result; + } } diff --git a/application/models/FilterEntriesMapper.php b/application/models/FilterEntriesMapper.php index 54d6e3a..ef2c28f 100644 --- a/application/models/FilterEntriesMapper.php +++ b/application/models/FilterEntriesMapper.php @@ -31,20 +31,31 @@ class Application_Model_FilterEntriesMapper public function save(Application_Model_FilterEntries $filterentries) { - + try{ $data = array('filterID'=> $filterentries->getFilterID() , 'filtertypeID'=> $filterentries->getFiltertypeID() , 'filtervalue'=> $filterentries->getFiltervalue() , 'filtervalue2'=> $filterentries->getFiltervalue2() ); - - if (null != ($id1 = $filterentries->getFilterID()) && - null != ($id2 = $filterentries->getFiltertypeID()) && - $this->getDbTable()->find($filterentries->getFilterID(),$filterentries->getFiltertypeID())) { + + $filterentries2 = new Application_Model_FilterEntries(); + $result = $this->find($filterentries->getFilterID(),$filterentries->getFiltertypeID(),$filterentries2); + echo "
"; + print_r(array($filterentries,$filterentries2,$result)); + echo ""; + $id1 = $filterentries->getFilterID(); + $id2 = $filterentries->getFiltertypeID(); + if (0 == count($result) && + null != $id1 && + null != $id2) { $this->getDbTable()->insert($data); - echo 'fall1'; + echo 'inserted'; } else { - $this->getDbTable()->update($data, array('filterID = ?' => $id1, 'filtertypeID = ?' => $id2)); - echo 'fall2'; + print_r($this->getDbTable()->update($data, array('filterID = ?' => $id1, 'filtertypeID = ?' => $id2))); + echo 'updated'; + } + + }catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; } } @@ -53,13 +64,18 @@ class Application_Model_FilterEntriesMapper try{ $id1 = $filterentries->getFilterID(); $id2 = $filterentries->getFiltertypeID(); + echo "
"; + echo "-----------\n"; var_dump(array($id1,$id2)); + echo ""; //TODO: Löschen klappt nicht - if ((null != $id1) && (null != $id2) && + if ((null == $id1) && (null == $id2) && $this->getDbTable()->find($filterentries->getFilterID(),$filterentries->getFiltertypeID())) { + echo 'case1'; return; } else { $this->getDbTable()->delete(array('filterID = ?' => $id1, 'filtertypeID = ?' => $id2)); + echo 'case2'; } }catch (Zend_Exception $e) { diff --git a/application/models/FilterMapper.php b/application/models/FilterMapper.php index 0ac3cb3..3960c0d 100644 --- a/application/models/FilterMapper.php +++ b/application/models/FilterMapper.php @@ -33,12 +33,17 @@ class Application_Model_FilterMapper { $data = array('filterID'=> $filter->getID() ,'membershipID'=> $filter->getMembershipID() ,'groupID'=> $filter->getGroupID() ,'bootmenuID'=> $filter->getBootmenuID() ,'title'=> $filter->getTitle() ,'description'=> $filter->getDescription() ,'created'=> $filter->getCreated() ,'priority'=> $filter->getPriority() ); + echo "
";
+ print_r(array('woot',$filter->getID()));
+ echo "";
if (null === ($id = $filter->getID()) ) {
unset($data['filterID']);
$this->getDbTable()->insert($data);
+ echo 'case1';
} else {
$this->getDbTable()->update($data, array('filterID = ?' => $id));
+ echo 'case2';
}
}
@@ -52,15 +57,22 @@ class Application_Model_FilterMapper
}
public function find($id, Application_Model_Filter $filter)
- {
+ {
+
$result = $this->getDbTable()->find($id);
if (0 == count($result)) {
return;
}
-
$row = $result->current();
- $filter->setID($row->filterID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setBootmenuID($row->bootmenuID)->setTitle($row->title)->setDescription($row->description)->setCreated($row->created)->setPriority($row->priority);
+ $filter->setID($row->filterID)
+ ->setMembershipID($row->membershipID)
+ ->setGroupID($row->groupID)
+ ->setBootmenuID($row->bootmenuID)
+ ->setTitle($row->title)
+ ->setDescription($row->description)
+ ->setCreated($row->created)
+ ->setPriority($row->priority);
}
public function fetchAll()
@@ -76,7 +88,7 @@ class Application_Model_FilterMapper
}
return $entries;
}
-
+
}
diff --git a/application/models/FilterType.php b/application/models/FilterType.php
index a66950a..3293083 100644
--- a/application/models/FilterType.php
+++ b/application/models/FilterType.php
@@ -61,5 +61,39 @@ class Application_Model_FilterType
$this->_filtertypename = $_filtertypename;
return $this;
}
+ /**
+ * Returns current data as associative array using ReflectionClass
+ *
+ * @return array Returns associative array containing model data
+ * If "get"-method not available (our primary keys) the function getID() is called
+ */
+ public function toArray()
+ {
+ $reflectionClass = new ReflectionClass($this);
+ $properties = $reflectionClass->getProperties();
+ $result = array();
+ foreach ($properties as $property) {
+ $key = $property->name;
+ if (substr($key, 0, 1) != '_' && $this->$key !== null) {
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ } else {
+ $result[$key] = $this->$key;
+ }
+ }
+ elseif(substr($key, 0, 1) == '_' && $this->$key !== null) {
+ $key = substr($key, 1);
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ }else{
+ $result[$key] = $this->getID();
+ }
+
+ }
+ }
+ return $result;
+ }
}
diff --git a/application/models/Group.php b/application/models/Group.php
index 2ef4f6a..3cfabd1 100644
--- a/application/models/Group.php
+++ b/application/models/Group.php
@@ -71,5 +71,39 @@ class Application_Model_Group
$this->_description = $_description;
return $this;
}
+ /**
+ * Returns current data as associative array using ReflectionClass
+ *
+ * @return array Returns associative array containing model data
+ * If "get"-method not available (our primary keys) the function getID() is called
+ */
+ public function toArray()
+ {
+ $reflectionClass = new ReflectionClass($this);
+ $properties = $reflectionClass->getProperties();
+ $result = array();
+ foreach ($properties as $property) {
+ $key = $property->name;
+ if (substr($key, 0, 1) != '_' && $this->$key !== null) {
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ } else {
+ $result[$key] = $this->$key;
+ }
+ }
+ elseif(substr($key, 0, 1) == '_' && $this->$key !== null) {
+ $key = substr($key, 1);
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ }else{
+ $result[$key] = $this->getID();
+ }
+
+ }
+ }
+ return $result;
+ }
}
diff --git a/application/models/GroupGroups.php b/application/models/GroupGroups.php
index 3673d57..18307e7 100644
--- a/application/models/GroupGroups.php
+++ b/application/models/GroupGroups.php
@@ -61,5 +61,39 @@ class Application_Model_GroupGroups
$this->_groupID = $_groupID;
return $this;
}
+ /**
+ * Returns current data as associative array using ReflectionClass
+ *
+ * @return array Returns associative array containing model data
+ * If "get"-method not available (our primary keys) the function getID() is called
+ */
+ public function toArray()
+ {
+ $reflectionClass = new ReflectionClass($this);
+ $properties = $reflectionClass->getProperties();
+ $result = array();
+ foreach ($properties as $property) {
+ $key = $property->name;
+ if (substr($key, 0, 1) != '_' && $this->$key !== null) {
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ } else {
+ $result[$key] = $this->$key;
+ }
+ }
+ elseif(substr($key, 0, 1) == '_' && $this->$key !== null) {
+ $key = substr($key, 1);
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ }else{
+ $result[$key] = $this->getID();
+ }
+
+ }
+ }
+ return $result;
+ }
}
diff --git a/application/models/GroupRequest.php b/application/models/GroupRequest.php
index 8c24c49..6675991 100644
--- a/application/models/GroupRequest.php
+++ b/application/models/GroupRequest.php
@@ -81,5 +81,39 @@ class Application_Model_GroupRequest
$this->_time = $_time;
return $this;
}
+ /**
+ * Returns current data as associative array using ReflectionClass
+ *
+ * @return array Returns associative array containing model data
+ * If "get"-method not available (our primary keys) the function getID() is called
+ */
+ public function toArray()
+ {
+ $reflectionClass = new ReflectionClass($this);
+ $properties = $reflectionClass->getProperties();
+ $result = array();
+ foreach ($properties as $property) {
+ $key = $property->name;
+ if (substr($key, 0, 1) != '_' && $this->$key !== null) {
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ } else {
+ $result[$key] = $this->$key;
+ }
+ }
+ elseif(substr($key, 0, 1) == '_' && $this->$key !== null) {
+ $key = substr($key, 1);
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ }else{
+ $result[$key] = $this->getID();
+ }
+
+ }
+ }
+ return $result;
+ }
}
diff --git a/application/models/Membership.php b/application/models/Membership.php
index 4107072..eaa1f97 100644
--- a/application/models/Membership.php
+++ b/application/models/Membership.php
@@ -81,5 +81,39 @@ class Application_Model_Membership
$this->_personID = $_personID;
return $this;
}
+ /**
+ * Returns current data as associative array using ReflectionClass
+ *
+ * @return array Returns associative array containing model data
+ * If "get"-method not available (our primary keys) the function getID() is called
+ */
+ public function toArray()
+ {
+ $reflectionClass = new ReflectionClass($this);
+ $properties = $reflectionClass->getProperties();
+ $result = array();
+ foreach ($properties as $property) {
+ $key = $property->name;
+ if (substr($key, 0, 1) != '_' && $this->$key !== null) {
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ } else {
+ $result[$key] = $this->$key;
+ }
+ }
+ elseif(substr($key, 0, 1) == '_' && $this->$key !== null) {
+ $key = substr($key, 1);
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ }else{
+ $result[$key] = $this->getID();
+ }
+
+ }
+ }
+ return $result;
+ }
}
diff --git a/application/models/Person.php b/application/models/Person.php
index eb26cbf..b4545e9 100644
--- a/application/models/Person.php
+++ b/application/models/Person.php
@@ -181,5 +181,39 @@ class Application_Model_Person
{
return $this->_password_salt;
}
+ /**
+ * Returns current data as associative array using ReflectionClass
+ *
+ * @return array Returns associative array containing model data
+ * If "get"-method not available (our primary keys) the function getID() is called
+ */
+ public function toArray()
+ {
+ $reflectionClass = new ReflectionClass($this);
+ $properties = $reflectionClass->getProperties();
+ $result = array();
+ foreach ($properties as $property) {
+ $key = $property->name;
+ if (substr($key, 0, 1) != '_' && $this->$key !== null) {
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ } else {
+ $result[$key] = $this->$key;
+ }
+ }
+ elseif(substr($key, 0, 1) == '_' && $this->$key !== null) {
+ $key = substr($key, 1);
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ }else{
+ $result[$key] = $this->getID();
+ }
+
+ }
+ }
+ return $result;
+ }
}
diff --git a/application/models/Pool.php b/application/models/Pool.php
index 76c7a3b..11d5a03 100644
--- a/application/models/Pool.php
+++ b/application/models/Pool.php
@@ -81,5 +81,39 @@ class Application_Model_Pool
$this->_location = $_location;
return $this;
}
+ /**
+ * Returns current data as associative array using ReflectionClass
+ *
+ * @return array Returns associative array containing model data
+ * If "get"-method not available (our primary keys) the function getID() is called
+ */
+ public function toArray()
+ {
+ $reflectionClass = new ReflectionClass($this);
+ $properties = $reflectionClass->getProperties();
+ $result = array();
+ foreach ($properties as $property) {
+ $key = $property->name;
+ if (substr($key, 0, 1) != '_' && $this->$key !== null) {
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ } else {
+ $result[$key] = $this->$key;
+ }
+ }
+ elseif(substr($key, 0, 1) == '_' && $this->$key !== null) {
+ $key = substr($key, 1);
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ }else{
+ $result[$key] = $this->getID();
+ }
+
+ }
+ }
+ return $result;
+ }
}
diff --git a/application/models/PoolEntries.php b/application/models/PoolEntries.php
index 2a74dad..31caf5f 100644
--- a/application/models/PoolEntries.php
+++ b/application/models/PoolEntries.php
@@ -61,5 +61,39 @@ class Application_Model_PoolEntries
$this->_clientID = $_clientID;
return $this;
}
+ /**
+ * Returns current data as associative array using ReflectionClass
+ *
+ * @return array Returns associative array containing model data
+ * If "get"-method not available (our primary keys) the function getID() is called
+ */
+ public function toArray()
+ {
+ $reflectionClass = new ReflectionClass($this);
+ $properties = $reflectionClass->getProperties();
+ $result = array();
+ foreach ($properties as $property) {
+ $key = $property->name;
+ if (substr($key, 0, 1) != '_' && $this->$key !== null) {
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ } else {
+ $result[$key] = $this->$key;
+ }
+ }
+ elseif(substr($key, 0, 1) == '_' && $this->$key !== null) {
+ $key = substr($key, 1);
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ }else{
+ $result[$key] = $this->getID();
+ }
+
+ }
+ }
+ return $result;
+ }
}
diff --git a/application/models/PoolFilters.php b/application/models/PoolFilters.php
index 5511c4b..8ce21fc 100644
--- a/application/models/PoolFilters.php
+++ b/application/models/PoolFilters.php
@@ -61,5 +61,39 @@ class Application_Model_PoolFilters
$this->_filterID = $_filterID;
return $this;
}
+ /**
+ * Returns current data as associative array using ReflectionClass
+ *
+ * @return array Returns associative array containing model data
+ * If "get"-method not available (our primary keys) the function getID() is called
+ */
+ public function toArray()
+ {
+ $reflectionClass = new ReflectionClass($this);
+ $properties = $reflectionClass->getProperties();
+ $result = array();
+ foreach ($properties as $property) {
+ $key = $property->name;
+ if (substr($key, 0, 1) != '_' && $this->$key !== null) {
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ } else {
+ $result[$key] = $this->$key;
+ }
+ }
+ elseif(substr($key, 0, 1) == '_' && $this->$key !== null) {
+ $key = substr($key, 1);
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ }else{
+ $result[$key] = $this->getID();
+ }
+
+ }
+ }
+ return $result;
+ }
}
diff --git a/application/models/Right.php b/application/models/Right.php
index ad1821e..c0df29c 100644
--- a/application/models/Right.php
+++ b/application/models/Right.php
@@ -71,5 +71,39 @@ class Application_Model_Right
$this->_description = $_description;
return $this;
}
+ /**
+ * Returns current data as associative array using ReflectionClass
+ *
+ * @return array Returns associative array containing model data
+ * If "get"-method not available (our primary keys) the function getID() is called
+ */
+ public function toArray()
+ {
+ $reflectionClass = new ReflectionClass($this);
+ $properties = $reflectionClass->getProperties();
+ $result = array();
+ foreach ($properties as $property) {
+ $key = $property->name;
+ if (substr($key, 0, 1) != '_' && $this->$key !== null) {
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ } else {
+ $result[$key] = $this->$key;
+ }
+ }
+ elseif(substr($key, 0, 1) == '_' && $this->$key !== null) {
+ $key = substr($key, 1);
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ }else{
+ $result[$key] = $this->getID();
+ }
+
+ }
+ }
+ return $result;
+ }
}
diff --git a/application/models/RightRoles.php b/application/models/RightRoles.php
index e9b75c7..b25a605 100644
--- a/application/models/RightRoles.php
+++ b/application/models/RightRoles.php
@@ -61,5 +61,39 @@ class Application_Model_RightRoles
$this->_rightID = $_rightID;
return $this;
}
+ /**
+ * Returns current data as associative array using ReflectionClass
+ *
+ * @return array Returns associative array containing model data
+ * If "get"-method not available (our primary keys) the function getID() is called
+ */
+ public function toArray()
+ {
+ $reflectionClass = new ReflectionClass($this);
+ $properties = $reflectionClass->getProperties();
+ $result = array();
+ foreach ($properties as $property) {
+ $key = $property->name;
+ if (substr($key, 0, 1) != '_' && $this->$key !== null) {
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ } else {
+ $result[$key] = $this->$key;
+ }
+ }
+ elseif(substr($key, 0, 1) == '_' && $this->$key !== null) {
+ $key = substr($key, 1);
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ }else{
+ $result[$key] = $this->getID();
+ }
+
+ }
+ }
+ return $result;
+ }
}
diff --git a/application/models/Role.php b/application/models/Role.php
index 0503627..28f0af1 100644
--- a/application/models/Role.php
+++ b/application/models/Role.php
@@ -81,5 +81,39 @@ class Application_Model_Role
$this->_description = $_description;
return $this;
}
+ /**
+ * Returns current data as associative array using ReflectionClass
+ *
+ * @return array Returns associative array containing model data
+ * If "get"-method not available (our primary keys) the function getID() is called
+ */
+ public function toArray()
+ {
+ $reflectionClass = new ReflectionClass($this);
+ $properties = $reflectionClass->getProperties();
+ $result = array();
+ foreach ($properties as $property) {
+ $key = $property->name;
+ if (substr($key, 0, 1) != '_' && $this->$key !== null) {
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ } else {
+ $result[$key] = $this->$key;
+ }
+ }
+ elseif(substr($key, 0, 1) == '_' && $this->$key !== null) {
+ $key = substr($key, 1);
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ }else{
+ $result[$key] = $this->getID();
+ }
+
+ }
+ }
+ return $result;
+ }
}
diff --git a/application/models/Session.php b/application/models/Session.php
index 73b6b4d..b042c17 100644
--- a/application/models/Session.php
+++ b/application/models/Session.php
@@ -101,5 +101,39 @@ class Application_Model_Session
$this->_ip6 = $_ip6;
return $this;
}
+ /**
+ * Returns current data as associative array using ReflectionClass
+ *
+ * @return array Returns associative array containing model data
+ * If "get"-method not available (our primary keys) the function getID() is called
+ */
+ public function toArray()
+ {
+ $reflectionClass = new ReflectionClass($this);
+ $properties = $reflectionClass->getProperties();
+ $result = array();
+ foreach ($properties as $property) {
+ $key = $property->name;
+ if (substr($key, 0, 1) != '_' && $this->$key !== null) {
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ } else {
+ $result[$key] = $this->$key;
+ }
+ }
+ elseif(substr($key, 0, 1) == '_' && $this->$key !== null) {
+ $key = substr($key, 1);
+ $method = 'get' . ucfirst($key);
+ if ($reflectionClass->hasMethod($method)) {
+ $result[$key] = $this->$method();
+ }else{
+ $result[$key] = $this->getID();
+ }
+
+ }
+ }
+ return $result;
+ }
}
diff --git a/application/views/scripts/filter/editfilter.phtml b/application/views/scripts/filter/editfilter.phtml
index 9b54ac7..e3d1c36 100644
--- a/application/views/scripts/filter/editfilter.phtml
+++ b/application/views/scripts/filter/editfilter.phtml
@@ -3,6 +3,7 @@
echo "| getFiltertypeID();?> | -getFiltervalue();?> | -getFiltervalue();?> | -remove filterentry - | |
| find($filterentry->getFiltertypeID(),$erg); + //name zur ID finden + echo $erg->getFiltertypename(); + + ?> | +getFiltervalue();?> | +getFiltervalue2();?> | +edit filterentry + | remove filterentry + |