diff options
| author | michael pereira | 2011-03-21 10:49:32 +0100 |
|---|---|---|
| committer | michael pereira | 2011-03-21 10:49:32 +0100 |
| commit | 19d1af16ad8a2fdaa5aa608693b81fa9502e162d (patch) | |
| tree | b5b00a6fb91fffad157b85bbf209ac7675a86801 /application/models | |
| parent | Filter funktioniert nun, FBGui IndexController angepasst (diff) | |
| download | pbs2-19d1af16ad8a2fdaa5aa608693b81fa9502e162d.tar.gz pbs2-19d1af16ad8a2fdaa5aa608693b81fa9502e162d.tar.xz pbs2-19d1af16ad8a2fdaa5aa608693b81fa9502e162d.zip | |
Preboot Controller eingerichtet
Diffstat (limited to 'application/models')
| -rw-r--r-- | application/models/BootIso.php | 10 | ||||
| -rw-r--r-- | application/models/BootIsoMapper.php | 6 | ||||
| -rw-r--r-- | application/models/DbTable/PreBoot.php | 10 | ||||
| -rw-r--r-- | application/models/PreBoot.php | 137 | ||||
| -rw-r--r-- | application/models/PreBootMapper.php | 105 |
5 files changed, 260 insertions, 8 deletions
diff --git a/application/models/BootIso.php b/application/models/BootIso.php index 6354d7c..fdcc6b5 100644 --- a/application/models/BootIso.php +++ b/application/models/BootIso.php @@ -4,7 +4,7 @@ class Application_Model_BootIso { protected $_bootisoID; protected $_title; - protected $_path_fbgui; + protected $_prebootID; protected $_membershipID; protected $_groupID; protected $_serialnumber; @@ -89,13 +89,13 @@ class Application_Model_BootIso $this->_title = $_title; return $this; } - public function getPath_fbgui() + public function getPrebootID() { - return $this->_path_fbgui; + return $this->_prebootID; } - public function setPath_fbgui($_path_fbgui) + public function setPrebootID($_prebootID) { - $this->_path_fbgui = $_path_fbgui; + $this->_prebootID = $_prebootID; return $this; } public function getSerialnumber() diff --git a/application/models/BootIsoMapper.php b/application/models/BootIsoMapper.php index bccc851..9e5b3db 100644 --- a/application/models/BootIsoMapper.php +++ b/application/models/BootIsoMapper.php @@ -47,7 +47,7 @@ class Application_Model_BootIsoMapper public function save(Application_Model_BootIso $botiso) { - $data = array('bootisoID'=> $botiso->getID() ,'membershipID'=> $botiso->getMembershipID() ,'title'=> $botiso->getTitle(),'path_fbgui'=> $botiso->getPath_fbgui() ,'groupID'=> $botiso->getGroupID() ,'serialnumber'=> $botiso->getSerialnumber() ,'created'=> $botiso->getCreated() ,'expires'=> $botiso->getExpires() ,'public'=> $botiso->getPublic() ); + $data = array('bootisoID'=> $botiso->getID() ,'membershipID'=> $botiso->getMembershipID() ,'title'=> $botiso->getTitle(),'prebootID'=> $botiso->getPrebootID() ,'groupID'=> $botiso->getGroupID() ,'serialnumber'=> $botiso->getSerialnumber() ,'created'=> $botiso->getCreated() ,'expires'=> $botiso->getExpires() ,'public'=> $botiso->getPublic() ); if (null === ($id = $botiso->getID()) ) { unset($data['bootisoID']); @@ -75,7 +75,7 @@ class Application_Model_BootIsoMapper $row = $result->current(); - $botiso->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_fbgui($row->path_fbgui)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public); + $botiso->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPrebootID($row->prebootID)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public); } public function fetchAll() @@ -85,7 +85,7 @@ class Application_Model_BootIsoMapper foreach ($resultSet as $row) { $entry = new Application_Model_BootIso(); - $entry->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_fbgui($row->path_fbgui)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public); + $entry->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPrebootID($row->prebootID)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public); $entries[] = $entry; } diff --git a/application/models/DbTable/PreBoot.php b/application/models/DbTable/PreBoot.php new file mode 100644 index 0000000..1bff7bb --- /dev/null +++ b/application/models/DbTable/PreBoot.php @@ -0,0 +1,10 @@ +<?php + +class Application_Model_DbTable_PreBoot extends Zend_Db_Table_Abstract +{ + + protected $_name = 'pbs_preboot'; + + +} + diff --git a/application/models/PreBoot.php b/application/models/PreBoot.php new file mode 100644 index 0000000..19047bc --- /dev/null +++ b/application/models/PreBoot.php @@ -0,0 +1,137 @@ +<?php + +class Application_Model_PreBoot +{ + protected $_prebootID; + protected $_title; + protected $_path_preboot; + protected $_membershipID; + protected $_groupID; + + + public function __construct(array $options = null) + { + if (is_array($options)) { + $this->setOptions($options); + } + } + + public function __set($name, $value) + { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid preboot property'); + } + $this->$method($value); + } + + public function __get($name) + { + $method = 'get' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid preboot property'); + } + return $this->$method(); + } + + public function setOptions(array $options) + { + $methods = get_class_methods($this); + foreach ($options as $key => $value) { + $method = 'set' . ucfirst($key); + if (in_array($method, $methods)) { + $this->$method($value); + } + } + return $this; + } + + public function getID() + { + return $this->_prebootID; + } + public function setID($_prebootID) + { + $this->_prebootID = $_prebootID; + return $this; + } + + public function getMembershipID() + { + return $this->_membershipID; + } + + public function setMembershipID($_membershipID) + { + $this->_membershipID = $_membershipID; + return $this; + } + + public function getGroupID() + { + return $this->_groupID; + } + + public function setGroupID($_groupID) + { + $this->_groupID = $_groupID; + return $this; + } + public function getTitle() + { + return $this->_title; + } + public function setTitle($_title) + { + $this->_title = $_title; + return $this; + } + public function getPath_preboot() + { + return $this->_path_preboot; + } + + public function setPath_preboot($_path_preboot) + { + $this->_path_preboot = $_path_preboot; + 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/PreBootMapper.php b/application/models/PreBootMapper.php new file mode 100644 index 0000000..5ff760d --- /dev/null +++ b/application/models/PreBootMapper.php @@ -0,0 +1,105 @@ +<?php + +class Application_Model_PreBootMapper +{ + + protected $_dbTable; + + public function findBy($criteria, $value) + { + try{ + $db = Zend_Db_Table::getDefaultAdapter(); + $select = $this->getDbTable()->select() + ->from($this->_dbTable) + ->where($criteria . ' = ?', $value); + $stmt = $select->query(); + $result = $stmt->fetchAll(); + return $result; + }catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + } + + 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_PreBoot'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_PreBoot $preboot) + { + + $data = array('prebootID'=> $preboot->getID() ,'membershipID'=> $preboot->getMembershipID() ,'title'=> $preboot->getTitle() ,'path_preboot'=> $preboot->getPath_preboot() ,'groupID'=> $preboot->getGroupID() ); + + if (null === ($id = $preboot->getID()) ) { + unset($data['prebootID']); + return $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('prebootID = ?' => $id)); + } + + } + + public function delete(Application_Model_PreBoot $preboot) + { + if (null === ($id = $preboot->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('prebootID = ?' => $id)); + } + } + + public function find($id, Application_Model_PreBoot $preboot = null) + { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + if($preboot == null){ + $preboot = new Application_Model_PreBoot(); + $preboot->setID($row->prebootID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_preboot($row->path_preboot)->setGroupID($row->groupID); + return $preboot; + }else{ + $preboot->setID($row->prebootID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_preboot($row->path_preboot)->setGroupID($row->groupID); + } + } + + public function fetchAll() + { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_PreBoot(); + + $entry->setID($row->prebootID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_preboot($row->path_preboot)->setGroupID($row->groupID); + + $entries[] = $entry; + } + return $entries; + } + + + +} + |
