summaryrefslogtreecommitdiffstats
path: root/application/models/Eventreport.php
diff options
context:
space:
mode:
authorBjörn Geiger2011-06-27 15:20:03 +0200
committerBjörn Geiger2011-06-27 15:20:03 +0200
commit3f204df0b2c88ca0407f893b0c17f8de889b614d (patch)
treea63de293700d5b8025fe58317c693dfed7bb6bbf /application/models/Eventreport.php
parentFehler in Datenbank korrigiert (diff)
downloadpoolctrl-3f204df0b2c88ca0407f893b0c17f8de889b614d.tar.gz
poolctrl-3f204df0b2c88ca0407f893b0c17f8de889b614d.tar.xz
poolctrl-3f204df0b2c88ca0407f893b0c17f8de889b614d.zip
Datenbank Mapper hinzugefügt
Diffstat (limited to 'application/models/Eventreport.php')
-rw-r--r--application/models/Eventreport.php121
1 files changed, 121 insertions, 0 deletions
diff --git a/application/models/Eventreport.php b/application/models/Eventreport.php
new file mode 100644
index 0000000..b0c061b
--- /dev/null
+++ b/application/models/Eventreport.php
@@ -0,0 +1,121 @@
+<?php
+/*
+ * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
+ * This program is free software distributed under the GPL version 2.
+ * See http://gpl.openslx.org/
+ *
+ * If you have any feedback please consult http://feedback.openslx.org/ and
+ * send your suggestions, praise, or complaints to feedback@openslx.org
+ *
+ * General information about OpenSLX can be found at http://openslx.org/
+ */
+
+class Application_Model_Eventreport
+{
+ protected $_reportID;
+ protected $_report;
+ protected $_eventID;
+
+ 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 eventreport property');
+ }
+ $this->$method($value);
+ }
+
+ public function __get($name)
+ {
+ $method = 'get' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid eventreport 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;
+ }
+
+ /**
+ * 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;
+ }
+
+ public function getID()
+ {
+ return $this->_reportID;
+ }
+ public function setID($_reportID)
+ {
+ $this->_reportID = $_reportID;
+ return $this;
+ }
+
+ public function getReport()
+ {
+ return $this->_report;
+ }
+
+ public function setReport($_report)
+ {
+ $this->_report = $_report;
+ }
+
+ public function getEventID()
+ {
+ return $this->_eventID;
+ }
+
+ public function setEventID($_eventID)
+ {
+ $this->_eventID = $_eventID;
+ }
+}
+