summaryrefslogtreecommitdiffstats
path: root/application
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
parentFehler in Datenbank korrigiert (diff)
downloadpoolctrl-3f204df0b2c88ca0407f893b0c17f8de889b614d.tar.gz
poolctrl-3f204df0b2c88ca0407f893b0c17f8de889b614d.tar.xz
poolctrl-3f204df0b2c88ca0407f893b0c17f8de889b614d.zip
Datenbank Mapper hinzugefügt
Diffstat (limited to 'application')
-rw-r--r--application/models/BootOs.php229
-rw-r--r--application/models/BootOsMapper.php146
-rw-r--r--application/models/Client.php139
-rw-r--r--application/models/ClientMapper.php153
-rw-r--r--application/models/Config.php170
-rw-r--r--application/models/ConfigMapper.php148
-rw-r--r--application/models/DbTable/BootOs.php20
-rw-r--r--application/models/DbTable/Client.php20
-rw-r--r--application/models/DbTable/Config.php20
-rw-r--r--application/models/DbTable/Event.php20
-rw-r--r--application/models/DbTable/Eventreport.php20
-rw-r--r--application/models/DbTable/Group.php20
-rw-r--r--application/models/DbTable/GroupGroups.php20
-rw-r--r--application/models/DbTable/Membership.php20
-rw-r--r--application/models/DbTable/Person.php20
-rw-r--r--application/models/DbTable/Pool.php20
-rw-r--r--application/models/DbTable/PoolEntries.php20
-rw-r--r--application/models/Event.php221
-rw-r--r--application/models/EventMapper.php146
-rw-r--r--application/models/Eventreport.php121
-rw-r--r--application/models/EventreportMapper.php146
-rw-r--r--application/models/Group.php119
-rw-r--r--application/models/GroupGroups.php109
-rw-r--r--application/models/GroupGroupsMapper.php171
-rw-r--r--application/models/GroupMapper.php144
-rw-r--r--application/models/Membership.php149
-rw-r--r--application/models/MembershipMapper.php151
-rw-r--r--application/models/Person.php251
-rw-r--r--application/models/PersonMapper.php198
-rw-r--r--application/models/Pool.php139
-rw-r--r--application/models/PoolEntries.php118
-rw-r--r--application/models/PoolEntriesMapper.php141
-rw-r--r--application/models/PoolMapper.php152
33 files changed, 3681 insertions, 0 deletions
diff --git a/application/models/BootOs.php b/application/models/BootOs.php
new file mode 100644
index 0000000..f095720
--- /dev/null
+++ b/application/models/BootOs.php
@@ -0,0 +1,229 @@
+<?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_BootOs
+{
+ protected $_bootosID;
+ protected $_groupID;
+ protected $_membershipID;
+ protected $_title;
+ protected $_defaultkcl;
+ protected $_created;
+ protected $_description;
+ protected $_expires;
+ protected $_public;
+ protected $_source;
+ protected $_distro;
+ protected $_distroversion;
+ protected $_shortname;
+ protected $_share;
+
+ 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 bootos property');
+ }
+ $this->$method($value);
+ }
+
+ public function __get($name)
+ {
+ $method = 'get' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid bootos 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->_bootosID;
+ }
+ public function setID($_bootosID)
+ {
+ $this->_bootosID = $_bootosID;
+ return $this;
+ }
+ public function getGroupID()
+ {
+ return $this->_groupID;
+ }
+ public function setGroupID($_groupID)
+ {
+ $this->_groupID = $_groupID;
+ return $this;
+ }
+ public function getMembershipID()
+ {
+ return $this->_membershipID;
+ }
+ public function setMembershipID($_membershipID)
+ {
+ $this->_membershipID = $_membershipID;
+ return $this;
+ }
+ public function getTitle()
+ {
+ return $this->_title;
+ }
+ public function setTitle($_title)
+ {
+ $this->_title = $_title;
+ return $this;
+ }
+ public function getDescription()
+ {
+ return $this->_description;
+ }
+ public function setDescription($_description)
+ {
+ $this->_description = $_description;
+ return $this;
+ }
+ public function getDefaultkcl()
+ {
+ return $this->_defaultkcl;
+ }
+ public function setDefaultkcl($_defaultkcl)
+ {
+ $this->_defaultkcl = $_defaultkcl;
+ return $this;
+ }
+ public function getCreated()
+ {
+ return $this->_created;
+ }
+ public function setCreated($_created)
+ {
+ $this->_created = $_created;
+ return $this;
+ }
+ public function getExpires()
+ {
+ return $this->_expires;
+ }
+ public function setExpires($_expires)
+ {
+ $this->_expires = $_expires;
+ return $this;
+ }
+ public function getPublic()
+ {
+ return $this->_public;
+ }
+ public function setPublic($_public)
+ {
+ $this->_public = $_public;
+ return $this;
+ }
+ public function getSource()
+ {
+ return $this->_source;
+ }
+ public function setSource($_source)
+ {
+ $this->_source = $_source;
+ return $this;
+ }
+ public function getDistro()
+ {
+ return $this->_distro;
+ }
+ public function setDistro($_distro)
+ {
+ $this->_distro = $_distro;
+ return $this;
+ }
+ public function getDistroversion()
+ {
+ return $this->_distroversion;
+ }
+ public function setDistroversion($_distroversion)
+ {
+ $this->_distroversion = $_distroversion;
+ return $this;
+ }
+ public function getShortname()
+ {
+ return $this->_shortname;
+ }
+ public function setShortname($_shortname)
+ {
+ $this->_shortname = $_shortname;
+ return $this;
+ }
+ public function getShare()
+ {
+ return $this->_share;
+ }
+ public function setShare($_share)
+ {
+ $this->_share = $_share;
+ 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/BootOsMapper.php b/application/models/BootOsMapper.php
new file mode 100644
index 0000000..2bde6db
--- /dev/null
+++ b/application/models/BootOsMapper.php
@@ -0,0 +1,146 @@
+<?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_BootOsMapper
+{
+
+ 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();
+ foreach ($result as $row) {
+ $entry = new Application_Model_BootOs($row);
+ $entry->setID($row['bootosID']);
+ $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_BootOs');
+ }
+
+ return $this->_dbTable;
+ }
+
+ public function save(Application_Model_BootOs $botos)
+ {
+ $data = array('bootosID'=> $botos->getID() ,'groupID'=> $botos->getGroupID() ,'title'=> $botos->getTitle(), 'membershipID'=> $botos->getMembershipID(),'defaultkcl'=> $botos->getDefaultkcl() ,'created'=> $botos->getCreated() ,'description'=> $botos->getDescription() ,'expires'=> $botos->getExpires() ,'public'=> $botos->getPublic(),'source'=> $botos->getSource(),'distro'=> $botos->getDistro(),'distroversion'=> $botos->getDistroversion(),'shortname'=> $botos->getShortname(),'share'=> $botos->getShare() );
+ if (null === ($id = $botos->getID()) ) {
+ unset($data['bootosID']);
+ return $this->getDbTable()->insert($data);
+ } else {
+ $this->getDbTable()->update($data, array('bootosID = ?' => $id));
+ }
+ }
+
+ public function delete(Application_Model_BootOs $botos)
+ {
+ if (null === ($id = $botos->getID()) ) {
+ return;
+ } else {
+ $this->getDbTable()->delete(array('bootosID = ?' => $id));
+ }
+ }
+
+ public function find($id, Application_Model_BootOs $botos = null)
+ {
+ $result = $this->getDbTable()->find($id);
+ if (0 == count($result)) {
+ return;
+ }
+
+ $row = $result->current();
+
+ if($botos == null){
+ $botos = new Application_Model_BootOs();
+ $botos->setID($row->bootosID)->setGroupID($row->groupID)->setMembershipID($row->membershipID)->setTitle($row->title)->setDefaultkcl($row->defaultkcl)->setCreated($row->created)->setDescription($row->description)->setExpires($row->expires)->setPublic($row->public)->setSource($row->source)->setDistro($row->distro)->setDistroversion($row->distroversion)->setShortname($row->shortname)->setShare($row->share);
+ return $botos;
+ }else{
+ $botos->setID($row->bootosID)->setGroupID($row->groupID)->setMembershipID($row->membershipID)->setTitle($row->title)->setDefaultkcl($row->defaultkcl)->setCreated($row->created)->setDescription($row->description)->setExpires($row->expires)->setPublic($row->public)->setSource($row->source)->setDistro($row->distro)->setDistroversion($row->distroversion)->setShortname($row->shortname)->setShare($row->share);
+ }
+
+ }
+
+ public function fetchAll()
+ {
+ $resultSet = $this->getDbTable()->fetchAll();
+ $entries = array();
+ foreach ($resultSet as $row) {
+ $entry = new Application_Model_BootOs();
+
+ $entry->setID($row->bootosID)->setGroupID($row->groupID)->setMembershipID($row->membershipID)->setTitle($row->title)->setDefaultkcl($row->defaultkcl)->setCreated($row->created)->setDescription($row->description)->setExpires($row->expires)->setPublic($row->public)->setSource($row->source)->setDistro($row->distro)->setDistroversion($row->distroversion)->setShortname($row->shortname)->setShare($row->share);
+
+ $entries[$row->bootosID] = $entry;
+ }
+ return $entries;
+ }
+
+ public function compare(Application_Model_BootOs $v1,Application_Model_BootOs $v2){
+ $vv1 = $v1->toArray();
+ $vv2 = $v2->toArray();
+ return array_diff($vv1,$vv2);
+ }
+
+
+
+}
+
diff --git a/application/models/Client.php b/application/models/Client.php
new file mode 100644
index 0000000..e8108ef
--- /dev/null
+++ b/application/models/Client.php
@@ -0,0 +1,139 @@
+<?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_Client
+{
+ protected $_clientID;
+ protected $_groupID;
+ protected $_macadress;
+ protected $_hardwarehash;
+ protected $_created;
+
+ 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 client property');
+ }
+ $this->$method($value);
+ }
+
+ public function __get($name)
+ {
+ $method = 'get' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid client 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->_clientID;
+ }
+ public function setID($_clientID)
+ {
+ $this->_clientID = $_clientID;
+ return $this;
+ }
+ public function getGroupID()
+ {
+ return $this->_groupID;
+ }
+ public function setGroupID($_groupID)
+ {
+ $this->_groupID = $_groupID;
+ return $this;
+ }
+ public function getMacadress()
+ {
+ return $this->_macadress;
+ }
+ public function setMacadress($_macadress)
+ {
+ $this->_macadress = $_macadress;
+ return $this;
+ }
+ public function getHardwarehash()
+ {
+ return $this->_hardwarehash;
+ }
+ public function setHardwarehash($_hardwarehash)
+ {
+ $this->_hardwarehash = $_hardwarehash;
+ return $this;
+ }
+ public function getCreated()
+ {
+ return $this->_created;
+ }
+ public function setCreated($_created)
+ {
+ $this->_created = $_created;
+ 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/ClientMapper.php b/application/models/ClientMapper.php
new file mode 100644
index 0000000..bcb3286
--- /dev/null
+++ b/application/models/ClientMapper.php
@@ -0,0 +1,153 @@
+<?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_ClientMapper
+{
+
+ 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();
+ foreach ($result as $row) {
+ $entry = new Application_Model_Client($row);
+ $entry->setID($row['clientID']);
+ $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_Client');
+ }
+
+ return $this->_dbTable;
+ }
+
+ public function save(Application_Model_Client $client)
+ {
+
+ $data = array('clientID'=> $client->getID() ,
+ 'groupID' => $client->getGroupID(),
+ 'macadress'=> $client->getMacadress() ,
+ 'hardwarehash'=> $client->getHardwarehash(),
+ 'created'=> $client->getCreated()
+ );
+
+ if (null === ($id = $client->getID()) ) {
+ unset($data['clientID']);
+ return $this->getDbTable()->insert($data);
+ } else {
+ return $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));
+ }
+ }
+
+ public function find($id, Application_Model_Client $client)
+ {
+ $result = $this->getDbTable()->find($id);
+ if (0 == count($result)) {
+ return;
+ }
+
+ $row = $result->current();
+
+ $client->setID($row->clientID)
+ ->setGroupID($row->groupID)
+ ->setMacadress($row->macadress)
+ ->setHardwarehash($row->hardwarehash)
+ ->setCreated($row->created);
+ }
+
+ public function fetchAll()
+ {
+ $resultSet = $this->getDbTable()->fetchAll();
+ $entries = array();
+ foreach ($resultSet as $row) {
+ $entry = new Application_Model_Client();
+
+ $entry->setID($row->clientID)
+ ->setGroupID($row->groupID)
+ ->setMacadress($row->macadress)
+ ->setHardwarehash($row->hardwarehash)
+ ->setCreated($row->created);
+
+ $entries[] = $entry;
+ }
+ return $entries;
+ }
+
+ public function compare(Application_Model_Client $v1,Application_Model_Client $v2){
+ $vv1 = $v1->toArray();
+ $vv2 = $v2->toArray();
+ return array_diff($vv1,$vv2);
+ }
+
+
+}
+
diff --git a/application/models/Config.php b/application/models/Config.php
new file mode 100644
index 0000000..295f922
--- /dev/null
+++ b/application/models/Config.php
@@ -0,0 +1,170 @@
+<?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_Config
+{
+ protected $_configID;
+ protected $_groupID;
+ protected $_membershipID;
+ protected $_title;
+ protected $_description;
+ protected $_visible;
+ protected $_bootosID;
+ protected $_created;
+
+ 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 config property');
+ }
+ $this->$method($value);
+ }
+
+ public function __get($name)
+ {
+ $method = 'get' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid config 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->_configID;
+ }
+ public function setID($_configID)
+ {
+ $this->_configID = $_configID;
+ return $this;
+ }
+ public function getGroupID()
+ {
+ return $this->_groupID;
+ }
+ public function setGroupID($_groupID)
+ {
+ $this->_groupID = $_groupID;
+ return $this;
+ }
+ public function getMembershipID()
+ {
+ return $this->_membershipID;
+ }
+ public function setMembershipID($_membershipID)
+ {
+ $this->_membershipID = $_membershipID;
+ return $this;
+ }
+ public function getTitle()
+ {
+ return $this->_title;
+ }
+ public function setTitle($_title)
+ {
+ $this->_title = $_title;
+ return $this;
+ }
+ public function getCreated()
+ {
+ return $this->_created;
+ }
+ public function setCreated($_created)
+ {
+ $this->_created = $_created;
+ return $this;
+ }
+ public function getDescription()
+ {
+ return $this->_description;
+ }
+ public function setDescription($_description)
+ {
+ $this->_description = $_description;
+ return $this;
+ }
+ public function getVisible()
+ {
+ return $this->_visible;
+ }
+ public function setVisible($_visible)
+ {
+ $this->_visible = $_visible;
+ return $this;
+ }
+ public function getBootosID()
+ {
+ return $this->_bootosID;
+ }
+ public function setBootosID($_bootosID)
+ {
+ $this->_bootosID = $_bootosID;
+ 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/ConfigMapper.php b/application/models/ConfigMapper.php
new file mode 100644
index 0000000..f46bd72
--- /dev/null
+++ b/application/models/ConfigMapper.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_ConfigMapper
+{
+
+ 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();
+ foreach ($result as $row) {
+ $entry = new Application_Model_Config($row);
+ $entry->setID($row['configID']);
+ $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_Config');
+ }
+
+ return $this->_dbTable;
+ }
+
+ public function save(Application_Model_Config $config)
+ {
+
+ $data = array('configID'=> $config->getID() ,'groupID'=> $config->getGroupID(), 'membershipID'=> $config->getMembershipID(), 'title'=> $config->getTitle() , 'created'=> $config->getCreated(), 'description' => $config->getDescription(), 'visible' => $config->getVisible(), 'bootosID' => $config->getBootosID() );
+
+ if (null === ($id = $config->getID()) ) {
+ unset($data['configID']);
+ return $this->getDbTable()->insert($data);
+ } else {
+ $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));
+ }
+ }
+
+ public function find($id, Application_Model_Config $config = null)
+ {
+
+ $result = $this->getDbTable()->find($id);
+ if (0 == count($result)) {
+ return;
+ }
+
+ $row = $result->current();
+
+ if($config == null){
+ $config = new Application_Model_Config();
+ $config->setID($row->configID)->setGroupID($row->groupID)->setMembershipID($row->membershipID)->setCreated($row->created)->setTitle($row->title)->setDescription($row->description)->setVisible($row->visible)->setBootosID($row->bootosID);
+ return $config;
+ }else{
+ $config->setID($row->configID)->setGroupID($row->groupID)->setMembershipID($row->membershipID)->setCreated($row->created)->setTitle($row->title)->setDescription($row->description)->setVisible($row->visible)->setBootosID($row->bootosID);
+ }
+
+ }
+
+ public function fetchAll()
+ {
+ $resultSet = $this->getDbTable()->fetchAll();
+ $entries = array();
+ foreach ($resultSet as $row) {
+ $entry = new Application_Model_Config();
+
+ $entry->setID($row->configID)->setGroupID($row->groupID)->setMembershipID($row->membershipID)->setCreated($row->created)->setTitle($row->title)->setDescription($row->description)->setVisible($row->visible)->setBootosID($row->bootosID);
+
+ $entries[] = $entry;
+ }
+ return $entries;
+ }
+
+ public function compare(Application_Model_Config $v1,Application_Model_Config $v2){
+ $vv1 = $v1->toArray();
+ $vv2 = $v2->toArray();
+ return array_diff($vv1,$vv2);
+ }
+
+
+
+}
+
diff --git a/application/models/DbTable/BootOs.php b/application/models/DbTable/BootOs.php
new file mode 100644
index 0000000..a61167a
--- /dev/null
+++ b/application/models/DbTable/BootOs.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_BootOs extends Zend_Db_Table_Abstract
+{
+
+ protected $_name = 'pbs_bootos';
+
+
+}
+
diff --git a/application/models/DbTable/Client.php b/application/models/DbTable/Client.php
new file mode 100644
index 0000000..59d71a1
--- /dev/null
+++ b/application/models/DbTable/Client.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_Client extends Zend_Db_Table_Abstract
+{
+
+ protected $_name = 'pbs_client';
+
+
+}
+
diff --git a/application/models/DbTable/Config.php b/application/models/DbTable/Config.php
new file mode 100644
index 0000000..56b6a41
--- /dev/null
+++ b/application/models/DbTable/Config.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_Config extends Zend_Db_Table_Abstract
+{
+
+ protected $_name = 'pbs_config';
+
+
+}
+
diff --git a/application/models/DbTable/Event.php b/application/models/DbTable/Event.php
new file mode 100644
index 0000000..aec4dbf
--- /dev/null
+++ b/application/models/DbTable/Event.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_Event extends Zend_Db_Table_Abstract
+{
+
+ protected $_name = 'poolctrl_event';
+
+
+}
+
diff --git a/application/models/DbTable/Eventreport.php b/application/models/DbTable/Eventreport.php
new file mode 100644
index 0000000..6107889
--- /dev/null
+++ b/application/models/DbTable/Eventreport.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_Eventreport extends Zend_Db_Table_Abstract
+{
+
+ protected $_name = 'poolctrl_eventreport';
+
+
+}
+
diff --git a/application/models/DbTable/Group.php b/application/models/DbTable/Group.php
new file mode 100644
index 0000000..d31d93a
--- /dev/null
+++ b/application/models/DbTable/Group.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_Group extends Zend_Db_Table_Abstract
+{
+
+ protected $_name = 'pbs_group';
+
+
+}
+
diff --git a/application/models/DbTable/GroupGroups.php b/application/models/DbTable/GroupGroups.php
new file mode 100644
index 0000000..bd7c7c4
--- /dev/null
+++ b/application/models/DbTable/GroupGroups.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_GroupGroups extends Zend_Db_Table_Abstract
+{
+
+ protected $_name = 'pbs_groupgroups';
+
+
+}
+
diff --git a/application/models/DbTable/Membership.php b/application/models/DbTable/Membership.php
new file mode 100644
index 0000000..cc1d4cc
--- /dev/null
+++ b/application/models/DbTable/Membership.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_Membership extends Zend_Db_Table_Abstract
+{
+
+ protected $_name = 'pbs_membership';
+
+
+}
+
diff --git a/application/models/DbTable/Person.php b/application/models/DbTable/Person.php
new file mode 100644
index 0000000..132e8b6
--- /dev/null
+++ b/application/models/DbTable/Person.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_Person extends Zend_Db_Table_Abstract
+{
+
+ protected $_name = 'pbs_person';
+
+
+}
+
diff --git a/application/models/DbTable/Pool.php b/application/models/DbTable/Pool.php
new file mode 100644
index 0000000..9650166
--- /dev/null
+++ b/application/models/DbTable/Pool.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_Pool extends Zend_Db_Table_Abstract
+{
+
+ protected $_name = 'pbs_pool';
+
+
+}
+
diff --git a/application/models/DbTable/PoolEntries.php b/application/models/DbTable/PoolEntries.php
new file mode 100644
index 0000000..275f443
--- /dev/null
+++ b/application/models/DbTable/PoolEntries.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_PoolEntries extends Zend_Db_Table_Abstract
+{
+
+ protected $_name = 'pbs_poolentries';
+
+
+}
+
diff --git a/application/models/Event.php b/application/models/Event.php
new file mode 100644
index 0000000..a21ec65
--- /dev/null
+++ b/application/models/Event.php
@@ -0,0 +1,221 @@
+<?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_Event
+{
+ protected $_eventID;
+ protected $_title;
+ protected $_start;
+ protected $_end;
+ protected $_participants;
+ protected $_category;
+ protected $_pbs_poolID;
+ protected $_pbs_membershipID;
+ protected $_pbs_bootosID;
+ protected $_repeat;
+ protected $_immediate;
+ protected $_note;
+
+ 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 event property');
+ }
+ $this->$method($value);
+ }
+
+ public function __get($name)
+ {
+ $method = 'get' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid event 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->_eventID;
+ }
+
+ public function setID($_eventID)
+ {
+ $this->_eventID = $_eventID;
+ return $this;
+ }
+
+ public function getTitle()
+ {
+ return $this->_title;
+ }
+
+ public function setTitle($_title)
+ {
+ $this->_title = $_title;
+ }
+
+ public function getStart()
+ {
+ return $this->_start;
+ }
+
+ public function setStart($_start)
+ {
+ $this->_start = $_start;
+ }
+
+ public function getEnd()
+ {
+ return $this->_end;
+ }
+
+ public function setEnd($_end)
+ {
+ $this->_end = $_end;
+ }
+
+ public function getParticipants()
+ {
+ return $this->_participants;
+ }
+
+ public function setParticipants($_participants)
+ {
+ $this->_participants = $_participants;
+ }
+
+ public function getCategory()
+ {
+ return $this->_category;
+ }
+
+ public function setCategory($_category)
+ {
+ $this->_category = $_category;
+ }
+
+ public function getPbsPoolID()
+ {
+ return $this->_pbs_poolID;
+ }
+
+ public function setPbsPoolID($_pbs_poolID)
+ {
+ $this->_pbs_poolID = $_pbs_poolID;
+ }
+
+ public function getPbsMembershipID()
+ {
+ return $this->_pbs_membershipID;
+ }
+
+ public function setPbsMembershipID($_pbs_membershipID)
+ {
+ $this->_pbs_membershipID = $_pbs_membershipID;
+ }
+
+ public function getPbsBootosID()
+ {
+ return $this->_pbs_bootosID;
+ }
+
+ public function setPbsBootosID($_pbs_bootosID)
+ {
+ $this->_pbs_bootosID = $_pbs_bootosID;
+ }
+
+ public function getRepeat()
+ {
+ return $this->_repeat;
+ }
+
+ public function set_repeat($_repeat)
+ {
+ $this->_repeat = $_repeat;
+ }
+
+ public function getImmediate()
+ {
+ return $this->_immediate;
+ }
+
+ public function setImmediate($_immediate)
+ {
+ $this->_immediate = $_immediate;
+ }
+
+ public function getNote()
+ {
+ return $this->_note;
+ }
+
+ public function setNote($_note)
+ {
+ $this->_note = $_note;
+ }
+}
+
diff --git a/application/models/EventMapper.php b/application/models/EventMapper.php
new file mode 100644
index 0000000..ff3bc0c
--- /dev/null
+++ b/application/models/EventMapper.php
@@ -0,0 +1,146 @@
+<?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_EventMapper
+{
+
+ 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();
+ foreach ($result as $row) {
+ $entry = new Application_Model_Event($row);
+ $entry->setID($row['eventID']);
+ $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_Event');
+ }
+
+ return $this->_dbTable;
+ }
+
+ public function save(Application_Model_Event $event)
+ {
+ $data = array('eventID'=> $event->getID() ,'category'=> $event->getCategory() ,'title'=> $event->getTitle(), 'pbs_membershipID'=> $event->getPbsMembershipID(),'end'=> $event->getEnd() ,'immediate'=> $event->getImmediate() ,'note'=> $event->getNote() ,'participants'=> $event->getParticipants() ,'pbs_bootosID'=> $event->getPbsBootosID(),'pbs_poolID'=> $event->getPbsPoolID(),'repeat'=> $event->getRepeat(),'start'=> $event->getStart() );
+ if (null === ($id = $event->getID()) ) {
+ unset($data['eventID']);
+ return $this->getDbTable()->insert($data);
+ } else {
+ $this->getDbTable()->update($data, array('eventID = ?' => $id));
+ }
+ }
+
+ public function delete(Application_Model_Event $event)
+ {
+ if (null === ($id = $event->getID()) ) {
+ return;
+ } else {
+ $this->getDbTable()->delete(array('eventID = ?' => $id));
+ }
+ }
+
+ public function find($id, Application_Model_Event $event = null)
+ {
+ $result = $this->getDbTable()->find($id);
+ if (0 == count($result)) {
+ return;
+ }
+
+ $row = $result->current();
+
+ if($event == null){
+ $event = new Application_Model_Event();
+ $event->setID($row->eventID)->setCategory($row->category)->setTitle($row->title)->setPbsMembershipID($row->pbs_membership)->setEnd($row->end)->setImmediate($row->immediate)->setNote($row->note)->setParticipants($row->participants)->setPbsBootosID($row->pbs_bootosID)->setPbsPoolID($row->pbs_poolID)->setRepeat($row->repeat)->setStart($row->start);
+ return $event;
+ }else{
+ $event->setID($row->eventID)->setCategory($row->category)->setTitle($row->title)->setPbsMembershipID($row->pbs_membership)->setEnd($row->end)->setImmediate($row->immediate)->setNote($row->note)->setParticipants($row->participants)->setPbsBootosID($row->pbs_bootosID)->setPbsPoolID($row->pbs_poolID)->setRepeat($row->repeat)->setStart($row->start);
+ }
+
+ }
+
+ public function fetchAll()
+ {
+ $resultSet = $this->getDbTable()->fetchAll();
+ $entries = array();
+ foreach ($resultSet as $row) {
+ $entry = new Application_Model_Event();
+
+ $entry->setID($row->eventID)->setCategory($row->category)->setTitle($row->title)->setPbsMembershipID($row->pbs_membership)->setEnd($row->end)->setImmediate($row->immediate)->setNote($row->note)->setParticipants($row->participants)->setPbsBootosID($row->pbs_bootosID)->setPbsPoolID($row->pbs_poolID)->setRepeat($row->repeat)->setStart($row->start);
+
+ $entries[$row->eventID] = $entry;
+ }
+ return $entries;
+ }
+
+ public function compare(Application_Model_Event $v1,Application_Model_Event $v2){
+ $vv1 = $v1->toArray();
+ $vv2 = $v2->toArray();
+ return array_diff($vv1,$vv2);
+ }
+
+
+
+}
+
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;
+ }
+}
+
diff --git a/application/models/EventreportMapper.php b/application/models/EventreportMapper.php
new file mode 100644
index 0000000..97337f9
--- /dev/null
+++ b/application/models/EventreportMapper.php
@@ -0,0 +1,146 @@
+<?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_EventreportMapper
+{
+
+ 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();
+ foreach ($result as $row) {
+ $entry = new Application_Model_Eventreportreport($row);
+ $entry->setID($row['reportID']);
+ $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_Eventreport');
+ }
+
+ return $this->_dbTable;
+ }
+
+ public function save(Application_Model_Eventreport $eventreport)
+ {
+ $data = array('reportID'=> $eventreport->getID() ,'eventID'=> $eventreport->getEventID() ,'report'=> $eventreport->getReport() );
+ if (null === ($id = $eventreport->getID()) ) {
+ unset($data['reportID']);
+ return $this->getDbTable()->insert($data);
+ } else {
+ $this->getDbTable()->update($data, array('reportID = ?' => $id));
+ }
+ }
+
+ public function delete(Application_Model_Eventreport $eventreport)
+ {
+ if (null === ($id = $eventreport->getID()) ) {
+ return;
+ } else {
+ $this->getDbTable()->delete(array('reportID = ?' => $id));
+ }
+ }
+
+ public function find($id, Application_Model_Eventreport $eventreport = null)
+ {
+ $result = $this->getDbTable()->find($id);
+ if (0 == count($result)) {
+ return;
+ }
+
+ $row = $result->current();
+
+ if($eventreport == null){
+ $eventreport = new Application_Model_Eventreport();
+ $eventreport->setID($row->reportID)->setEventID($row->eventID)->setReport($row->report);
+ return $eventreport;
+ }else{
+ $eventreport->setID($row->reportID)->setEventID($row->eventID)->setReport($row->report);
+ }
+
+ }
+
+ public function fetchAll()
+ {
+ $resultSet = $this->getDbTable()->fetchAll();
+ $entries = array();
+ foreach ($resultSet as $row) {
+ $entry = new Application_Model_Eventreport();
+
+ $entry->setID($row->reportID)->setEventID($row->eventID)->setReport($row->report);
+
+ $entries[$row->reportID] = $entry;
+ }
+ return $entries;
+ }
+
+ public function compare(Application_Model_Eventreport $v1,Application_Model_Eventreport $v2){
+ $vv1 = $v1->toArray();
+ $vv2 = $v2->toArray();
+ return array_diff($vv1,$vv2);
+ }
+
+
+
+}
+
diff --git a/application/models/Group.php b/application/models/Group.php
new file mode 100644
index 0000000..262f0c3
--- /dev/null
+++ b/application/models/Group.php
@@ -0,0 +1,119 @@
+<?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_Group
+{
+ protected $_groupID;
+ protected $_title;
+ protected $_description;
+
+ 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 group property');
+ }
+ $this->$method($value);
+ }
+
+ public function __get($name)
+ {
+ $method = 'get' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid group 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->_groupID;
+ }
+ public function setID($_groupID)
+ {
+ $this->_groupID = $_groupID;
+ return $this;
+ }
+ public function getTitle()
+ {
+ return $this->_title;
+ }
+ public function setTitle($_title)
+ {
+ $this->_title = $_title;
+ return $this;
+ }
+ public function getDescription()
+ {
+ return $this->_description;
+ }
+ public function setDescription($_description)
+ {
+ $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
new file mode 100644
index 0000000..43dcab1
--- /dev/null
+++ b/application/models/GroupGroups.php
@@ -0,0 +1,109 @@
+<?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_GroupGroups
+{
+ protected $_parentID;
+ 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 groupGroups property');
+ }
+ $this->$method($value);
+ }
+
+ public function __get($name)
+ {
+ $method = 'get' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid groupGroups 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 getParentID()
+ {
+ return $this->_parentID;
+ }
+ public function setParentID($_parentID)
+ {
+ $this->_parentID = $_parentID;
+ return $this;
+ }
+ public function getGroupID()
+ {
+ return $this->_groupID;
+ }
+ public function setGroupID($_groupID)
+ {
+ $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/GroupGroupsMapper.php b/application/models/GroupGroupsMapper.php
new file mode 100644
index 0000000..318b298
--- /dev/null
+++ b/application/models/GroupGroupsMapper.php
@@ -0,0 +1,171 @@
+<?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_GroupGroupsMapper
+{
+
+ 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();
+ foreach ($result as $row) {
+ $entry = new Application_Model_GroupGroups($row);
+ $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_GroupGroups');
+ }
+
+ return $this->_dbTable;
+ }
+
+ public function save(Application_Model_GroupGroups $groupgroups)
+ {
+
+ $data = array('parentID'=> $groupgroups->getParentID() ,'groupID'=> $groupgroups->getGroupID() );
+
+ #Noch zu prüfen ob Eintrag schon vorhanden
+ $this->getDbTable()->insert($data);
+ }
+
+ public function delete(Application_Model_GroupGroups $groupgroups)
+ {
+ if (null === ($id = $groupgroups->getID()) ) {
+ return;
+ } else {
+ $this->getDbTable()->delete(array('groupgroupsID = ?' => $id));
+ }
+ }
+
+ public function find($id, Application_Model_GroupGroups $groupgroups)
+ {
+ $result = $this->getDbTable()->find($id);
+ if (0 == count($result)) {
+ return;
+ }
+
+ $row = $result->current();
+
+ $groupgroups->setParentID($row->parentID)->setGroupID($row->groupID);
+ }
+
+ public function fetchAll()
+ {
+ $resultSet = $this->getDbTable()->fetchAll();
+ $entries = array();
+ foreach ($resultSet as $row) {
+ $entry = new Application_Model_GroupGroups();
+
+ $entry->setParentID($row->parentID)->setGroupID($row->groupID);
+
+ $entries[] = $entry;
+ }
+ return $entries;
+ }
+ private $crawledNodes;
+ // Gets All groupIDs of the parent groups begins with the
+ public function getParentGroups($groupID, &$data=null, $level=0) {
+ if(isset($this->crawledNodes['parent'][$groupID]) && $this->crawledNodes['parent'][$groupID] == 1)
+ return $data;
+ $this->crawledNodes['parent'][$groupID] = 1;
+
+ $data[$level][] = $groupID;
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $query = 'SELECT parentID FROM pbs_groupgroups WHERE groupID="'.$groupID.'"';
+ $stmt = $db->query($query);
+ $result = $stmt->fetchAll();
+ foreach($result as $row){
+ // get the function recursive an increase the level
+ $data = $this->getParentGroups($row['parentID'], $data, $level+1);
+ }
+ return $data;
+ }
+ // Gets all childs-groups from a given group
+ public function getChildGroups($groupID, &$data=null, $level=0) {
+ if(isset($this->crawledNodes['child'][$groupID]) && $this->crawledNodes['child'][$groupID] == 1)
+ return $data;
+ $this->crawledNodes['child'][$groupID] = 1;
+ $data[$level][] = $groupID;
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $query = 'SELECT groupID FROM pbs_groupgroups WHERE parentID="'.$groupID.'"';
+ $stmt = $db->query($query);
+ $result = $stmt->fetchAll();
+ foreach($result as $row){
+ // get the function recursive an increase the level
+ $data = $this->getChildGroups($row['groupID'], $data, $level+1);
+ }
+ return $data;
+ }
+
+ public function compare(Application_Model_GroupGroups $v1,Application_Model_GroupGroups $v2){
+ $vv1 = $v1->toArray();
+ $vv2 = $v2->toArray();
+ return array_diff($vv1,$vv2);
+ }
+
+
+
+
+}
+
diff --git a/application/models/GroupMapper.php b/application/models/GroupMapper.php
new file mode 100644
index 0000000..df93483
--- /dev/null
+++ b/application/models/GroupMapper.php
@@ -0,0 +1,144 @@
+<?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_GroupMapper
+{
+
+ protected $_dbTable;
+
+ public function findBy($where, $array=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);
+ $stmt = $select->query();
+ $result = $stmt->fetchAll();
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_Group($row);
+ $entry->setID($row['groupID']);
+ $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_Group');
+ }
+
+ return $this->_dbTable;
+ }
+
+ public function save(Application_Model_Group $group)
+ {
+
+ $data = array('groupID'=> $group->getID() ,'title'=> $group->getTitle() ,'description'=> $group->getDescription() );
+
+ if (null === ($id = $group->getID()) ) {
+ unset($data['groupID']);
+ $this->getDbTable()->insert($data);
+ } else {
+ $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));
+ }
+ }
+
+ public function find($id,Application_Model_Group $group = null)
+ {
+ $return = false;
+ if($group == null){
+ $return = true;
+ }
+ if($return){
+ $group = new Application_Model_Group();
+ }
+ $result = $this->getDbTable()->find($id);
+ if (0 == count($result)) {
+ return;
+ }
+
+ $row = $result->current();
+
+ $group->setID($row->groupID)->setTitle($row->title)->setDescription($row->description);
+ if($return){
+ return $group;
+ }
+ }
+
+ public function fetchAll()
+ {
+ $resultSet = $this->getDbTable()->fetchAll();
+ $entries = array();
+ foreach ($resultSet as $row) {
+ $entry = new Application_Model_Group();
+
+ $entry->setID($row->groupID)->setTitle($row->title)->setDescription($row->description);
+
+ $entries[] = $entry;
+ }
+ return $entries;
+ }
+
+ public function compare(Application_Model_Group $v1,Application_Model_Group $v2){
+ $vv1 = $v1->toArray();
+ $vv2 = $v2->toArray();
+ return array_diff($vv1,$vv2);
+ }
+
+
+
+}
+
diff --git a/application/models/Membership.php b/application/models/Membership.php
new file mode 100644
index 0000000..a455848
--- /dev/null
+++ b/application/models/Membership.php
@@ -0,0 +1,149 @@
+<?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_Membership
+{
+ protected $_membershipID;
+ protected $_groupID;
+ protected $_roleID;
+ protected $_personID;
+ protected $_suspend;
+ protected $_apikey;
+
+ 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 membership property');
+ }
+ $this->$method($value);
+ }
+
+ public function __get($name)
+ {
+ $method = 'get' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid membership 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->_membershipID;
+ }
+ public function setID($_membershipID)
+ {
+ $this->_membershipID = $_membershipID;
+ return $this;
+ }
+ public function getGroupID()
+ {
+ return $this->_groupID;
+ }
+ public function setGroupID($_groupID)
+ {
+ $this->_groupID = $_groupID;
+ return $this;
+ }
+ public function getRoleID()
+ {
+ return $this->_roleID;
+ }
+ public function setRoleID($_roleID)
+ {
+ $this->_roleID = $_roleID;
+ return $this;
+ }
+ public function getPersonID()
+ {
+ return $this->_personID;
+ }
+ public function setPersonID($_personID)
+ {
+ $this->_personID = $_personID;
+ return $this;
+ }
+ public function getSuspend()
+ {
+ return $this->_suspend;
+ }
+ public function setSuspend($_suspend)
+ {
+ $this->_suspend = $_suspend;
+ return $this;
+ }
+ public function getApikey()
+ {
+ return $this->_apikey;
+ }
+ public function setApikey($_apikey)
+ {
+ $this->_apikey = $_apikey;
+ 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/MembershipMapper.php b/application/models/MembershipMapper.php
new file mode 100644
index 0000000..6786c92
--- /dev/null
+++ b/application/models/MembershipMapper.php
@@ -0,0 +1,151 @@
+<?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_MembershipMapper
+{
+
+ 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();
+ foreach ($result as $row) {
+ $entry = new Application_Model_Membership($row);
+ $entry->setID($row['membershipID']);
+ $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_Membership');
+ }
+
+ return $this->_dbTable;
+ }
+
+ public function save(Application_Model_Membership $membership)
+ {
+
+ $data = array('membershipID'=> $membership->getID() ,'groupID'=> $membership->getGroupID() ,'roleID'=> $membership->getRoleID() ,'personID'=> $membership->getPersonID() ,'suspend'=> $membership->getSuspend(), 'apikey'=> $membership->getApikey() );
+
+ if (null === ($id = $membership->getID()) ) {
+ unset($data['membershipID']);
+ return $this->getDbTable()->insert($data);
+ } else {
+ $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));
+ }
+ }
+
+ public function find($id, Application_Model_Membership $membership = null)
+ {
+ $return = false;
+ if($membership == null){
+ $return = true;
+ }
+ if($return){
+ $membership = new Application_Model_Membership();
+ }
+ $result = $this->getDbTable()->find($id);
+ if (0 == count($result)) {
+ return;
+ }
+
+ $row = $result->current();
+
+ $membership->setID($row->membershipID)->setGroupID($row->groupID)->setRoleID($row->roleID)->setPersonID($row->personID)->setSuspend($row->suspend)->setApikey($row->apikey);
+ if($return){
+ return $membership;
+ }
+ }
+
+ public function fetchAll()
+ {
+ $resultSet = $this->getDbTable()->fetchAll();
+ $entries = array();
+ foreach ($resultSet as $row) {
+ $entry = new Application_Model_Membership();
+
+ $entry->setID($row->membershipID)->setGroupID($row->groupID)->setRoleID($row->roleID)->setPersonID($row->personID)->setSuspend($row->suspend)->setApikey($row->apikey);
+
+ $entries[] = $entry;
+ }
+ return $entries;
+ }
+
+ public function compare(Application_Model_Membership $v1,Application_Model_Membership $v2){
+ $vv1 = $v1->toArray();
+ $vv2 = $v2->toArray();
+ return array_diff($vv1,$vv2);
+ }
+
+
+
+}
+
diff --git a/application/models/Person.php b/application/models/Person.php
new file mode 100644
index 0000000..637eb7d
--- /dev/null
+++ b/application/models/Person.php
@@ -0,0 +1,251 @@
+<?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_Person
+{
+ protected $_personID;
+ protected $_title;
+ protected $_name;
+ protected $_firstname;
+ protected $_street;
+ protected $_housenumber;
+ protected $_city;
+ protected $_postalcode;
+ protected $_logindate;
+ protected $_registerdate;
+ protected $_email;
+ protected $_login;
+ protected $_password;
+ protected $_password_salt;
+ protected $_loginpassword;
+ protected $_suspend;
+
+ 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 person property');
+ }
+ $this->$method($value);
+ }
+
+ public function __get($name)
+ {
+ $method = 'get' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid person property');
+ }
+ return $this->$method();
+ }
+
+ public function setOptions(array $options)
+ {
+ $methods = get_class_methods($this);
+ $options['passwordSalt'] = $options['password_salt'];
+ unset($options['password_salt']);
+ foreach ($options as $key => $value) {
+ $method = 'set' . ucfirst($key);
+ if (in_array($method, $methods)) {
+ $this->$method($value);
+ }
+ }
+ return $this;
+ }
+
+
+ public function getID()
+ {
+ return $this->_personID;
+ }
+ public function setID($_personID)
+ {
+ $this->_personID = $_personID;
+ return $this;
+ }
+ public function getTitle()
+ {
+ return $this->_title;
+ }
+ public function setTitle($_title)
+ {
+ $this->_title = $_title;
+ return $this;
+ }
+ public function getName()
+ {
+ return $this->_name;
+ }
+ public function setName($_name)
+ {
+ $this->_name = $_name;
+ return $this;
+ }
+ public function getFirstname()
+ {
+ return $this->_firstname;
+ }
+ public function setFirstname($_firstname)
+ {
+ $this->_firstname = $_firstname;
+ return $this;
+ }
+ public function getStreet()
+ {
+ return $this->_street;
+ }
+ public function setStreet($_street)
+ {
+ $this->_street = $_street;
+ return $this;
+ }
+ public function getHousenumber()
+ {
+ return $this->_housenumber;
+ }
+ public function setHousenumber($_housenumber)
+ {
+ $this->_housenumber = $_housenumber;
+ return $this;
+ }
+ public function getCity()
+ {
+ return $this->_city;
+ }
+ public function setCity($_city)
+ {
+ $this->_city = $_city;
+ return $this;
+ }
+ public function getPostalcode()
+ {
+ return $this->_postalcode;
+ }
+ public function setPostalcode($_postalcode)
+ {
+ $this->_postalcode = $_postalcode;
+ return $this;
+ }
+ public function getLogindate()
+ {
+ return $this->_logindate;
+ }
+ public function setLogindate($_logindate)
+ {
+ $this->_logindate = $_logindate;
+ return $this;
+ }
+ public function getRegisterdate()
+ {
+ return $this->_registerdate;
+ }
+ public function setRegisterdate($_registerdate)
+ {
+ $this->_registerdate = $_registerdate;
+ return $this;
+ }
+ public function getEmail()
+ {
+ return $this->_email;
+ }
+ public function setEmail($_email)
+ {
+ $this->_email = $_email;
+ return $this;
+ }
+ public function getLogin()
+ {
+ return $this->_login;
+ }
+ public function setLogin($_login)
+ {
+ $this->_login = $_login;
+ return $this;
+ }
+ public function getPassword()
+ {
+ return $this->_password;
+ }
+ public function setPassword($_password)
+ {
+ $this->_password = $_password;
+ return $this;
+ }
+ public function getLoginpassword()
+ {
+ return $this->_loginpassword;
+ }
+ public function setLoginpassword($_loginpassword)
+ {
+ $this->_loginpassword = $_loginpassword;
+ return $this;
+ }
+ public function setPasswordSalt($_password_salt)
+ {
+ $this->_password_salt = $_password_salt;
+ return $this;
+ }
+ public function getPasswordSalt()
+ {
+ return $this->_password_salt;
+ }
+ public function getSuspend()
+ {
+ return $this->_suspend;
+ }
+ public function setSuspend($_suspend)
+ {
+ $this->_suspend = $_suspend;
+ 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/PersonMapper.php b/application/models/PersonMapper.php
new file mode 100644
index 0000000..9330e7e
--- /dev/null
+++ b/application/models/PersonMapper.php
@@ -0,0 +1,198 @@
+<?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_PersonMapper
+{
+
+ 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);
+ }
+ # print_a($select);
+ $stmt = $select->query();
+ # print_a($stmt);
+ $result = $stmt->fetchAll();
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_Person($row);
+ $entry->setID($row['personID']);
+ $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_Person');
+ }
+
+ return $this->_dbTable;
+ }
+
+ public function save(Application_Model_Person $person)
+ {
+
+ $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(),
+ 'loginpassword'=> $person->getLoginpassword() ,
+ 'password_salt'=> $person->getPasswordSalt() ,
+ 'suspend'=> $person->getSuspend() );
+
+ if (null === ($id = $person->getID()) ) {
+ unset($data['personID']);
+ $this->getDbTable()->insert($data);
+ } else {
+ $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));
+ }
+ }
+
+ public function find($id,Application_Model_Person $person = null)
+ {
+ $return = false;
+
+ if($person == null){
+ $return = true;
+ }
+ if($return){
+ $person = new Application_Model_Person();
+ }
+ $result = $this->getDbTable()->find($id);
+ if (0 == count($result)) {
+ return;
+ }
+
+ $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)
+ ->setLoginpassword($row->loginpassword)
+ ->setSuspend($row->suspend);
+ if($return){
+ return $person;
+ }
+ }
+
+ public function fetchAll()
+ {
+ $resultSet = $this->getDbTable()->fetchAll();
+ $entries = array();
+ 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)
+ ->setSuspend($row->suspend)
+ ->setLoginpassword($row->loginpassword);
+
+ $entries[] = $entry;
+ }
+ return $entries;
+ }
+
+ public function compare(Application_Model_Person $v1,Application_Model_Person $v2){
+ $vv1 = $v1->toArray();
+ $vv2 = $v2->toArray();
+ return array_diff($vv1,$vv2);
+ }
+
+
+
+}
+
diff --git a/application/models/Pool.php b/application/models/Pool.php
new file mode 100644
index 0000000..4ceca29
--- /dev/null
+++ b/application/models/Pool.php
@@ -0,0 +1,139 @@
+<?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_Pool
+{
+ protected $_poolID;
+ protected $_groupID;
+ protected $_title;
+ protected $_description;
+ protected $_location;
+
+ 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 pool property');
+ }
+ $this->$method($value);
+ }
+
+ public function __get($name)
+ {
+ $method = 'get' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid pool 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->_poolID;
+ }
+ public function setID($_poolID)
+ {
+ $this->_poolID = $_poolID;
+ 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 getDescription()
+ {
+ return $this->_description;
+ }
+ public function setDescription($_description)
+ {
+ $this->_description = $_description;
+ return $this;
+ }
+ public function getLocation()
+ {
+ return $this->_location;
+ }
+ public function setLocation($_location)
+ {
+ $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
new file mode 100644
index 0000000..020358c
--- /dev/null
+++ b/application/models/PoolEntries.php
@@ -0,0 +1,118 @@
+<?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_PoolEntries
+{
+ protected $_poolentriesID;
+ protected $_poolID;
+ protected $_clientID;
+
+ 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 poolentries property');
+ }
+ $this->$method($value);
+ }
+
+ public function __get($name)
+ {
+ $method = 'get' . $name;
+ if (('mapper' == $name) || !method_exists($this, $method)) {
+ throw new Exception('Invalid poolentries 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->_poolentriesID;
+ }
+ public function setID($_poolentriesID)
+ {
+ $this->_poolentriesID = $_poolentriesID;
+ return $this;
+ }
+ public function getPoolID()
+ {
+ return $this->_poolID;
+ }
+ public function setPoolID($_poolID)
+ {
+ $this->_poolID = $_poolID;
+ return $this;
+ }
+ public function getClientID()
+ {
+ return $this->_clientID;
+ }
+ public function setClientID($_clientID)
+ {
+ $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/PoolEntriesMapper.php b/application/models/PoolEntriesMapper.php
new file mode 100644
index 0000000..c5a6893
--- /dev/null
+++ b/application/models/PoolEntriesMapper.php
@@ -0,0 +1,141 @@
+<?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_PoolEntriesMapper
+{
+
+ 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();
+ foreach ($result as $row) {
+ $entry = new Application_Model_PoolEntries($row);
+ $entry->setID($row['poolentriesID']);
+ $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_PoolEntries');
+ }
+
+ return $this->_dbTable;
+ }
+
+ public function save(Application_Model_PoolEntries $polentries)
+ {
+
+ $data = array('poolentriesID' => $polentries->getID(), 'poolID'=> $polentries->getPoolID() ,'clientID'=> $polentries->getClientID() );
+
+ if (null === ($id = $polentries->getID()) ) {
+ unset($data['poolentriesID']);
+ $this->getDbTable()->insert($data);
+ } else {
+ $this->getDbTable()->update($data, array('poolentriesID = ?' => $id));
+ }
+ }
+
+ public function delete(Application_Model_PoolEntries $polentries)
+ {
+ if (null === ($id = $polentries->getID()) ) {
+ return;
+ } else {
+ $this->getDbTable()->delete(array('poolentriesID = ?' => $id));
+ }
+ }
+
+ public function find($id, Application_Model_PoolEntries $polentries)
+ {
+ $result = $this->getDbTable()->find($id);
+ if (0 == count($result)) {
+ return;
+ }
+
+ $row = $result->current();
+
+ $polentries->setID($row->poolentriesID)->setPoolID($row->poolID)->setClientID($row->clientID);
+ }
+
+ public function fetchAll()
+ {
+ $resultSet = $this->getDbTable()->fetchAll();
+ $entries = array();
+ foreach ($resultSet as $row) {
+ $entry = new Application_Model_PoolEntries();
+
+ $entry->setID($row->poolentriesID)->setPoolID($row->poolID)->setClientID($row->clientID);
+
+ $entries[] = $entry;
+ }
+ return $entries;
+ }
+
+ public function compare(Application_Model_PoolEntries $v1,Application_Model_PoolEntries $v2){
+ $vv1 = $v1->toArray();
+ $vv2 = $v2->toArray();
+ return array_diff($vv1,$vv2);
+ }
+
+
+
+}
+
diff --git a/application/models/PoolMapper.php b/application/models/PoolMapper.php
new file mode 100644
index 0000000..469ab92
--- /dev/null
+++ b/application/models/PoolMapper.php
@@ -0,0 +1,152 @@
+<?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_PoolMapper
+{
+
+ 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();
+ foreach ($result as $row) {
+ $entry = new Application_Model_Pool($row);
+ $entry->setID($row['poolID']);
+ $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_Pool');
+ }
+
+ return $this->_dbTable;
+ }
+
+ public function save(Application_Model_Pool $pol)
+ {
+ print_a($pol);
+ $data = array('poolID'=> $pol->getID() ,
+ 'groupID'=> $pol->getGroupID() ,
+ 'title'=> $pol->getTitle() ,
+ 'description'=> $pol->getDescription() ,
+ 'location'=> $pol->getLocation() );
+
+ if (null === ($id = $pol->getID()) ) {
+ unset($data['poolID']);
+ $this->getDbTable()->insert($data);
+ } else {
+ $this->getDbTable()->update($data, array('poolID = ?' => $id));
+ }
+ }
+
+ public function delete(Application_Model_Pool $pol)
+ {
+ if (null === ($id = $pol->getID()) ) {
+ return;
+ } else {
+ $this->getDbTable()->delete(array('poolID = ?' => $id));
+ }
+ }
+
+ public function find($id, Application_Model_Pool $pol)
+ {
+ $result = $this->getDbTable()->find($id);
+ if (0 == count($result)) {
+ return;
+ }
+
+ $row = $result->current();
+
+ $pol->setID($row->poolID)
+ ->setGroupID($row->groupID)
+ ->setTitle($row->title)
+ ->setDescription($row->description)
+ ->setLocation($row->location);
+ }
+
+ public function fetchAll()
+ {
+ $resultSet = $this->getDbTable()->fetchAll();
+ $entries = array();
+ foreach ($resultSet as $row) {
+ $entry = new Application_Model_Pool();
+
+ $entry->setID($row->poolID)
+ ->setGroupID($row->groupID)
+ ->setTitle($row->title)
+ ->setDescription($row->description)
+ ->setLocation($row->location);
+
+ $entries[] = $entry;
+ }
+ return $entries;
+ }
+
+ public function compare(Application_Model_Pool $v1,Application_Model_Pool $v2){
+ $vv1 = $v1->toArray();
+ $vv2 = $v2->toArray();
+ return array_diff($vv1,$vv2);
+ }
+
+
+}
+