diff options
author | michael pereira | 2011-03-04 03:10:53 +0100 |
---|---|---|
committer | michael pereira | 2011-03-04 03:10:53 +0100 |
commit | cd5f39054796ffe8cdda493d472d302a4de9e768 (patch) | |
tree | 517ee81c31809317e36bfd1141dfdb952e021d89 | |
parent | fixing git (diff) | |
download | pbs2-cd5f39054796ffe8cdda493d472d302a4de9e768.tar.gz pbs2-cd5f39054796ffe8cdda493d472d302a4de9e768.tar.xz pbs2-cd5f39054796ffe8cdda493d472d302a4de9e768.zip |
Mapper mit neuer delete function
26 files changed, 411 insertions, 47 deletions
diff --git a/application/models/BootIsoMapper.php b/application/models/BootIsoMapper.php index 559f41e..624940b 100644 --- a/application/models/BootIsoMapper.php +++ b/application/models/BootIsoMapper.php @@ -35,10 +35,19 @@ class Application_Model_BootIsoMapper $data = array('bootisoID'=> $botiso->getBootisoID() ,'membershipID'=> $botiso->getMembershipID() ,'groupID'=> $botiso->getGroupID() ,'serialnumber'=> $botiso->getSerialnumber() ,'created'=> $botiso->getCreated() ,'expires'=> $botiso->getExpires() ,'public'=> $botiso->getPublic() ); if (null === ($id = $botiso->getID()) ) { - unset($data['id']); + unset($data['botisoID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('botisoID = ?' => $id)); + } + } + + public function delete(Application_Model_BootIso $botiso) + { + if (null === ($id = $botiso->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('botisoID = ?' => $id)); } } diff --git a/application/models/BootMapper.php b/application/models/BootMapper.php new file mode 100644 index 0000000..43f9d3d --- /dev/null +++ b/application/models/BootMapper.php @@ -0,0 +1,83 @@ +<?php + +class Application_Model_BootMapper +{ + + protected $_dbTable; + + public function setDbTable($dbTable) + { + if (is_string($dbTable)) { + $dbTable = new $dbTable(); + } + + if (!$dbTable instanceof Zend_Db_Table_Abstract) { + throw new Exception('Invalid table data gateway provided'); + } + + $this->_dbTable = $dbTable; + + return $this; + } + + public function getDbTable() + { + if (null === $this->_dbTable) { + $this->setDbTable('Application_Model_DbTable_Boot'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_Boot $bot) + { + + $data = array(); + + if (null === ($id = $bot->getID()) ) { + unset($data['botID']); + $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('botID = ?' => $id)); + } + } + + public function delete(Application_Model_Boot $bot) + { + if (null === ($id = $bot->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('botID = ?' => $id)); + } + } + + public function find($id, Application_Model_Boot $bot) + { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + $bot; + } + + public function fetchAll() + { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_Boot(); + + $entry; + + $entries[] = $entry; + } + return $entries; + } + + + +} + diff --git a/application/models/BootMenuEntriesMapper.php b/application/models/BootMenuEntriesMapper.php index 6ef11e3..cf7ba46 100644 --- a/application/models/BootMenuEntriesMapper.php +++ b/application/models/BootMenuEntriesMapper.php @@ -35,10 +35,19 @@ class Application_Model_BootMenuEntriesMapper $data = array('bootosID'=> $botmenuentries->getBootosID() ,'bootmenuID'=> $botmenuentries->getBootmenuID() ,'title'=> $botmenuentries->getTitle() ,'kcl'=> $botmenuentries->getKcl() ,'order'=> $botmenuentries->getOrder() ); if (null === ($id = $botmenuentries->getID()) ) { - unset($data['id']); + unset($data['botmenuentriesID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('botmenuentriesID = ?' => $id)); + } + } + + public function delete(Application_Model_BootMenuEntries $botmenuentries) + { + if (null === ($id = $botmenuentries->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('botmenuentriesID = ?' => $id)); } } diff --git a/application/models/BootMenuMapper.php b/application/models/BootMenuMapper.php index 9d6ec1b..fa9b8a7 100644 --- a/application/models/BootMenuMapper.php +++ b/application/models/BootMenuMapper.php @@ -35,10 +35,19 @@ class Application_Model_BootMenuMapper $data = array('bootmenuID'=> $botmenu->getBootmenuID() ,'membershipID'=> $botmenu->getMembershipID() ,'title'=> $botmenu->getTitle() ,'time'=> $botmenu->getTime() ); if (null === ($id = $botmenu->getID()) ) { - unset($data['id']); + unset($data['botmenuID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('botmenuID = ?' => $id)); + } + } + + public function delete(Application_Model_BootMenu $botmenu) + { + if (null === ($id = $botmenu->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('botmenuID = ?' => $id)); } } diff --git a/application/models/BootOsMapper.php b/application/models/BootOsMapper.php index 87d4d6c..0c5d30f 100644 --- a/application/models/BootOsMapper.php +++ b/application/models/BootOsMapper.php @@ -35,10 +35,19 @@ class Application_Model_BootOsMapper $data = array('bootisoID'=> $botos->getBootisoID() ,'membershipID'=> $botos->getMembershipID() ,'groupID'=> $botos->getGroupID() ,'serialnumber'=> $botos->getSerialnumber() ,'created'=> $botos->getCreated() ,'expires'=> $botos->getExpires() ,'public'=> $botos->getPublic() ); if (null === ($id = $botos->getID()) ) { - unset($data['id']); + unset($data['botosID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('botosID = ?' => $id)); + } + } + + public function delete(Application_Model_BootOs $botos) + { + if (null === ($id = $botos->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('botosID = ?' => $id)); } } diff --git a/application/models/ClientMapper.php b/application/models/ClientMapper.php index dda9f12..bf513ea 100644 --- a/application/models/ClientMapper.php +++ b/application/models/ClientMapper.php @@ -35,10 +35,19 @@ class Application_Model_ClientMapper $data = array('clientID'=> $client->getID() ,'macadress'=> $client->getMacadress() ,'hardwarehash'=> $client->getHardwarehash() ); if (null === ($id = $client->getID()) ) { - unset($data['id']); + unset($data['clientID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('clientID = ?' => $id)); + } + } + + public function delete(Application_Model_Client $client) + { + if (null === ($id = $client->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('clientID = ?' => $id)); } } diff --git a/application/models/ConfigMapper.php b/application/models/ConfigMapper.php index 6cd5f67..10d590b 100644 --- a/application/models/ConfigMapper.php +++ b/application/models/ConfigMapper.php @@ -35,10 +35,19 @@ class Application_Model_ConfigMapper $data = array('configID'=> $config->getID() ,'membershipID'=> $config->getMembershipID() ,'shellscript'=> $config->getShellscript() ); if (null === ($id = $config->getID()) ) { - unset($data['id']); + unset($data['configID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('configID = ?' => $id)); + } + } + + public function delete(Application_Model_Config $config) + { + if (null === ($id = $config->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('configID = ?' => $id)); } } diff --git a/application/models/FilterEntriesMapper.php b/application/models/FilterEntriesMapper.php index af90d78..58ea563 100644 --- a/application/models/FilterEntriesMapper.php +++ b/application/models/FilterEntriesMapper.php @@ -35,10 +35,19 @@ class Application_Model_FilterEntriesMapper $data = array('filterID'=> $filterentries->getFilterID() ,'filtertypeID'=> $filterentries->getFiltertypeID() ,'filtervalue'=> $filterentries->getFiltervalue() ,'filtervalue2'=> $filterentries->getFiltervalue2() ); if (null === ($id = $filterentries->getID()) ) { - unset($data['id']); + unset($data['filterentriesID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('filterentriesID = ?' => $id)); + } + } + + public function delete(Application_Model_FilterEntries $filterentries) + { + if (null === ($id = $filterentries->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('filterentriesID = ?' => $id)); } } diff --git a/application/models/FilterMapper.php b/application/models/FilterMapper.php index 41ae3c7..0ac3cb3 100644 --- a/application/models/FilterMapper.php +++ b/application/models/FilterMapper.php @@ -35,10 +35,19 @@ 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() ); if (null === ($id = $filter->getID()) ) { - unset($data['id']); + unset($data['filterID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('filterID = ?' => $id)); + } + } + + public function delete(Application_Model_Filter $filter) + { + if (null === ($id = $filter->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('filterID = ?' => $id)); } } diff --git a/application/models/FilterTypeMapper.php b/application/models/FilterTypeMapper.php index c1f3635..f10ee21 100644 --- a/application/models/FilterTypeMapper.php +++ b/application/models/FilterTypeMapper.php @@ -35,10 +35,19 @@ class Application_Model_FilterTypeMapper $data = array('filtertypeID'=> $filtertype->getID() ,'filtertypename'=> $filtertype->getFiltertypename() ); if (null === ($id = $filtertype->getID()) ) { - unset($data['id']); + unset($data['filtertypeID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('filtertypeID = ?' => $id)); + } + } + + public function delete(Application_Model_FilterType $filtertype) + { + if (null === ($id = $filtertype->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('filtertypeID = ?' => $id)); } } diff --git a/application/models/GroupGroupsMapper.php b/application/models/GroupGroupsMapper.php index dce6a5a..79bf774 100644 --- a/application/models/GroupGroupsMapper.php +++ b/application/models/GroupGroupsMapper.php @@ -35,10 +35,19 @@ class Application_Model_GroupGroupsMapper $data = array('parentID'=> $groupgroups->getParentID() ,'groupID'=> $groupgroups->getGroupID() ); if (null === ($id = $groupgroups->getID()) ) { - unset($data['id']); + unset($data['groupgroupsID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('groupgroupsID = ?' => $id)); + } + } + + public function delete(Application_Model_GroupGroups $groupgroups) + { + if (null === ($id = $groupgroups->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('groupgroupsID = ?' => $id)); } } diff --git a/application/models/GroupMapper.php b/application/models/GroupMapper.php index 5ad6c64..b9c7e30 100644 --- a/application/models/GroupMapper.php +++ b/application/models/GroupMapper.php @@ -35,10 +35,19 @@ class Application_Model_GroupMapper $data = array('groupID'=> $group->getID() ,'title'=> $group->getTitle() ,'description'=> $group->getDescription() ); if (null === ($id = $group->getID()) ) { - unset($data['id']); + unset($data['groupID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('groupID = ?' => $id)); + } + } + + public function delete(Application_Model_Group $group) + { + if (null === ($id = $group->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('groupID = ?' => $id)); } } diff --git a/application/models/GroupRequestMapper.php b/application/models/GroupRequestMapper.php index 8ffd88e..c09e047 100644 --- a/application/models/GroupRequestMapper.php +++ b/application/models/GroupRequestMapper.php @@ -35,10 +35,19 @@ class Application_Model_GroupRequestMapper $data = array('grouprequestID'=> $grouprequest->getID() ,'groupID'=> $grouprequest->getGroupID() ,'personID'=> $grouprequest->getPersonID() ,'time'=> $grouprequest->getTime() ); if (null === ($id = $grouprequest->getID()) ) { - unset($data['id']); + unset($data['grouprequestID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('grouprequestID = ?' => $id)); + } + } + + public function delete(Application_Model_GroupRequest $grouprequest) + { + if (null === ($id = $grouprequest->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('grouprequestID = ?' => $id)); } } diff --git a/application/models/MembershipFiltersMapper.php b/application/models/MembershipFiltersMapper.php index 5c1fa29..e894c82 100644 --- a/application/models/MembershipFiltersMapper.php +++ b/application/models/MembershipFiltersMapper.php @@ -35,10 +35,19 @@ class Application_Model_MembershipFiltersMapper $data = array('membershipID'=> $membershipfilters->getMembershipID() ,'filterID'=> $membershipfilters->getFilterID() ); if (null === ($id = $membershipfilters->getID()) ) { - unset($data['id']); + unset($data['membershipfiltersID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('membershipfiltersID = ?' => $id)); + } + } + + public function delete(Application_Model_MembershipFilters $membershipfilters) + { + if (null === ($id = $membershipfilters->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('membershipfiltersID = ?' => $id)); } } diff --git a/application/models/MembershipMapper.php b/application/models/MembershipMapper.php index fbbe279..f2c0aee 100644 --- a/application/models/MembershipMapper.php +++ b/application/models/MembershipMapper.php @@ -35,10 +35,19 @@ class Application_Model_MembershipMapper $data = array('membershipID'=> $membership->getID() ,'groupID'=> $membership->getGroupID() ,'roleID'=> $membership->getRoleID() ,'personID'=> $membership->getPersonID() ); if (null === ($id = $membership->getID()) ) { - unset($data['id']); + unset($data['membershipID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('membershipID = ?' => $id)); + } + } + + public function delete(Application_Model_Membership $membership) + { + if (null === ($id = $membership->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('membershipID = ?' => $id)); } } diff --git a/application/models/Person.php b/application/models/Person.php index 9a44657..eb26cbf 100644 --- a/application/models/Person.php +++ b/application/models/Person.php @@ -177,7 +177,7 @@ class Application_Model_Person $this->_password_salt = $_password_salt; return $this; } - public function getPasswordSalt($_password_salt) + public function getPasswordSalt() { return $this->_password_salt; } diff --git a/application/models/PersonMapper.php b/application/models/PersonMapper.php index 13385ca..07c0347 100644 --- a/application/models/PersonMapper.php +++ b/application/models/PersonMapper.php @@ -35,10 +35,19 @@ class Application_Model_PersonMapper $data = array('personID'=> $person->getID() ,'title'=> $person->getTitle() ,'name'=> $person->getName() ,'firstname'=> $person->getFirstname() ,'street'=> $person->getStreet() ,'housenumber'=> $person->getHousenumber() ,'city'=> $person->getCity() ,'postalcode'=> $person->getPostalcode() ,'logindate'=> $person->getLogindate() ,'registerdate'=> $person->getRegisterdate() ,'email'=> $person->getEmail() ,'login'=> $person->getLogin() ,'password'=> $person->getPassword() ,'password'=> $person->getPassword() ); if (null === ($id = $person->getID()) ) { - unset($data['id']); + unset($data['personID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('personID = ?' => $id)); + } + } + + public function delete(Application_Model_Person $person) + { + if (null === ($id = $person->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('personID = ?' => $id)); } } @@ -51,7 +60,7 @@ 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); + $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)->setPassword($row->password); } public function fetchAll() @@ -61,7 +70,7 @@ class Application_Model_PersonMapper foreach ($resultSet as $row) { $entry = new Application_Model_Person(); - $entry->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); + $entry->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)->setPassword($row->password); $entries[] = $entry; } diff --git a/application/models/PoolEntriesMapper.php b/application/models/PoolEntriesMapper.php index 77bd34c..5d92f4c 100644 --- a/application/models/PoolEntriesMapper.php +++ b/application/models/PoolEntriesMapper.php @@ -35,10 +35,19 @@ class Application_Model_PoolEntriesMapper $data = array('poolID'=> $polentries->getPoolID() ,'clientID'=> $polentries->getClientID() ); if (null === ($id = $polentries->getID()) ) { - unset($data['id']); + unset($data['polentriesID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('polentriesID = ?' => $id)); + } + } + + public function delete(Application_Model_PoolEntries $polentries) + { + if (null === ($id = $polentries->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('polentriesID = ?' => $id)); } } diff --git a/application/models/PoolFiltersMapper.php b/application/models/PoolFiltersMapper.php index 88ffe97..582f955 100644 --- a/application/models/PoolFiltersMapper.php +++ b/application/models/PoolFiltersMapper.php @@ -35,10 +35,19 @@ class Application_Model_PoolFiltersMapper $data = array('poolID'=> $polfilters->getPoolID() ,'filterID'=> $polfilters->getFilterID() ); if (null === ($id = $polfilters->getID()) ) { - unset($data['id']); + unset($data['polfiltersID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('polfiltersID = ?' => $id)); + } + } + + public function delete(Application_Model_PoolFilters $polfilters) + { + if (null === ($id = $polfilters->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('polfiltersID = ?' => $id)); } } diff --git a/application/models/PoolMapper.php b/application/models/PoolMapper.php index f889330..f9be34f 100644 --- a/application/models/PoolMapper.php +++ b/application/models/PoolMapper.php @@ -35,10 +35,19 @@ class Application_Model_PoolMapper $data = array('poolID'=> $pol->getPoolID() ,'title'=> $pol->getTitle() ,'description'=> $pol->getDescription() ,'location'=> $pol->getLocation() ); if (null === ($id = $pol->getID()) ) { - unset($data['id']); + unset($data['polID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('polID = ?' => $id)); + } + } + + public function delete(Application_Model_Pool $pol) + { + if (null === ($id = $pol->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('polID = ?' => $id)); } } diff --git a/application/models/RightMapper.php b/application/models/RightMapper.php index 3ffe5f5..35e5b05 100644 --- a/application/models/RightMapper.php +++ b/application/models/RightMapper.php @@ -35,10 +35,19 @@ class Application_Model_RightMapper $data = array('rightID'=> $right->getID() ,'title'=> $right->getTitle() ,'description'=> $right->getDescription() ); if (null === ($id = $right->getID()) ) { - unset($data['id']); + unset($data['rightID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('rightID = ?' => $id)); + } + } + + public function delete(Application_Model_Right $right) + { + if (null === ($id = $right->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('rightID = ?' => $id)); } } diff --git a/application/models/RightRolesMapper.php b/application/models/RightRolesMapper.php index afd5c26..ae409d8 100644 --- a/application/models/RightRolesMapper.php +++ b/application/models/RightRolesMapper.php @@ -35,10 +35,19 @@ class Application_Model_RightRolesMapper $data = array('roleID'=> $rightroles->getRoleID() ,'rightID'=> $rightroles->getRightID() ); if (null === ($id = $rightroles->getID()) ) { - unset($data['id']); + unset($data['rightrolesID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('rightrolesID = ?' => $id)); + } + } + + public function delete(Application_Model_RightRoles $rightroles) + { + if (null === ($id = $rightroles->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('rightrolesID = ?' => $id)); } } diff --git a/application/models/RoleMapper.php b/application/models/RoleMapper.php index 2b1d658..da8d73a 100644 --- a/application/models/RoleMapper.php +++ b/application/models/RoleMapper.php @@ -35,10 +35,19 @@ class Application_Model_RoleMapper $data = array('roleID'=> $role->getID() ,'groupID'=> $role->getGroupID() ,'title'=> $role->getTitle() ,'description'=> $role->getDescription() ); if (null === ($id = $role->getID()) ) { - unset($data['id']); + unset($data['roleID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('roleID = ?' => $id)); + } + } + + public function delete(Application_Model_Role $role) + { + if (null === ($id = $role->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('roleID = ?' => $id)); } } diff --git a/application/models/RolesMapper.php b/application/models/RolesMapper.php new file mode 100644 index 0000000..681c173 --- /dev/null +++ b/application/models/RolesMapper.php @@ -0,0 +1,83 @@ +<?php + +class Application_Model_RolesMapper +{ + + protected $_dbTable; + + public function setDbTable($dbTable) + { + if (is_string($dbTable)) { + $dbTable = new $dbTable(); + } + + if (!$dbTable instanceof Zend_Db_Table_Abstract) { + throw new Exception('Invalid table data gateway provided'); + } + + $this->_dbTable = $dbTable; + + return $this; + } + + public function getDbTable() + { + if (null === $this->_dbTable) { + $this->setDbTable('Application_Model_DbTable_Roles'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_Roles $roles) + { + + $data = array(); + + if (null === ($id = $roles->getID()) ) { + unset($data['rolesID']); + $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('rolesID = ?' => $id)); + } + } + + public function delete(Application_Model_Roles $roles) + { + if (null === ($id = $roles->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('rolesID = ?' => $id)); + } + } + + public function find($id, Application_Model_Roles $roles) + { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + $roles; + } + + public function fetchAll() + { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_Roles(); + + $entry; + + $entries[] = $entry; + } + return $entries; + } + + + +} + diff --git a/application/models/SessionMapper.php b/application/models/SessionMapper.php index c4187bd..dac5c4e 100644 --- a/application/models/SessionMapper.php +++ b/application/models/SessionMapper.php @@ -35,10 +35,19 @@ class Application_Model_SessionMapper $data = array('sessionID'=> $sesion->getSessionID() ,'clientID'=> $sesion->getClientID() ,'bootosID'=> $sesion->getBootosID() ,'time'=> $sesion->getTime() ,'ip'=> $sesion->getIp() ,'ip6'=> $sesion->getIp6() ); if (null === ($id = $sesion->getID()) ) { - unset($data['id']); + unset($data['sesionID']); $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('id = ?' => $id)); + $this->getDbTable()->update($data, array('sesionID = ?' => $id)); + } + } + + public function delete(Application_Model_Session $sesion) + { + if (null === ($id = $sesion->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('sesionID = ?' => $id)); } } diff --git a/application/views/scripts/auth/delete-account.phtml b/application/views/scripts/auth/delete.phtml index 3b7085d..3b7085d 100644 --- a/application/views/scripts/auth/delete-account.phtml +++ b/application/views/scripts/auth/delete.phtml |