summaryrefslogtreecommitdiffstats
path: root/application/models
diff options
context:
space:
mode:
authorBjörn Geiger2011-08-19 00:45:34 +0200
committerBjörn Geiger2011-08-19 00:45:34 +0200
commit74d2e51da636f8ec981a0b004efb7e1f04b08e08 (patch)
treec62968896bfc4fb4cb6715b17894c58bdfba9418 /application/models
parentmore ps-logic (diff)
downloadpoolctrl-74d2e51da636f8ec981a0b004efb7e1f04b08e08.tar.gz
poolctrl-74d2e51da636f8ec981a0b004efb7e1f04b08e08.tar.xz
poolctrl-74d2e51da636f8ec981a0b004efb7e1f04b08e08.zip
verschiedene Datenbankänderungen
Diffstat (limited to 'application/models')
-rw-r--r--application/models/DbTable/Reporttype.php20
-rw-r--r--application/models/Event.php12
-rw-r--r--application/models/EventMapper.php8
-rw-r--r--application/models/Eventreport.php12
-rw-r--r--application/models/EventreportMapper.php10
-rw-r--r--application/models/Reporttype.php111
-rw-r--r--application/models/ReporttypeMapper.php148
7 files changed, 314 insertions, 7 deletions
diff --git a/application/models/DbTable/Reporttype.php b/application/models/DbTable/Reporttype.php
new file mode 100644
index 0000000..fe62330
--- /dev/null
+++ b/application/models/DbTable/Reporttype.php
@@ -0,0 +1,20 @@
+<?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_DbTable_Reporttype extends Zend_Db_Table_Abstract
+{
+
+ protected $_name = 'poolctrl_reporttype';
+
+
+}
+
diff --git a/application/models/Event.php b/application/models/Event.php
index b69412e..33a470e 100644
--- a/application/models/Event.php
+++ b/application/models/Event.php
@@ -26,6 +26,7 @@ class Application_Model_Event
protected $_pbs_filterID;
protected $_repeat;
protected $_immediate;
+ protected $_running;
protected $_note;
public function __construct(array $options = null)
@@ -264,5 +265,16 @@ class Application_Model_Event
$this->_pbs_filterID = $_pbs_filterID;
return $this;
}
+
+ public function getRunning()
+ {
+ return $this->_running;
+ }
+
+ public function setRunning($_running)
+ {
+ $this->_running = $_running;
+ return $this;
+ }
}
diff --git a/application/models/EventMapper.php b/application/models/EventMapper.php
index 394fea2..a2648a0 100644
--- a/application/models/EventMapper.php
+++ b/application/models/EventMapper.php
@@ -85,7 +85,7 @@ class Application_Model_EventMapper
public function save(Application_Model_Event $event)
{
- $data = array('eventID'=> $event->getID() ,'category'=> $event->getCategory() ,'title'=> $event->getTitle(), 'pbs_membershipID'=> $event->getPbs_membershipID(),'end'=> $event->getEnd() ,'immediate'=> $event->getImmediate() ,'note'=> $event->getNote() ,'participants'=> $event->getParticipants() ,'pbs_bootosID'=> $event->getPbs_bootosID(),'pbs_poolID'=> $event->getPbs_poolID(),'repeat'=> $event->getRepeat(),'start'=> $event->getStart(),'pbs_bootmenuID'=> $event->getPbs_bootmenuID(),'pbs_filterID'=> $event->getPbs_filterID() );
+ $data = array('eventID'=> $event->getID() ,'category'=> $event->getCategory() ,'title'=> $event->getTitle(), 'pbs_membershipID'=> $event->getPbs_membershipID(),'end'=> $event->getEnd() ,'immediate'=> $event->getImmediate() ,'note'=> $event->getNote() ,'participants'=> $event->getParticipants() ,'pbs_bootosID'=> $event->getPbs_bootosID(),'pbs_poolID'=> $event->getPbs_poolID(),'repeat'=> $event->getRepeat(),'start'=> $event->getStart(),'pbs_bootmenuID'=> $event->getPbs_bootmenuID(),'pbs_filterID'=> $event->getPbs_filterID(), 'running' => $event->getRunning() );
if (null === ($id = $event->getID()) ) {
unset($data['eventID']);
return $this->getDbTable()->insert($data);
@@ -130,7 +130,8 @@ class Application_Model_EventMapper
->setPbs_filterID($row->pbs_filterID)
->setPbs_bootmenuID($row->pbs_bootmenuID)
->setRepeat($row->repeat)
- ->setStart($row->start);
+ ->setStart($row->start)
+ ->setRunning($row->running);
}
public function fetchAll()
@@ -155,7 +156,8 @@ class Application_Model_EventMapper
->setPbs_filterID($row->pbs_filterID)
->setPbs_bootmenuID($row->pbs_bootmenuID)
->setRepeat($row->repeat)
- ->setStart($row->start);
+ ->setStart($row->start)
+ ->setRunning($row->running);
$entries[$row->eventID] = $entry;
}
diff --git a/application/models/Eventreport.php b/application/models/Eventreport.php
index 3b9d11d..7b72ab0 100644
--- a/application/models/Eventreport.php
+++ b/application/models/Eventreport.php
@@ -14,6 +14,7 @@ class Application_Model_Eventreport
{
protected $_reportID;
protected $_report;
+ protected $_type;
protected $_eventID;
public function __construct(array $options = null)
@@ -119,5 +120,16 @@ class Application_Model_Eventreport
$this->_eventID = $_eventID;
return $this;
}
+
+ public function geType()
+ {
+ return $this->_type;
+ }
+
+ public function setType($_type)
+ {
+ $this->_type = $_type;
+ return $this;
+ }
}
diff --git a/application/models/EventreportMapper.php b/application/models/EventreportMapper.php
index 8ea9a28..19b2977 100644
--- a/application/models/EventreportMapper.php
+++ b/application/models/EventreportMapper.php
@@ -39,7 +39,7 @@ class Application_Model_EventreportMapper
$stmt = $select->query();
$result = $stmt->fetchAll();
- if(!$array){
+ if(!$array){
$entries = array();
if(count($result) > 0) {
foreach ($result as $row) {
@@ -84,7 +84,7 @@ class Application_Model_EventreportMapper
public function save(Application_Model_Eventreport $eventreport)
{
- $data = array('reportID'=> $eventreport->getID() ,'eventID'=> $eventreport->getEventID() ,'report'=> $eventreport->getReport() );
+ $data = array('reportID'=> $eventreport->getID() ,'eventID'=> $eventreport->getEventID() ,'report'=> $eventreport->getReport(), 'type' => $eventreport->geType() );
if (null === ($id = $eventreport->getID()) ) {
unset($data['reportID']);
return $this->getDbTable()->insert($data);
@@ -118,7 +118,8 @@ class Application_Model_EventreportMapper
$eventreport
->setID($row->reportID)
->setEventID($row->eventID)
- ->setReport($row->report);
+ ->setReport($row->report)
+ ->setType($row->type);
}
public function fetchAll()
@@ -131,7 +132,8 @@ class Application_Model_EventreportMapper
$entry
->setID($row->reportID)
->setEventID($row->eventID)
- ->setReport($row->report);
+ ->setReport($row->report)
+ ->setType($row->type);
$entries[$row->reportID] = $entry;
}
diff --git a/application/models/Reporttype.php b/application/models/Reporttype.php
new file mode 100644
index 0000000..794e3f4
--- /dev/null
+++ b/application/models/Reporttype.php
@@ -0,0 +1,111 @@
+<?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_Reporttype
+{
+ protected $_reporttypeID;
+ protected $_title;
+
+ 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 reporttype property');
+ }
+ $this->$method($value);
+ }
+
+ public function __get($name)
+ {
+ $method = 'get' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid reporttype 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->_reporttypeID;
+ }
+ public function setID($_reporttypeID)
+ {
+ $this->reporttypeID = $_reporttypeID;
+ return $this;
+ }
+
+ public function getTitle()
+ {
+ return $this->_title;
+ }
+
+ public function setTitle($_title)
+ {
+ $this->_title = $_title;
+ return $this;
+ }
+}
+
diff --git a/application/models/ReporttypeMapper.php b/application/models/ReporttypeMapper.php
new file mode 100644
index 0000000..fbbd95a
--- /dev/null
+++ b/application/models/ReporttypeMapper.php
@@ -0,0 +1,148 @@
+<?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_ReporttypeMapper
+{
+
+ protected $_dbTable;
+
+ public function findBy($where, $array=false, $order=false)
+ {
+ foreach($where as $k => $v){
+ if($v != null)
+ $where2[] = "$k = '$v'";
+ else
+ $where2[] = "$k IS NULL";
+ }
+ $where = implode(" AND " ,$where2);
+
+ try{
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $select = $this->getDbTable()->select()
+ ->from($this->_dbTable)
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
+ $stmt = $select->query();
+ $result = $stmt->fetchAll();
+
+ if(!$array){
+ $entries = array();
+ if(count($result) > 0) {
+ foreach ($result as $row) {
+ $entry = new Application_Model_Event($row);
+ $entry->setID($row['reporttypeID']);
+ $entries[] = $entry;
+ }
+ }
+ return $entries;
+ }else{
+ 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_Reporttype');
+ }
+
+ return $this->_dbTable;
+ }
+
+ public function save(Application_Model_Reporttype $reporttype)
+ {
+ $data = array('reporttypeID'=> $reporttype->getID() ,'title'=> $reporttype->getTitle() );
+ if (null === ($id = $reporttype->getID()) ) {
+ unset($data['reporttypeID']);
+ return $this->getDbTable(F)->insert($data);
+ } else {
+ $this->getDbTable()->update($data, array('reporttypeID = ?' => $id));
+ }
+ }
+
+ public function delete(Application_Model_Reporttype $reporttype)
+ {
+ if (null === ($id = $reporttype->getID()) ) {
+ return;
+ } else {
+ $this->getDbTable()->delete(array('reporttypeID = ?' => $id));
+ }
+ }
+
+ public function find($id, Application_Model_Reporttype $reporttype = null)
+ {
+ $result = $this->getDbTable()->find($id);
+ if (0 == count($result)) {
+ return;
+ }
+
+ $row = $result->current();
+
+ if($reporttype == null){
+ $reporttype = new Application_Model_Reporttype();
+ }
+
+ $reporttype
+ ->setID($row->reporttypeID)
+ ->setTitle($row->title);
+ }
+
+ public function fetchAll()
+ {
+ $resultSet = $this->getDbTable()->fetchAll();
+ $entries = array();
+ foreach ($resultSet as $row) {
+ $entry = new Application_Model_Reporttype();
+
+ $entry
+ ->setID($row->reporttypeID)
+ ->setTitle($row->title);
+
+ $entries[$row->reporttypeID] = $entry;
+ }
+ return $entries;
+ }
+
+ public function compare(Application_Model_Reporttype $v1,Application_Model_Reporttype $v2){
+ $vv1 = $v1->toArray();
+ $vv2 = $v2->toArray();
+ return array_diff($vv1,$vv2);
+ }
+
+
+
+} \ No newline at end of file