diff options
author | Sebastian Schmelzer | 2012-01-11 14:36:35 +0100 |
---|---|---|
committer | Sebastian Schmelzer | 2012-01-11 14:36:35 +0100 |
commit | fca04a6dab252eb9e8c0a92ce3b7e14b32e68d1e (patch) | |
tree | 6e6aaf749f34db8c7c7153c23ef85c57187430bb /application/models | |
parent | API: mit addBootos kann man nun auch editieren (diff) | |
download | pbs2-fca04a6dab252eb9e8c0a92ce3b7e14b32e68d1e.tar.gz pbs2-fca04a6dab252eb9e8c0a92ce3b7e14b32e68d1e.tar.xz pbs2-fca04a6dab252eb9e8c0a92ce3b7e14b32e68d1e.zip |
format source files
Diffstat (limited to 'application/models')
75 files changed, 6772 insertions, 7449 deletions
diff --git a/application/models/BootIso.php b/application/models/BootIso.php index e34c3b8..eca6bf9 100644 --- a/application/models/BootIso.php +++ b/application/models/BootIso.php @@ -1,210 +1,182 @@ -<?php +<? 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_BootIso -{ - protected $_bootisoID; - protected $_title; - protected $_description; - protected $_prebootID; - protected $_membershipID; - protected $_groupID; - protected $_serialnumber; - protected $_created; - protected $_expires; - protected $_public; - - public function __construct(array $options = null) - { - if (is_array($options)) { - $this->setOptions($options); - } +* 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_BootIso { + protected $_bootisoID; + protected $_title; + protected $_description; + protected $_prebootID; + protected $_membershipID; + protected $_groupID; + protected $_serialnumber; + protected $_created; + protected $_expires; + protected $_public; + + 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 bootiso property'); - } + public function __set($name, $value) { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid bootiso property'); + } + $this->$method($value); + } + + public function __get($name) { + $method = 'get' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid bootiso 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); + } } - - public function __get($name) - { - $method = 'get' . $name; - if (('mapper' == $name) || !method_exists($this, $method)) { - throw new Exception('Invalid bootiso property'); + return $this; + } + + public function getID() { + return $this->_bootisoID; + } + public function setID($_bootisoID) { + $this->_bootisoID = $_bootisoID; + return $this; + } + + public function getMembershipID() { + return $this->_membershipID; + } + + public function setMembershipID($_membershipID) { + $this->_membershipID = $_membershipID; + return $this; + } + + public function getGroupID() { + return $this->_groupID; + } + + public function setGroupID($_groupID) { + $this->_groupID = $_groupID; + return $this; + } + public function getTitle() { + return $this->_title; + } + public function setTitle($_title) { + $this->_title = $_title; + return $this; + } + public function getPrebootID() { + return $this->_prebootID; + } + public function setPrebootID($_prebootID) { + $this->_prebootID = $_prebootID; + return $this; + } + public function getSerialnumber() { + return $this->_serialnumber; + } + + public function setSerialnumber($_serialnumber) { + $this->_serialnumber = $_serialnumber; + 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 getBootisoID() { + return $this->_bootisoID; + } + + public function setBootisoID($_bootisoID) { + $this->_bootisoID = $_bootisoID; + 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; } - 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); - } + } + 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 $this; - } - public function getID() - { - return $this->_bootisoID; - } - public function setID($_bootisoID) - { - $this->_bootisoID = $_bootisoID; - return $this; - } - - public function getMembershipID() - { - return $this->_membershipID; - } - - public function setMembershipID($_membershipID) - { - $this->_membershipID = $_membershipID; - return $this; - } - - public function getGroupID() - { - return $this->_groupID; - } - - public function setGroupID($_groupID) - { - $this->_groupID = $_groupID; - return $this; - } - public function getTitle() - { - return $this->_title; - } - public function setTitle($_title) - { - $this->_title = $_title; - return $this; - } - public function getPrebootID() - { - return $this->_prebootID; - } - public function setPrebootID($_prebootID) - { - $this->_prebootID = $_prebootID; - return $this; - } - public function getSerialnumber() - { - return $this->_serialnumber; - } - - public function setSerialnumber($_serialnumber) - { - $this->_serialnumber = $_serialnumber; - 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 getBootisoID() - { - return $this->_bootisoID; - } - - public function setBootisoID($_bootisoID) - { - $this->_bootisoID = $_bootisoID; - 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; + } } + return $result; + } } diff --git a/application/models/BootIsoMapper.php b/application/models/BootIsoMapper.php index 6ca7ad3..3cf5548 100644 --- a/application/models/BootIsoMapper.php +++ b/application/models/BootIsoMapper.php @@ -1,142 +1,134 @@ -<?php +<? 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_BootIsoMapper -{ - - 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_BootIso($row); - $entry->setID($row['bootisoID']); - $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_BootIso'); - } - - return $this->_dbTable; - } - - public function save(Application_Model_BootIso $botiso) - { - - $data = array('bootisoID'=> $botiso->getID() ,'membershipID'=> $botiso->getMembershipID() ,'title'=> $botiso->getTitle(),'prebootID'=> $botiso->getPrebootID() ,'groupID'=> $botiso->getGroupID() ,'serialnumber'=> $botiso->getSerialnumber() ,'created'=> $botiso->getCreated() ,'expires'=> $botiso->getExpires() ,'public'=> $botiso->getPublic(), 'description' => $botiso->getDescription() ); - - if (null === ($id = $botiso->getID()) ) { - unset($data['bootisoID']); - return $this->getDbTable()->insert($data); - } else { - $this->getDbTable()->update($data, array('bootisoID = ?' => $id)); - } - } - - public function delete(Application_Model_BootIso $botiso) - { - if (null === ($id = $botiso->getID()) ) { - return; - } else { - $this->getDbTable()->delete(array('bootisoID = ?' => $id)); - } - } - - public function find($id, Application_Model_BootIso $botiso = null) - { - $result = $this->getDbTable()->find($id); - if (0 == count($result)) { - return; - } - - $row = $result->current(); - - if($botiso == null){ - $botiso = new Application_Model_BootIso(); - $botiso->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPrebootID($row->prebootID)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public)->setDescription($row->description); - return $botiso; - }else{ - $botiso->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPrebootID($row->prebootID)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public)->setDescription($row->description); - } - } - - public function fetchAll() - { - $resultSet = $this->getDbTable()->fetchAll(); - $entries = array(); - foreach ($resultSet as $row) { - $entry = new Application_Model_BootIso(); - - $entry->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPrebootID($row->prebootID)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public)->setDescription($row->description); - - $entries[] = $entry; - } - return $entries; - } - - public function compare(Application_Model_BootIso $v1,Application_Model_BootIso $v2){ - $vv1 = $v1->toArray(); - $vv2 = $v2->toArray(); - return array_diff($vv1,$vv2); - } +* 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_BootIsoMapper { + + 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_BootIso($row); + $entry->setID($row['bootisoID']); + $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_BootIso'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_BootIso $botiso) { + + $data = array('bootisoID' => $botiso->getID() , 'membershipID' => $botiso->getMembershipID() , 'title' => $botiso->getTitle(), 'prebootID' => $botiso->getPrebootID() , 'groupID' => $botiso->getGroupID() , 'serialnumber' => $botiso->getSerialnumber() , 'created' => $botiso->getCreated() , 'expires' => $botiso->getExpires() , 'public' => $botiso->getPublic(), 'description' => $botiso->getDescription() ); + + if (null == = ($id = $botiso->getID()) ) { + unset($data['bootisoID']); + return $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('bootisoID = ?' => $id)); + } + } + + public function delete(Application_Model_BootIso $botiso) { + if (null == = ($id = $botiso->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('bootisoID = ?' => $id)); + } + } + + public function find($id, Application_Model_BootIso $botiso = null) { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + if($botiso == null) { + $botiso = new Application_Model_BootIso(); + $botiso->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPrebootID($row->prebootID)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public)->setDescription($row->description); + return $botiso; + } else { + $botiso->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPrebootID($row->prebootID)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public)->setDescription($row->description); + } + } + + public function fetchAll() { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_BootIso(); + + $entry->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPrebootID($row->prebootID)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public)->setDescription($row->description); + + $entries[] = $entry; + } + return $entries; + } + + public function compare(Application_Model_BootIso $v1, Application_Model_BootIso $v2) { + $vv1 = $v1->toArray(); + $vv2 = $v2->toArray(); + return array_diff($vv1, $vv2); + } } diff --git a/application/models/BootMenu.php b/application/models/BootMenu.php index dae3776..a5b8a68 100644 --- a/application/models/BootMenu.php +++ b/application/models/BootMenu.php @@ -1,158 +1,138 @@ -<?php +<? 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/ - */ +* 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_BootMenu -{ - protected $_bootmenuID; - protected $_membershipID; - protected $_groupID; - protected $_title; - protected $_startcounter; - protected $_created; - protected $_defaultbootmenu; - - public function __construct(array $options = null) - { - if (is_array($options)) { - $this->setOptions($options); - } +class Application_Model_BootMenu { + protected $_bootmenuID; + protected $_membershipID; + protected $_groupID; + protected $_title; + protected $_startcounter; + protected $_created; + protected $_defaultbootmenu; + + 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 bootmenu property'); - } - $this->$method($value); + public function __set($name, $value) { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid bootmenu property'); } - - public function __get($name) - { - $method = 'get' . $name; - if (('mapper' == $name) || !method_exists($this, $method)) { - throw new Exception('Invalid bootmenu property'); - } - return $this->$method(); + $this->$method($value); + } + + public function __get($name) { + $method = 'get' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid bootmenu property'); } - - 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; + 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); + } } - - public function getID() - { - return $this->_bootmenuID; - } - public function setID($_bootmenuID) - { - $this->_bootmenuID = $_bootmenuID; - return $this; - } - public function getMembershipID() - { - return $this->_membershipID; - } - public function setMembershipID($_membershipID) - { - $this->_membershipID = $_membershipID; - return $this; - } - public function getGroupID() - { - return $this->_groupID; - } - public function setGroupID($_groupID) - { - $this->_groupID = $_groupID; - return $this; - } - public function getTitle() - { - return $this->_title; - } - public function setTitle($_title) - { - $this->_title = $_title; - return $this; - } - public function getCreated() - { - return $this->_created; - } - public function setStartcounter($_startcounter) - { - $this->_startcounter = $_startcounter; - return $this; - } - public function getStartcounter() - { - return $this->_startcounter; - } - public function setCreated($_created) - { - $this->_created = $_created; - return $this; - } - public function getDefaultbootmenu() - { - return $this->_defaultbootmenu; - } - public function setDefaultbootmenu($_defaultbootmenu) - { - $this->_defaultbootmenu = $_defaultbootmenu; - 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 $this; + } + + public function getID() { + return $this->_bootmenuID; + } + public function setID($_bootmenuID) { + $this->_bootmenuID = $_bootmenuID; + return $this; + } + public function getMembershipID() { + return $this->_membershipID; + } + public function setMembershipID($_membershipID) { + $this->_membershipID = $_membershipID; + return $this; + } + public function getGroupID() { + return $this->_groupID; + } + public function setGroupID($_groupID) { + $this->_groupID = $_groupID; + return $this; + } + public function getTitle() { + return $this->_title; + } + public function setTitle($_title) { + $this->_title = $_title; + return $this; + } + public function getCreated() { + return $this->_created; + } + public function setStartcounter($_startcounter) { + $this->_startcounter = $_startcounter; + return $this; + } + public function getStartcounter() { + return $this->_startcounter; + } + public function setCreated($_created) { + $this->_created = $_created; + return $this; + } + public function getDefaultbootmenu() { + return $this->_defaultbootmenu; + } + public function setDefaultbootmenu($_defaultbootmenu) { + $this->_defaultbootmenu = $_defaultbootmenu; + 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; + + } } + return $result; + } } diff --git a/application/models/BootMenuEntries.php b/application/models/BootMenuEntries.php index 7d53dfb..5d76702 100644 --- a/application/models/BootMenuEntries.php +++ b/application/models/BootMenuEntries.php @@ -1,168 +1,146 @@ -<?php +<? 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/ - */ +* 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_BootMenuEntries -{ - protected $_bootmenuentriesID; - protected $_bootosID; - protected $_bootmenuID; - protected $_title; - protected $_kcl; - protected $_kclappend; - protected $_configID; - protected $_order; - - public function __construct(array $options = null) - { - if (is_array($options)) { - $this->setOptions($options); - } +class Application_Model_BootMenuEntries { + protected $_bootmenuentriesID; + protected $_bootosID; + protected $_bootmenuID; + protected $_title; + protected $_kcl; + protected $_kclappend; + protected $_configID; + protected $_order; + + 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 bootmenuentries property'); - } - $this->$method($value); + public function __set($name, $value) { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid bootmenuentries property'); } - - public function __get($name) - { - $method = 'get' . $name; - if (('mapper' == $name) || !method_exists($this, $method)) { - throw new Exception('Invalid bootmenuentries property'); - } - return $this->$method(); + $this->$method($value); + } + + public function __get($name) { + $method = 'get' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid bootmenuentries property'); } - - 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; + 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); + } } - public function getID() - { - return $this->_bootmenuentriesID; - } - public function setID($_bootmenuentriesID) - { - $this->_bootmenuentriesID = $_bootmenuentriesID; - return $this; - } - public function getBootosID() - { - return $this->_bootosID; - } - public function setBootosID($_bootosID) - { - $this->_bootosID = $_bootosID; - return $this; - } - public function getBootmenuID() - { - return $this->_bootmenuID; - } - public function setBootmenuID($_bootmenuID) - { - $this->_bootmenuID = $_bootmenuID; - return $this; - } - public function getTitle() - { - return $this->_title; - } - public function setTitle($_title) - { - $this->_title = $_title; - return $this; - } - public function getKcl() - { - return $this->_kcl; - } - public function setKcl($_kcl) - { - $this->_kcl = $_kcl; - return $this; - } - public function getKclappend() - { - return $this->_kclappend; - } - public function setKclappend($_kclappend) - { - $this->_kclappend = $_kclappend; - return $this; - } - public function getConfigID() - { - return $this->_configID; - } - public function setConfigID($_configID) - { - $this->_configID = $_configID; - return $this; - } - public function getOrder() - { - return $this->_order; - } - public function setOrder($_order) - { - $this->_order = $_order; - 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 $this; + } + public function getID() { + return $this->_bootmenuentriesID; + } + public function setID($_bootmenuentriesID) { + $this->_bootmenuentriesID = $_bootmenuentriesID; + return $this; + } + public function getBootosID() { + return $this->_bootosID; + } + public function setBootosID($_bootosID) { + $this->_bootosID = $_bootosID; + return $this; + } + public function getBootmenuID() { + return $this->_bootmenuID; + } + public function setBootmenuID($_bootmenuID) { + $this->_bootmenuID = $_bootmenuID; + return $this; + } + public function getTitle() { + return $this->_title; + } + public function setTitle($_title) { + $this->_title = $_title; + return $this; + } + public function getKcl() { + return $this->_kcl; + } + public function setKcl($_kcl) { + $this->_kcl = $_kcl; + return $this; + } + public function getKclappend() { + return $this->_kclappend; + } + public function setKclappend($_kclappend) { + $this->_kclappend = $_kclappend; + return $this; + } + public function getConfigID() { + return $this->_configID; + } + public function setConfigID($_configID) { + $this->_configID = $_configID; + return $this; + } + public function getOrder() { + return $this->_order; + } + public function setOrder($_order) { + $this->_order = $_order; + 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; } - return $result; + } + 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/BootMenuEntriesMapper.php b/application/models/BootMenuEntriesMapper.php index 568dd5f..4978b22 100644 --- a/application/models/BootMenuEntriesMapper.php +++ b/application/models/BootMenuEntriesMapper.php @@ -1,185 +1,173 @@ -<?php +<? 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_BootMenuEntriesMapper -{ - - protected $_dbTable; - - public function findBy($where, $array=false, $order=false) - { - - foreach($where as $k => $v){ - $where[] = "$k = '$v'"; - } - $where = implode(" AND " ,$where); - - try{ - $db = Zend_Db_Table::getDefaultAdapter(); - - $select = $this->getDbTable()->select() - ->from($this->_dbTable) - ->where($where) - ->order('order'); - - 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_BootMenuEntries($row); - $entry->setID($row['bootmenuentriesID']); - $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_BootMenuEntries'); - } - - return $this->_dbTable; - } - - public function save(Application_Model_BootMenuEntries $botmenuentries) - { - - $data = array('bootmenuentriesID' => $botmenuentries->getID(), 'bootosID'=> $botmenuentries->getBootosID() ,'bootmenuID'=> $botmenuentries->getBootmenuID() ,'configID'=> $botmenuentries->getConfigID() ,'title'=> $botmenuentries->getTitle() ,'kcl'=> $botmenuentries->getKcl(),'kclappend'=> $botmenuentries->getKclappend() ,'order'=> $botmenuentries->getOrder() ); - - if (null === ($id = $botmenuentries->getID()) ) { - unset($data['bootmenuentriesID']); - $this->getDbTable()->insert($data); - } else { - $this->getDbTable()->update($data, array('bootmenuentriesID = ?' => $id)); - } - } - - public function order(Application_Model_BootMenuEntries $botmenuentries) - { - $db = Zend_Db_Table::getDefaultAdapter(); - $stmt = $db->query("UPDATE pbs_bootmenuentries SET `order` = `order` + 1 WHERE `order` >= ". $botmenuentries->getOrder() . " AND `bootmenuID` = " . $botmenuentries->getBootmenuID()); - } - - public function orderremove(Application_Model_BootMenuEntries $botmenuentries) - { - $db = Zend_Db_Table::getDefaultAdapter(); - $stmt = $db->query("UPDATE pbs_bootmenuentries SET `order` = `order` - 1 WHERE `order` > ". $botmenuentries->getOrder() . " AND `bootmenuID` = " . $botmenuentries->getBootmenuID()); - } - - public function orderbefore(Application_Model_BootMenuEntries $botmenuentries, $oldval) - { - $db = Zend_Db_Table::getDefaultAdapter(); - print_a($botmenuentries, $oldval); - $stmt = $db->query("UPDATE pbs_bootmenuentries SET `order` = `order` + 1 WHERE `order` >= ". $botmenuentries->getOrder() . " AND `order` < " . $oldval . " AND `bootmenuID` = " . $botmenuentries->getBootmenuID()); - } - - public function orderafter(Application_Model_BootMenuEntries $botmenuentries, $oldval) - { - $db = Zend_Db_Table::getDefaultAdapter(); - print_a($botmenuentries, $oldval); - $stmt = $db->query("UPDATE pbs_bootmenuentries SET `order` = `order` - 1 WHERE `order` <= ". $botmenuentries->getOrder() . " AND `order` > " . $oldval . " AND `bootmenuID` = " . $botmenuentries->getBootmenuID()); - } - - public function delete(Application_Model_BootMenuEntries $botmenuentries) - { - if (null === ($id = $botmenuentries->getID()) ) { - return; - } else { - $this->getDbTable()->delete(array('bootmenuentriesID = ?' => $id)); - } - } - - public function find($id, Application_Model_BootMenuEntries $botmenuentries = null) - { - $result = $this->getDbTable()->find($id); - if (0 == count($result)) { - return; - } - - $row = $result->current(); - - if($botmenuentries == null){ - $botmenuentries = new Application_Model_BootMenuEntries(); - $botmenuentries->setID($row->bootmenuentriesID) - ->setBootosID($row->bootosID) - ->setBootmenuID($row->bootmenuID) - ->setTitle($row->title) - ->setConfigID($row->configID) - ->setKcl($row->kcl) - ->setKclappend($row->kclappend) - ->setOrder($row->order); - return $botmenuentries; - }else{ - $botmenuentries->setID($row->bootmenuentriesID) - ->setBootosID($row->bootosID) - ->setBootmenuID($row->bootmenuID) - ->setTitle($row->title) - ->setConfigID($row->configID) - ->setKcl($row->kcl) - ->setKclappend($row->kclappend) - ->setOrder($row->order); - } - } - - public function fetchAll() - { - $resultSet = $this->getDbTable()->fetchAll(); - $entries = array(); - foreach ($resultSet as $row) { - $entry = new Application_Model_BootMenuEntries(); - $entry->setID($row->bootmenuentriesID)->setBootosID($row->bootosID)->setBootmenuID($row->bootmenuID)->setTitle($row->title)->setConfigID($row->configID)->setKcl($row->kcl)->setKclappend($row->kclappend)->setOrder($row->order); - $entries[] = $entry; - } - return $entries; - } - - public function compare(Application_Model_BootMenuEntries $v1,Application_Model_BootMenuEntries $v2){ - $vv1 = $v1->toArray(); - $vv2 = $v2->toArray(); - return array_diff($vv1,$vv2); - } - - - +* 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_BootMenuEntriesMapper { + + protected $_dbTable; + + public function findBy($where, $array = false, $order = false) { + + foreach($where as $k => $v) { + $where[] = "$k = '$v'"; + } + $where = implode(" AND " , $where); + + try { + $db = Zend_Db_Table::getDefaultAdapter(); + + $select = $this->getDbTable()->select() + ->from($this->_dbTable) + ->where($where) + ->order('order'); + + 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_BootMenuEntries($row); + $entry->setID($row['bootmenuentriesID']); + $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_BootMenuEntries'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_BootMenuEntries $botmenuentries) { + + $data = array('bootmenuentriesID' => $botmenuentries->getID(), 'bootosID' => $botmenuentries->getBootosID() , 'bootmenuID' => $botmenuentries->getBootmenuID() , 'configID' => $botmenuentries->getConfigID() , 'title' => $botmenuentries->getTitle() , 'kcl' => $botmenuentries->getKcl(), 'kclappend' => $botmenuentries->getKclappend() , 'order' => $botmenuentries->getOrder() ); + + if (null == = ($id = $botmenuentries->getID()) ) { + unset($data['bootmenuentriesID']); + $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('bootmenuentriesID = ?' => $id)); + } + } + + public function order(Application_Model_BootMenuEntries $botmenuentries) { + $db = Zend_Db_Table::getDefaultAdapter(); + $stmt = $db->query("UPDATE pbs_bootmenuentries SET `order` = `order` + 1 WHERE `order` >= ". $botmenuentries->getOrder() . " AND `bootmenuID` = " . $botmenuentries->getBootmenuID()); + } + + public function orderremove(Application_Model_BootMenuEntries $botmenuentries) { + $db = Zend_Db_Table::getDefaultAdapter(); + $stmt = $db->query("UPDATE pbs_bootmenuentries SET `order` = `order` - 1 WHERE `order` > ". $botmenuentries->getOrder() . " AND `bootmenuID` = " . $botmenuentries->getBootmenuID()); + } + + public function orderbefore(Application_Model_BootMenuEntries $botmenuentries, $oldval) { + $db = Zend_Db_Table::getDefaultAdapter(); + print_a($botmenuentries, $oldval); + $stmt = $db->query("UPDATE pbs_bootmenuentries SET `order` = `order` + 1 WHERE `order` >= ". $botmenuentries->getOrder() . " AND `order` < " . $oldval . " AND `bootmenuID` = " . $botmenuentries->getBootmenuID()); + } + + public function orderafter(Application_Model_BootMenuEntries $botmenuentries, $oldval) { + $db = Zend_Db_Table::getDefaultAdapter(); + print_a($botmenuentries, $oldval); + $stmt = $db->query("UPDATE pbs_bootmenuentries SET `order` = `order` - 1 WHERE `order` <= ". $botmenuentries->getOrder() . " AND `order` > " . $oldval . " AND `bootmenuID` = " . $botmenuentries->getBootmenuID()); + } + + public function delete(Application_Model_BootMenuEntries $botmenuentries) { + if (null == = ($id = $botmenuentries->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('bootmenuentriesID = ?' => $id)); + } + } + + public function find($id, Application_Model_BootMenuEntries $botmenuentries = null) { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + if($botmenuentries == null) { + $botmenuentries = new Application_Model_BootMenuEntries(); + $botmenuentries->setID($row->bootmenuentriesID) + ->setBootosID($row->bootosID) + ->setBootmenuID($row->bootmenuID) + ->setTitle($row->title) + ->setConfigID($row->configID) + ->setKcl($row->kcl) + ->setKclappend($row->kclappend) + ->setOrder($row->order); + return $botmenuentries; + } else { + $botmenuentries->setID($row->bootmenuentriesID) + ->setBootosID($row->bootosID) + ->setBootmenuID($row->bootmenuID) + ->setTitle($row->title) + ->setConfigID($row->configID) + ->setKcl($row->kcl) + ->setKclappend($row->kclappend) + ->setOrder($row->order); + } + } + + public function fetchAll() { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_BootMenuEntries(); + $entry->setID($row->bootmenuentriesID)->setBootosID($row->bootosID)->setBootmenuID($row->bootmenuID)->setTitle($row->title)->setConfigID($row->configID)->setKcl($row->kcl)->setKclappend($row->kclappend)->setOrder($row->order); + $entries[] = $entry; + } + return $entries; + } + + public function compare(Application_Model_BootMenuEntries $v1, Application_Model_BootMenuEntries $v2) { + $vv1 = $v1->toArray(); + $vv2 = $v2->toArray(); + return array_diff($vv1, $vv2); + } + + + } diff --git a/application/models/BootMenuMapper.php b/application/models/BootMenuMapper.php index 6ba72bd..a729979 100644 --- a/application/models/BootMenuMapper.php +++ b/application/models/BootMenuMapper.php @@ -1,166 +1,158 @@ -<?php +<? 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_BootMenuMapper -{ - - 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_BootMenu($row); - $entry->setID($row['bootmenuID']); - $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_BootMenu'); - } - - return $this->_dbTable; - } - - public function save(Application_Model_BootMenu $botmenu) - { - - $data = array('bootmenuID'=> $botmenu->getID() , - 'membershipID'=> $botmenu->getMembershipID(), - 'groupID'=> $botmenu->getGroupID() , - 'title'=> $botmenu->getTitle() , - 'startcounter'=> $botmenu->getStartcounter() , - 'created'=> $botmenu->getCreated(), - 'defaultbootmenu' => $botmenu->getDefaultbootmenu()); - - if (null === ($id = $botmenu->getID()) ) { - unset($data['bootmenuID']); - return $this->getDbTable()->insert($data); - } else { - $this->getDbTable()->update($data, array('bootmenuID = ?' => $id)); - } - } - - public function delete(Application_Model_BootMenu $botmenu) - { - if (null === ($id = $botmenu->getID()) ) { - return; - } else { - $this->getDbTable()->delete(array('bootmenuID = ?' => $id)); - } - } - - public function find($id, Application_Model_BootMenu $botmenu = null) - { - $result = $this->getDbTable()->find($id); - if (0 == count($result)) { - return; - } - $row = $result->current(); - - if($botmenu == null){ - $botmenu = new Application_Model_BootMenu(); - $botmenu->setID($row->bootmenuID) - ->setMembershipID($row->membershipID) - ->setGroupID($row->groupID) - ->setTitle($row->title) - ->setStartcounter($row->startcounter) - ->setCreated($row->created) - ->setDefaultbootmenu($row->defaultbootmenu); - return $botmenu; - }else{ - $botmenu->setID($row->bootmenuID) - ->setMembershipID($row->membershipID) - ->setGroupID($row->groupID) - ->setTitle($row->title) - ->setStartcounter($row->startcounter) - ->setCreated($row->created) - ->setDefaultbootmenu($row->defaultbootmenu); - } - - - } - - public function fetchAll() - { - $resultSet = $this->getDbTable()->fetchAll(); - $entries = array(); - foreach ($resultSet as $row) { - $entry = new Application_Model_BootMenu(); - - $entry->setID($row->bootmenuID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setTitle($row->title)->setStartcounter($row->startcounter)->setCreated($row->created)->setDefault($row->default); - - $entries[] = $entry; - } - return $entries; - } - - public function compare(Application_Model_BootMenu $v1,Application_Model_BootMenu $v2){ - $vv1 = $v1->toArray(); - $vv2 = $v2->toArray(); - return array_diff($vv1,$vv2); - } - - - +* 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_BootMenuMapper { + + 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_BootMenu($row); + $entry->setID($row['bootmenuID']); + $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_BootMenu'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_BootMenu $botmenu) { + + $data = array('bootmenuID' => $botmenu->getID() , + 'membershipID' => $botmenu->getMembershipID(), + 'groupID' => $botmenu->getGroupID() , + 'title' => $botmenu->getTitle() , + 'startcounter' => $botmenu->getStartcounter() , + 'created' => $botmenu->getCreated(), + 'defaultbootmenu' => $botmenu->getDefaultbootmenu()); + + if (null == = ($id = $botmenu->getID()) ) { + unset($data['bootmenuID']); + return $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('bootmenuID = ?' => $id)); + } + } + + public function delete(Application_Model_BootMenu $botmenu) { + if (null == = ($id = $botmenu->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('bootmenuID = ?' => $id)); + } + } + + public function find($id, Application_Model_BootMenu $botmenu = null) { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + $row = $result->current(); + + if($botmenu == null) { + $botmenu = new Application_Model_BootMenu(); + $botmenu->setID($row->bootmenuID) + ->setMembershipID($row->membershipID) + ->setGroupID($row->groupID) + ->setTitle($row->title) + ->setStartcounter($row->startcounter) + ->setCreated($row->created) + ->setDefaultbootmenu($row->defaultbootmenu); + return $botmenu; + } else { + $botmenu->setID($row->bootmenuID) + ->setMembershipID($row->membershipID) + ->setGroupID($row->groupID) + ->setTitle($row->title) + ->setStartcounter($row->startcounter) + ->setCreated($row->created) + ->setDefaultbootmenu($row->defaultbootmenu); + } + + + } + + public function fetchAll() { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_BootMenu(); + + $entry->setID($row->bootmenuID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setTitle($row->title)->setStartcounter($row->startcounter)->setCreated($row->created)->setDefault($row->default); + + $entries[] = $entry; + } + return $entries; + } + + public function compare(Application_Model_BootMenu $v1, Application_Model_BootMenu $v2) { + $vv1 = $v1->toArray(); + $vv2 = $v2->toArray(); + return array_diff($vv1, $vv2); + } + + + } diff --git a/application/models/BootOs.php b/application/models/BootOs.php index f095720..ebf1750 100644 --- a/application/models/BootOs.php +++ b/application/models/BootOs.php @@ -1,229 +1,195 @@ -<?php +<? 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/ - */ +* 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; +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 __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 __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 __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 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(); - } - - } + 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; + + } } + return $result; + } } diff --git a/application/models/BootOsMapper.php b/application/models/BootOsMapper.php index 2bde6db..dcee7db 100644 --- a/application/models/BootOsMapper.php +++ b/application/models/BootOsMapper.php @@ -1,146 +1,138 @@ -<?php +<? 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); - } - - - +* 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/BootOsUser.php b/application/models/BootOsUser.php index aefd311..ee68b19 100644 --- a/application/models/BootOsUser.php +++ b/application/models/BootOsUser.php @@ -1,154 +1,136 @@ -<?php +<? 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/ - */ +* 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_BootOsUser -{ - protected $_bootosuserID; - protected $_configID; - protected $_login; - protected $_password; - protected $_homepath; - protected $_hometypeID; - - public function __construct(array $options = null) - { - if (is_array($options)) { - $this->setOptions($options); - } +class Application_Model_BootOsUser { + protected $_bootosuserID; + protected $_configID; + protected $_login; + protected $_password; + protected $_homepath; + protected $_hometypeID; + + 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 BootOsUser property'); - } - $this->$method($value); + public function __set($name, $value) { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid BootOsUser property'); } - - public function __get($name) - { - $method = 'get' . $name; - if (('mapper' == $name) || !method_exists($this, $method)) { - throw new Exception('Invalid BootOsUser property'); - } - return $this->$method(); + $this->$method($value); + } + + public function __get($name) { + $method = 'get' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid BootOsUser property'); } - - 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; + 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->_bootosuserID; - } - public function setID($_bootosuserID) - { - $this->_bootosuserID = $_bootosuserID; - return $this; - } + public function getID() { + return $this->_bootosuserID; + } + public function setID($_bootosuserID) { + $this->_bootosuserID = $_bootosuserID; + return $this; + } - public function getConfigID() - { - return $this->_configID; - } + public function getConfigID() { + return $this->_configID; + } - public function setConfigID($_configID) - { - $this->_configID = $_configID; - return $this; - } + public function setConfigID($_configID) { + $this->_configID = $_configID; + return $this; + } - public function getLogin() - { - return $this->_login; - } + public function getLogin() { + return $this->_login; + } - public function setLogin($_login) - { - $this->_login = $_login; - return $this; - } - public function getPassword() - { - return $this->_password; - } + 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 getHomepath() - { - return $this->_homepath; - } - public function setHomepath($_homepath) - { - $this->_homepath = $_homepath; - return $this; - } - public function getHometypeID() - { - return $this->_hometypeID; - } - public function setHometypeID($_hometypeID) - { - $this->_hometypeID = $_hometypeID; - 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(); - } - - } + public function setPassword($_password) { + $this->_password = $_password; + return $this; + } + + public function getHomepath() { + return $this->_homepath; + } + public function setHomepath($_homepath) { + $this->_homepath = $_homepath; + return $this; + } + public function getHometypeID() { + return $this->_hometypeID; + } + public function setHometypeID($_hometypeID) { + $this->_hometypeID = $_hometypeID; + 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; + + } } + return $result; + } } diff --git a/application/models/BootOsUserMapper.php b/application/models/BootOsUserMapper.php index f93cd3f..c33645b 100644 --- a/application/models/BootOsUserMapper.php +++ b/application/models/BootOsUserMapper.php @@ -1,146 +1,138 @@ -<?php +<? 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_BootOsUserMapper -{ - - 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_BootOsUser($row); - $entry->setID($row['bootosuserID']); - $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_BootOsUser'); - } - - return $this->_dbTable; - } - - public function save(Application_Model_BootOsUser $user) - { - $data = array('bootosuserID'=> $user->getID() ,'configID'=> $user->getConfigID() ,'login'=> $user->getLogin(), 'password'=> $user->getPassword(),'homepath'=> $user->getHomepath() ,'hometypeID'=> $user->getHometypeID()); - if (null === ($id = $user->getID()) ) { - unset($data['bootosuserID']); - return $this->getDbTable()->insert($data); - } else { - $this->getDbTable()->update($data, array('bootosuserID = ?' => $id)); - } - } - - public function delete(Application_Model_BootOsUser $user) - { - if (null === ($id = $user->getID()) ) { - return; - } else { - $this->getDbTable()->delete(array('bootosuserID = ?' => $id)); - } - } - - public function find($id, Application_Model_BootOsUser $user = null) - { - $result = $this->getDbTable()->find($id); - if (0 == count($result)) { - return; - } - - $row = $result->current(); - - if($user == null){ - $user = new Application_Model_BootOsUser(); - $user->setID($row->bootosuserID)->setconfigID($row->configID)->setLogin($row->login)->setPassword($row->password)->setHomepath($row->homepath)->setHometypeID($row->hometypeID); - return $user; - }else{ - $user->setID($row->bootosuserID)->setconfigID($row->configID)->setLogin($row->login)->setPassword($row->password)->setHomepath($row->homepath)->setHometypeID($row->hometypeID); - } - - } - - public function fetchAll() - { - $resultSet = $this->getDbTable()->fetchAll(); - $entries = array(); - foreach ($resultSet as $row) { - $entry = new Application_Model_BootOsUser(); - - $user->setID($row->bootosuserID)->setconfigID($row->configID)->setLogin($row->login)->setPassword($row->password)->setHomepath($row->homepath)->setHometypeID($row->hometypeID); - - $entries[$row->bootosuserID] = $entry; - } - return $entries; - } - - public function compare(Application_Model_BootOsUser $v1,Application_Model_BootOsUser $v2){ - $vv1 = $v1->toArray(); - $vv2 = $v2->toArray(); - return array_diff($vv1,$vv2); - } - - - +* 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_BootOsUserMapper { + + 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_BootOsUser($row); + $entry->setID($row['bootosuserID']); + $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_BootOsUser'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_BootOsUser $user) { + $data = array('bootosuserID' => $user->getID() , 'configID' => $user->getConfigID() , 'login' => $user->getLogin(), 'password' => $user->getPassword(), 'homepath' => $user->getHomepath() , 'hometypeID' => $user->getHometypeID()); + if (null == = ($id = $user->getID()) ) { + unset($data['bootosuserID']); + return $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('bootosuserID = ?' => $id)); + } + } + + public function delete(Application_Model_BootOsUser $user) { + if (null == = ($id = $user->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('bootosuserID = ?' => $id)); + } + } + + public function find($id, Application_Model_BootOsUser $user = null) { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + if($user == null) { + $user = new Application_Model_BootOsUser(); + $user->setID($row->bootosuserID)->setconfigID($row->configID)->setLogin($row->login)->setPassword($row->password)->setHomepath($row->homepath)->setHometypeID($row->hometypeID); + return $user; + } else { + $user->setID($row->bootosuserID)->setconfigID($row->configID)->setLogin($row->login)->setPassword($row->password)->setHomepath($row->homepath)->setHometypeID($row->hometypeID); + } + + } + + public function fetchAll() { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_BootOsUser(); + + $user->setID($row->bootosuserID)->setconfigID($row->configID)->setLogin($row->login)->setPassword($row->password)->setHomepath($row->homepath)->setHometypeID($row->hometypeID); + + $entries[$row->bootosuserID] = $entry; + } + return $entries; + } + + public function compare(Application_Model_BootOsUser $v1, Application_Model_BootOsUser $v2) { + $vv1 = $v1->toArray(); + $vv2 = $v2->toArray(); + return array_diff($vv1, $vv2); + } + + + } diff --git a/application/models/Client.php b/application/models/Client.php index e8108ef..a11c6ad 100644 --- a/application/models/Client.php +++ b/application/models/Client.php @@ -1,139 +1,123 @@ -<?php +<? 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/ - */ +* 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; +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 __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 __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 __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 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(); - } - - } + 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; + + } } + return $result; + } } diff --git a/application/models/ClientMapper.php b/application/models/ClientMapper.php index bcb3286..e02a074 100644 --- a/application/models/ClientMapper.php +++ b/application/models/ClientMapper.php @@ -1,153 +1,145 @@ -<?php +<? 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); - } - - +* 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 index 295f922..5f5a288 100644 --- a/application/models/Config.php +++ b/application/models/Config.php @@ -1,170 +1,148 @@ -<?php +<? 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/ - */ +* 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; +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 __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 __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 __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 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(); - } - - } + 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; + + } } + return $result; + } } diff --git a/application/models/ConfigMapper.php b/application/models/ConfigMapper.php index f46bd72..63891f3 100644 --- a/application/models/ConfigMapper.php +++ b/application/models/ConfigMapper.php @@ -1,148 +1,140 @@ -<?php +<? 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); - } - - - +* 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/BootIso.php b/application/models/DbTable/BootIso.php index 088654d..eb47ef0 100644 --- a/application/models/DbTable/BootIso.php +++ b/application/models/DbTable/BootIso.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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_BootIso extends Zend_Db_Table_Abstract -{ +class Application_Model_DbTable_BootIso extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_bootiso'; + protected $_name = 'pbs_bootiso'; } diff --git a/application/models/DbTable/BootMenu.php b/application/models/DbTable/BootMenu.php index 3c35d6c..471c3a2 100644 --- a/application/models/DbTable/BootMenu.php +++ b/application/models/DbTable/BootMenu.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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_BootMenu extends Zend_Db_Table_Abstract -{ +class Application_Model_DbTable_BootMenu extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_bootmenu'; + protected $_name = 'pbs_bootmenu'; } diff --git a/application/models/DbTable/BootMenuEntries.php b/application/models/DbTable/BootMenuEntries.php index 2f74b32..836dfd8 100644 --- a/application/models/DbTable/BootMenuEntries.php +++ b/application/models/DbTable/BootMenuEntries.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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_BootMenuEntries extends Zend_Db_Table_Abstract -{ +class Application_Model_DbTable_BootMenuEntries extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_bootmenuentries'; + protected $_name = 'pbs_bootmenuentries'; } diff --git a/application/models/DbTable/BootOs.php b/application/models/DbTable/BootOs.php index a61167a..c6c80c9 100644 --- a/application/models/DbTable/BootOs.php +++ b/application/models/DbTable/BootOs.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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 -{ +class Application_Model_DbTable_BootOs extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_bootos'; + protected $_name = 'pbs_bootos'; } diff --git a/application/models/DbTable/BootOsUser.php b/application/models/DbTable/BootOsUser.php index 976e21a..1dccf73 100644 --- a/application/models/DbTable/BootOsUser.php +++ b/application/models/DbTable/BootOsUser.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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_BootOsUser extends Zend_Db_Table_Abstract -{ +class Application_Model_DbTable_BootOsUser extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_bootosuser'; + protected $_name = 'pbs_bootosuser'; } diff --git a/application/models/DbTable/Client.php b/application/models/DbTable/Client.php index 59d71a1..a67a04e 100644 --- a/application/models/DbTable/Client.php +++ b/application/models/DbTable/Client.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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 -{ +class Application_Model_DbTable_Client extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_client'; + protected $_name = 'pbs_client'; } diff --git a/application/models/DbTable/Config.php b/application/models/DbTable/Config.php index 56b6a41..de194a9 100644 --- a/application/models/DbTable/Config.php +++ b/application/models/DbTable/Config.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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 -{ +class Application_Model_DbTable_Config extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_config'; + protected $_name = 'pbs_config'; } diff --git a/application/models/DbTable/Filter.php b/application/models/DbTable/Filter.php index 545c587..225076e 100644 --- a/application/models/DbTable/Filter.php +++ b/application/models/DbTable/Filter.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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_Filter extends Zend_Db_Table_Abstract -{ +class Application_Model_DbTable_Filter extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_filter'; + protected $_name = 'pbs_filter'; } diff --git a/application/models/DbTable/FilterEntries.php b/application/models/DbTable/FilterEntries.php index f421bd3..2df226a 100644 --- a/application/models/DbTable/FilterEntries.php +++ b/application/models/DbTable/FilterEntries.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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_FilterEntries extends Zend_Db_Table_Abstract -{ +class Application_Model_DbTable_FilterEntries extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_filterentries'; + protected $_name = 'pbs_filterentries'; } diff --git a/application/models/DbTable/FilterType.php b/application/models/DbTable/FilterType.php index 595e6ca..daabac2 100644 --- a/application/models/DbTable/FilterType.php +++ b/application/models/DbTable/FilterType.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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_FilterType extends Zend_Db_Table_Abstract -{ +class Application_Model_DbTable_FilterType extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_filtertype'; + protected $_name = 'pbs_filtertype'; } diff --git a/application/models/DbTable/Group.php b/application/models/DbTable/Group.php index d31d93a..aaf3c47 100644 --- a/application/models/DbTable/Group.php +++ b/application/models/DbTable/Group.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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 -{ +class Application_Model_DbTable_Group extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_group'; + protected $_name = 'pbs_group'; } diff --git a/application/models/DbTable/GroupGroups.php b/application/models/DbTable/GroupGroups.php index bd7c7c4..eebd43b 100644 --- a/application/models/DbTable/GroupGroups.php +++ b/application/models/DbTable/GroupGroups.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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 -{ +class Application_Model_DbTable_GroupGroups extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_groupgroups'; + protected $_name = 'pbs_groupgroups'; } diff --git a/application/models/DbTable/GroupRequest.php b/application/models/DbTable/GroupRequest.php index 036df59..3361659 100644 --- a/application/models/DbTable/GroupRequest.php +++ b/application/models/DbTable/GroupRequest.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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_GroupRequest extends Zend_Db_Table_Abstract -{ +class Application_Model_DbTable_GroupRequest extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_grouprequest'; + protected $_name = 'pbs_grouprequest'; } diff --git a/application/models/DbTable/HomeType.php b/application/models/DbTable/HomeType.php index 2bd484f..e92e519 100644 --- a/application/models/DbTable/HomeType.php +++ b/application/models/DbTable/HomeType.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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_HomeType extends Zend_Db_Table_Abstract -{ +class Application_Model_DbTable_HomeType extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_hometype'; + protected $_name = 'pbs_hometype'; } diff --git a/application/models/DbTable/Membership.php b/application/models/DbTable/Membership.php index cc1d4cc..164809d 100644 --- a/application/models/DbTable/Membership.php +++ b/application/models/DbTable/Membership.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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 -{ +class Application_Model_DbTable_Membership extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_membership'; + protected $_name = 'pbs_membership'; } diff --git a/application/models/DbTable/PasswordRecovery.php b/application/models/DbTable/PasswordRecovery.php index b4e5082..aadb513 100644 --- a/application/models/DbTable/PasswordRecovery.php +++ b/application/models/DbTable/PasswordRecovery.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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_PasswordRecovery extends Zend_Db_Table_Abstract -{ +class Application_Model_DbTable_PasswordRecovery extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_passwordrecovery'; + protected $_name = 'pbs_passwordrecovery'; } diff --git a/application/models/DbTable/Person.php b/application/models/DbTable/Person.php index 132e8b6..1ae95ca 100644 --- a/application/models/DbTable/Person.php +++ b/application/models/DbTable/Person.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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 -{ +class Application_Model_DbTable_Person extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_person'; + protected $_name = 'pbs_person'; } diff --git a/application/models/DbTable/Pool.php b/application/models/DbTable/Pool.php index 9650166..0aadca7 100644 --- a/application/models/DbTable/Pool.php +++ b/application/models/DbTable/Pool.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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 -{ +class Application_Model_DbTable_Pool extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_pool'; + protected $_name = 'pbs_pool'; } diff --git a/application/models/DbTable/PoolEntries.php b/application/models/DbTable/PoolEntries.php index 275f443..2fe216e 100644 --- a/application/models/DbTable/PoolEntries.php +++ b/application/models/DbTable/PoolEntries.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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 -{ +class Application_Model_DbTable_PoolEntries extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_poolentries'; + protected $_name = 'pbs_poolentries'; } diff --git a/application/models/DbTable/PreBoot.php b/application/models/DbTable/PreBoot.php index 8553d6b..02d3680 100644 --- a/application/models/DbTable/PreBoot.php +++ b/application/models/DbTable/PreBoot.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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_PreBoot extends Zend_Db_Table_Abstract -{ +class Application_Model_DbTable_PreBoot extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_preboot'; + protected $_name = 'pbs_preboot'; } diff --git a/application/models/DbTable/Right.php b/application/models/DbTable/Right.php index d73dd5d..603fee1 100644 --- a/application/models/DbTable/Right.php +++ b/application/models/DbTable/Right.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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_Right extends Zend_Db_Table_Abstract -{ +class Application_Model_DbTable_Right extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_right'; + protected $_name = 'pbs_right'; } diff --git a/application/models/DbTable/RightCategory.php b/application/models/DbTable/RightCategory.php index 4146580..8cf7ef1 100644 --- a/application/models/DbTable/RightCategory.php +++ b/application/models/DbTable/RightCategory.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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_RightCategory extends Zend_Db_Table_Abstract -{ +class Application_Model_DbTable_RightCategory extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_rightcategory'; + protected $_name = 'pbs_rightcategory'; } diff --git a/application/models/DbTable/RightRoles.php b/application/models/DbTable/RightRoles.php index 6a9efe0..1c62f25 100644 --- a/application/models/DbTable/RightRoles.php +++ b/application/models/DbTable/RightRoles.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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_RightRoles extends Zend_Db_Table_Abstract -{ +class Application_Model_DbTable_RightRoles extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_rightroles'; + protected $_name = 'pbs_rightroles'; } diff --git a/application/models/DbTable/Role.php b/application/models/DbTable/Role.php index 94b8679..756d217 100644 --- a/application/models/DbTable/Role.php +++ b/application/models/DbTable/Role.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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_Role extends Zend_Db_Table_Abstract -{ +class Application_Model_DbTable_Role extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_role'; + protected $_name = 'pbs_role'; } diff --git a/application/models/DbTable/Session.php b/application/models/DbTable/Session.php index d74d505..12a8b6b 100644 --- a/application/models/DbTable/Session.php +++ b/application/models/DbTable/Session.php @@ -1,19 +1,18 @@ -<?php +<? 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/ - */ +* 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_Session extends Zend_Db_Table_Abstract -{ +class Application_Model_DbTable_Session extends Zend_Db_Table_Abstract { - protected $_name = 'pbs_session'; + protected $_name = 'pbs_session'; } diff --git a/application/models/Filter.php b/application/models/Filter.php index 2e94aba..1e33f24 100644 --- a/application/models/Filter.php +++ b/application/models/Filter.php @@ -1,169 +1,147 @@ -<?php +<? 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/ - */ +* 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_Filter -{ - protected $_filterID; - protected $_membershipID; - protected $_groupID; - protected $_bootmenuID; - protected $_title; - protected $_description; - protected $_created; - protected $_priority; +class Application_Model_Filter { + protected $_filterID; + protected $_membershipID; + protected $_groupID; + protected $_bootmenuID; + protected $_title; + protected $_description; + protected $_created; + protected $_priority; - public function __construct(array $options = null) - { - if (is_array($options)) { - $this->setOptions($options); - } - } + 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 filter property'); - } - $this->$method($value); - } + public function __set($name, $value) { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid filter property'); + } + $this->$method($value); + } - public function __get($name) - { - $method = 'get' . $name; - if (('mapper' == $name) || !method_exists($this, $method)) { - throw new Exception('Invalid filter property'); - } - return $this->$method(); - } + public function __get($name) { + $method = 'get' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid filter 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 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->_filterID; - } - public function setID($_filterID) - { - $this->_filterID = $_filterID; - return $this; - } - public function getMembershipID() - { - return $this->_membershipID; - } - public function setMembershipID($_membershipID) - { - $this->_membershipID = $_membershipID; - return $this; - } - public function getGroupID() - { - return $this->_groupID; - } - public function setGroupID($_groupID) - { - $this->_groupID = $_groupID; - return $this; - } - public function getBootmenuID() - { - return $this->_bootmenuID; - } - public function setBootmenuID($_bootmenuID) - { - $this->_bootmenuID = $_bootmenuID; - 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 getCreated() - { - return $this->_created; - } - public function setCreated($_created) - { - $this->_created = $_created; - return $this; - } - public function getPriority() - { - return $this->_priority; - } - public function setPriority($_priority) - { - $this->_priority = $_priority; - 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(); - } - - } + public function getID() { + return $this->_filterID; + } + public function setID($_filterID) { + $this->_filterID = $_filterID; + return $this; + } + public function getMembershipID() { + return $this->_membershipID; + } + public function setMembershipID($_membershipID) { + $this->_membershipID = $_membershipID; + return $this; + } + public function getGroupID() { + return $this->_groupID; + } + public function setGroupID($_groupID) { + $this->_groupID = $_groupID; + return $this; + } + public function getBootmenuID() { + return $this->_bootmenuID; + } + public function setBootmenuID($_bootmenuID) { + $this->_bootmenuID = $_bootmenuID; + 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 getCreated() { + return $this->_created; + } + public function setCreated($_created) { + $this->_created = $_created; + return $this; + } + public function getPriority() { + return $this->_priority; + } + public function setPriority($_priority) { + $this->_priority = $_priority; + 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; + + } } + return $result; + } } diff --git a/application/models/FilterEntries.php b/application/models/FilterEntries.php index 68088e2..37accca 100644 --- a/application/models/FilterEntries.php +++ b/application/models/FilterEntries.php @@ -1,138 +1,122 @@ -<?php +<? 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/ - */ +* 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_FilterEntries -{ - protected $_filterentriesID; - protected $_filterID; - protected $_filtertypeID; - protected $_filtervalue; - protected $_filtervalue2; +class Application_Model_FilterEntries { + protected $_filterentriesID; + protected $_filterID; + protected $_filtertypeID; + protected $_filtervalue; + protected $_filtervalue2; - public function __construct(array $options = null) - { - if (is_array($options)) { - $this->setOptions($options); - } - } + 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 filterentries property'); - } - $this->$method($value); - } + public function __set($name, $value) { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid filterentries property'); + } + $this->$method($value); + } - public function __get($name) - { - $method = 'get' . $name; - if (('mapper' == $name) || !method_exists($this, $method)) { - throw new Exception('Invalid filterentries property'); - } - return $this->$method(); - } + public function __get($name) { + $method = 'get' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid filterentries 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 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->_filterentriesID; - } - public function setID($_filterentriesID) - { - $this->_filterentriesID = $_filterentriesID; - return $this; - } - public function getFilterID() - { - return $this->_filterID; - } - public function setFilterID($_filterID) - { - $this->_filterID = $_filterID; - return $this; - } - public function getFiltertypeID() - { - return $this->_filtertypeID; - } - public function setFiltertypeID($_filtertypeID) - { - $this->_filtertypeID = $_filtertypeID; - return $this; - } - public function getFiltervalue() - { - return $this->_filtervalue; - } - public function setFiltervalue($_filtervalue) - { - $this->_filtervalue = $_filtervalue; - return $this; - } - public function getFiltervalue2() - { - return $this->_filtervalue2; - } - public function setFiltervalue2($_filtervalue2) - { - $this->_filtervalue2 = $_filtervalue2; - 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(); - } - - } + public function getID() { + return $this->_filterentriesID; + } + public function setID($_filterentriesID) { + $this->_filterentriesID = $_filterentriesID; + return $this; + } + public function getFilterID() { + return $this->_filterID; + } + public function setFilterID($_filterID) { + $this->_filterID = $_filterID; + return $this; + } + public function getFiltertypeID() { + return $this->_filtertypeID; + } + public function setFiltertypeID($_filtertypeID) { + $this->_filtertypeID = $_filtertypeID; + return $this; + } + public function getFiltervalue() { + return $this->_filtervalue; + } + public function setFiltervalue($_filtervalue) { + $this->_filtervalue = $_filtervalue; + return $this; + } + public function getFiltervalue2() { + return $this->_filtervalue2; + } + public function setFiltervalue2($_filtervalue2) { + $this->_filtervalue2 = $_filtervalue2; + 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; + + } } + return $result; + } } diff --git a/application/models/FilterEntriesMapper.php b/application/models/FilterEntriesMapper.php index f6884f0..f8c20e8 100644 --- a/application/models/FilterEntriesMapper.php +++ b/application/models/FilterEntriesMapper.php @@ -1,170 +1,162 @@ -<?php +<? 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_FilterEntriesMapper -{ - - 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_FilterEntries($row); - $entry->setID($row['filterentriesID']); - $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_FilterEntries'); - } - - return $this->_dbTable; - } - - public function save(Application_Model_FilterEntries $filterentries) - { - try{ - $data = array( 'filterentriesID'=>$filterentries->getID(), - 'filterID'=> $filterentries->getFilterID() , - 'filtertypeID'=> $filterentries->getFiltertypeID() , - 'filtervalue'=> $filterentries->getFiltervalue() , - 'filtervalue2'=> $filterentries->getFiltervalue2() ); - - $filterentries2 = new Application_Model_FilterEntries(); - $result = $this->find($filterentries->getID(),$filterentries2); - - $id1 = $filterentries2->getID(); - - if (0 == count($result) && null == $id1) { - $this->getDbTable()->insert($data); - } else { - $this->getDbTable()->update($data, array('filterentriesID = ?' => $id1)); - } - - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - } - } - - public function delete(Application_Model_FilterEntries $filterentries) - { - try{ - $id1 = $filterentries->getID(); - - - if ((null == $id1)) { - return; - } else { - $this->getDbTable()->delete(array('filterentriesID = ?' => $id1)); - } - - }catch (Zend_Exception $e) { - echo "Error message 2: " . $e->getMessage() . "\n"; - } - } - - public function find($filterentriesID, Application_Model_FilterEntries $filterentries) - { - $result = $this->getDbTable()->find($filterentriesID); - if (0 == count($result)) { - return; - } - $row = $result->current(); - - $filterentries->setID($row->filterentriesID) - ->setFilterID($row->filterID) - ->setFiltertypeID($row->filtertypeID) - ->setFiltervalue($row->filtervalue) - ->setFiltervalue2($row->filtervalue2); - return $filterentries; - } - - - public function fetchAll() - { - $resultSet = $this->getDbTable()->fetchAll(); - $entries = array(); - foreach ($resultSet as $row) { - $entry = new Application_Model_FilterEntries(); - - $entry->setID($row->filterentriesID) - ->setFilterID($row->filterID) - ->setFiltertypeID($row->filtertypeID) - ->setFiltervalue($row->filtervalue) - ->setFiltervalue2($row->filtervalue2); - - $entries[] = $entry; - } - return $entries; - } - - public function compare(Application_Model_FilterEntries $v1,Application_Model_FilterEntries $v2){ - $vv1 = $v1->toArray(); - $vv2 = $v2->toArray(); - return array_diff($vv1,$vv2); - } - - - +* 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_FilterEntriesMapper { + + 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_FilterEntries($row); + $entry->setID($row['filterentriesID']); + $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_FilterEntries'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_FilterEntries $filterentries) { + try { + $data = array( 'filterentriesID' => $filterentries->getID(), + 'filterID' => $filterentries->getFilterID() , + 'filtertypeID' => $filterentries->getFiltertypeID() , + 'filtervalue' => $filterentries->getFiltervalue() , + 'filtervalue2' => $filterentries->getFiltervalue2() ); + + $filterentries2 = new Application_Model_FilterEntries(); + $result = $this->find($filterentries->getID(), $filterentries2); + + $id1 = $filterentries2->getID(); + + if (0 == count($result) && null == $id1) { + $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('filterentriesID = ?' => $id1)); + } + + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + } + + public function delete(Application_Model_FilterEntries $filterentries) { + try { + $id1 = $filterentries->getID(); + + + if ((null == $id1)) { + return; + } else { + $this->getDbTable()->delete(array('filterentriesID = ?' => $id1)); + } + + } catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + } + + public function find($filterentriesID, Application_Model_FilterEntries $filterentries) { + $result = $this->getDbTable()->find($filterentriesID); + if (0 == count($result)) { + return; + } + $row = $result->current(); + + $filterentries->setID($row->filterentriesID) + ->setFilterID($row->filterID) + ->setFiltertypeID($row->filtertypeID) + ->setFiltervalue($row->filtervalue) + ->setFiltervalue2($row->filtervalue2); + return $filterentries; + } + + + public function fetchAll() { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_FilterEntries(); + + $entry->setID($row->filterentriesID) + ->setFilterID($row->filterID) + ->setFiltertypeID($row->filtertypeID) + ->setFiltervalue($row->filtervalue) + ->setFiltervalue2($row->filtervalue2); + + $entries[] = $entry; + } + return $entries; + } + + public function compare(Application_Model_FilterEntries $v1, Application_Model_FilterEntries $v2) { + $vv1 = $v1->toArray(); + $vv2 = $v2->toArray(); + return array_diff($vv1, $vv2); + } + + + } diff --git a/application/models/FilterMapper.php b/application/models/FilterMapper.php index 53fffad..1ba2e3b 100644 --- a/application/models/FilterMapper.php +++ b/application/models/FilterMapper.php @@ -1,155 +1,147 @@ -<?php +<? 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_FilterMapper -{ - - 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_Filter($row); - $entry->setID($row['filterID']); - $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_Filter'); - } - - return $this->_dbTable; - } - - public function save(Application_Model_Filter $filter) - { - - $data = array('filterID'=> $filter->getID() , - 'membershipID'=> $filter->getMembershipID() , - 'groupID'=> $filter->getGroupID() , - 'bootmenuID'=> $filter->getBootmenuID() , - 'title'=> $filter->getTitle() , - 'description'=> $filter->getDescription() , - 'created'=> $filter->getCreated() , - 'priority'=> $filter->getPriority() ); - - if (null === ($id = $filter->getID()) ) { - unset($data['filterID']); - return $this->getDbTable()->insert($data); - } else { - return $this->getDbTable()->update($data, array('filterID = ?' => $id)); - } - } - - public function delete(Application_Model_Filter $filter) - { - if (null === ($id = $filter->getID()) ) { - return; - } else { - $this->getDbTable()->delete(array('filterID = ?' => $id)); - } - } - - public function find($id, Application_Model_Filter $filter) - { - - $result = $this->getDbTable()->find($id); - if (0 == count($result)) { - return; - } - $row = $result->current(); - - $filter->setID($row->filterID) - ->setMembershipID($row->membershipID) - ->setGroupID($row->groupID) - ->setBootmenuID($row->bootmenuID) - ->setTitle($row->title) - ->setDescription($row->description) - ->setCreated($row->created) - ->setPriority($row->priority); - } - - public function fetchAll() - { - $resultSet = $this->getDbTable()->fetchAll(); - $entries = array(); - foreach ($resultSet as $row) { - $entry = new Application_Model_Filter(); - - $entry->setID($row->filterID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setBootmenuID($row->bootmenuID)->setTitle($row->title)->setDescription($row->description)->setCreated($row->created)->setPriority($row->priority); - - $entries[] = $entry; - } - return $entries; - } - - public function compare(Application_Model_Filter $v1,Application_Model_Filter $v2){ - $vv1 = $v1->toArray(); - $vv2 = $v2->toArray(); - return array_diff($vv1,$vv2); - } - - - +* 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_FilterMapper { + + 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_Filter($row); + $entry->setID($row['filterID']); + $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_Filter'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_Filter $filter) { + + $data = array('filterID' => $filter->getID() , + 'membershipID' => $filter->getMembershipID() , + 'groupID' => $filter->getGroupID() , + 'bootmenuID' => $filter->getBootmenuID() , + 'title' => $filter->getTitle() , + 'description' => $filter->getDescription() , + 'created' => $filter->getCreated() , + 'priority' => $filter->getPriority() ); + + if (null == = ($id = $filter->getID()) ) { + unset($data['filterID']); + return $this->getDbTable()->insert($data); + } else { + return $this->getDbTable()->update($data, array('filterID = ?' => $id)); + } + } + + public function delete(Application_Model_Filter $filter) { + if (null == = ($id = $filter->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('filterID = ?' => $id)); + } + } + + public function find($id, Application_Model_Filter $filter) { + + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + $row = $result->current(); + + $filter->setID($row->filterID) + ->setMembershipID($row->membershipID) + ->setGroupID($row->groupID) + ->setBootmenuID($row->bootmenuID) + ->setTitle($row->title) + ->setDescription($row->description) + ->setCreated($row->created) + ->setPriority($row->priority); + } + + public function fetchAll() { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_Filter(); + + $entry->setID($row->filterID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setBootmenuID($row->bootmenuID)->setTitle($row->title)->setDescription($row->description)->setCreated($row->created)->setPriority($row->priority); + + $entries[] = $entry; + } + return $entries; + } + + public function compare(Application_Model_Filter $v1, Application_Model_Filter $v2) { + $vv1 = $v1->toArray(); + $vv2 = $v2->toArray(); + return array_diff($vv1, $vv2); + } + + + } diff --git a/application/models/FilterType.php b/application/models/FilterType.php index 05d4192..7a3bfed 100644 --- a/application/models/FilterType.php +++ b/application/models/FilterType.php @@ -1,109 +1,99 @@ -<?php +<? 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/ - */ +* 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_FilterType -{ - protected $_filtertypeID; - protected $_filtertypename; +class Application_Model_FilterType { + protected $_filtertypeID; + protected $_filtertypename; - public function __construct(array $options = null) - { - if (is_array($options)) { - $this->setOptions($options); - } - } + 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 filtertype property'); - } - $this->$method($value); - } + public function __set($name, $value) { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid filtertype property'); + } + $this->$method($value); + } - public function __get($name) - { - $method = 'get' . $name; - if (('mapper' == $name) || !method_exists($this, $method)) { - throw new Exception('Invalid filtertype property'); - } - return $this->$method(); - } + public function __get($name) { + $method = 'get' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid filtertype 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 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->_filtertypeID; - } - public function setID($_filtertypeID) - { - $this->_filtertypeID = $_filtertypeID; - return $this; - } - public function getFiltertypename() - { - return $this->_filtertypename; - } - public function setFiltertypename($_filtertypename) - { - $this->_filtertypename = $_filtertypename; - 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(); - } - - } + public function getID() { + return $this->_filtertypeID; + } + public function setID($_filtertypeID) { + $this->_filtertypeID = $_filtertypeID; + return $this; + } + public function getFiltertypename() { + return $this->_filtertypename; + } + public function setFiltertypename($_filtertypename) { + $this->_filtertypename = $_filtertypename; + 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; + + } } + return $result; + } } diff --git a/application/models/FilterTypeMapper.php b/application/models/FilterTypeMapper.php index 0ee6498..a83e1fd 100644 --- a/application/models/FilterTypeMapper.php +++ b/application/models/FilterTypeMapper.php @@ -1,142 +1,134 @@ -<?php +<? 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_FilterTypeMapper -{ - - 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_FilterType($row); - $entry->setID($row['filtertypeID']); - $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_FilterType'); - } - - return $this->_dbTable; - } - - public function save(Application_Model_FilterType $filtertype) - { - - $data = array('filtertypeID'=> $filtertype->getID() ,'filtertypename'=> $filtertype->getFiltertypename() ); - - if (null === ($id = $filtertype->getID()) ) { - unset($data['filtertypeID']); - $this->getDbTable()->insert($data); - } else { - $this->getDbTable()->update($data, array('filtertypeID = ?' => $id)); - } - } - - public function delete(Application_Model_FilterType $filtertype) - { - if (null === ($id = $filtertype->getID()) ) { - return; - } else { - $this->getDbTable()->delete(array('filtertypeID = ?' => $id)); - } - } - - public function find($id, Application_Model_FilterType $filtertype) - { - $result = $this->getDbTable()->find($id); - if (0 == count($result)) { - return; - } - - $row = $result->current(); - - $filtertype->setID($row->filtertypeID) - ->setFiltertypename($row->filtertypename); - } - - public function fetchAll() - { - $resultSet = $this->getDbTable()->fetchAll(); - $entries = array(); - foreach ($resultSet as $row) { - $entry = new Application_Model_FilterType(); - - $entry->setID($row->filtertypeID) - ->setFiltertypename($row->filtertypename); - - $entries[] = $entry; - } - return $entries; - } - - public function compare(Application_Model_FilterType $v1,Application_Model_FilterType $v2){ - $vv1 = $v1->toArray(); - $vv2 = $v2->toArray(); - return array_diff($vv1,$vv2); - } - - - +* 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_FilterTypeMapper { + + 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_FilterType($row); + $entry->setID($row['filtertypeID']); + $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_FilterType'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_FilterType $filtertype) { + + $data = array('filtertypeID' => $filtertype->getID() , 'filtertypename' => $filtertype->getFiltertypename() ); + + if (null == = ($id = $filtertype->getID()) ) { + unset($data['filtertypeID']); + $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('filtertypeID = ?' => $id)); + } + } + + public function delete(Application_Model_FilterType $filtertype) { + if (null == = ($id = $filtertype->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('filtertypeID = ?' => $id)); + } + } + + public function find($id, Application_Model_FilterType $filtertype) { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + $filtertype->setID($row->filtertypeID) + ->setFiltertypename($row->filtertypename); + } + + public function fetchAll() { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_FilterType(); + + $entry->setID($row->filtertypeID) + ->setFiltertypename($row->filtertypename); + + $entries[] = $entry; + } + return $entries; + } + + public function compare(Application_Model_FilterType $v1, Application_Model_FilterType $v2) { + $vv1 = $v1->toArray(); + $vv2 = $v2->toArray(); + return array_diff($vv1, $vv2); + } + + + } diff --git a/application/models/Group.php b/application/models/Group.php index 262f0c3..a70373e 100644 --- a/application/models/Group.php +++ b/application/models/Group.php @@ -1,119 +1,107 @@ -<?php +<? 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/ - */ +* 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; +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 __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 __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 __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 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(); - } - - } + 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; + + } } + return $result; + } } diff --git a/application/models/GroupGroups.php b/application/models/GroupGroups.php index 43dcab1..7724c82 100644 --- a/application/models/GroupGroups.php +++ b/application/models/GroupGroups.php @@ -1,109 +1,99 @@ -<?php +<? 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/ - */ +* 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; +class Application_Model_GroupGroups { + protected $_parentID; + protected $_groupID; - public function __construct(array $options = null) - { - if (is_array($options)) { - $this->setOptions($options); - } - } + 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 __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 __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 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(); - } - - } + 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; + + } } + return $result; + } } diff --git a/application/models/GroupGroupsMapper.php b/application/models/GroupGroupsMapper.php index 318b298..e6fc3ab 100644 --- a/application/models/GroupGroupsMapper.php +++ b/application/models/GroupGroupsMapper.php @@ -1,169 +1,161 @@ -<?php +<? 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); - } - +* 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 index df93483..ce598db 100644 --- a/application/models/GroupMapper.php +++ b/application/models/GroupMapper.php @@ -1,144 +1,136 @@ -<?php +<? 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); - } - - - +* 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/GroupRequest.php b/application/models/GroupRequest.php index 21f4716..d5a0e8b 100644 --- a/application/models/GroupRequest.php +++ b/application/models/GroupRequest.php @@ -1,129 +1,115 @@ -<?php +<? 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/ - */ +* 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_GroupRequest -{ - protected $_grouprequestID; - protected $_groupID; - protected $_personID; - protected $_time; +class Application_Model_GroupRequest { + protected $_grouprequestID; + protected $_groupID; + protected $_personID; + protected $_time; - public function __construct(array $options = null) - { - if (is_array($options)) { - $this->setOptions($options); - } - } + 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 grouprequest property'); - } - $this->$method($value); - } + public function __set($name, $value) { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid grouprequest property'); + } + $this->$method($value); + } - public function __get($name) - { - $method = 'get' . $name; - if (('mapper' == $name) || !method_exists($this, $method)) { - throw new Exception('Invalid grouprequest property'); - } - return $this->$method(); - } + public function __get($name) { + $method = 'get' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid grouprequest 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 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->_grouprequestID; - } - public function setID($_grouprequestID) - { - $this->_grouprequestID = $_grouprequestID; - return $this; - } - public function getGroupID() - { - return $this->_groupID; - } - public function setGroupID($_groupID) - { - $this->_groupID = $_groupID; - return $this; - } - public function getPersonID() - { - return $this->_personID; - } - public function setPersonID($_personID) - { - $this->_personID = $_personID; - return $this; - } - public function getTime() - { - return $this->_time; - } - public function setTime($_time) - { - $this->_time = $_time; - 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(); - } - - } + public function getID() { + return $this->_grouprequestID; + } + public function setID($_grouprequestID) { + $this->_grouprequestID = $_grouprequestID; + return $this; + } + public function getGroupID() { + return $this->_groupID; + } + public function setGroupID($_groupID) { + $this->_groupID = $_groupID; + return $this; + } + public function getPersonID() { + return $this->_personID; + } + public function setPersonID($_personID) { + $this->_personID = $_personID; + return $this; + } + public function getTime() { + return $this->_time; + } + public function setTime($_time) { + $this->_time = $_time; + 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; + + } } + return $result; + } } diff --git a/application/models/GroupRequestMapper.php b/application/models/GroupRequestMapper.php index 79d19a0..107e633 100644 --- a/application/models/GroupRequestMapper.php +++ b/application/models/GroupRequestMapper.php @@ -1,143 +1,135 @@ -<?php +<? 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_GroupRequestMapper -{ - - 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_GroupRequest($row); - $entry->setID($row['grouprequestID']); - $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_GroupRequest'); - } - - return $this->_dbTable; - } - - public function save(Application_Model_GroupRequest $grouprequest) - { - - $data = array('grouprequestID'=> $grouprequest->getID() ,'groupID'=> $grouprequest->getGroupID() ,'personID'=> $grouprequest->getPersonID() ,'time'=> $grouprequest->getTime() ); - - if (null === ($id = $grouprequest->getID()) ) { - unset($data['grouprequestID']); - $this->getDbTable()->insert($data); - } else { - $this->getDbTable()->update($data, array('grouprequestID = ?' => $id)); - } - } - - public function delete(Application_Model_GroupRequest $grouprequest) - { - if (null === ($id = $grouprequest->getID()) ) { - return; - } else { - $this->getDbTable()->delete(array('grouprequestID = ?' => $id)); - } - } - - public function find($id) - { - $result = $this->getDbTable()->find($id); - if (0 == count($result)) { - return; - } - - $row = $result->current(); - - $grouprequest = new Application_Model_GroupRequest(); - $grouprequest->setID($row->grouprequestID)->setGroupID($row->groupID)->setPersonID($row->personID)->setTime($row->time); - return $grouprequest; - } - - public function fetchAll() - { - $resultSet = $this->getDbTable()->fetchAll(); - $entries = array(); - foreach ($resultSet as $row) { - $entry = new Application_Model_GroupRequest(); - - $entry->setID($row->grouprequestID)->setGroupID($row->groupID)->setPersonID($row->personID)->setTime($row->time); - - $entries[] = $entry; - } - return $entries; - } - - public function compare(Application_Model_GroupRequest $v1,Application_Model_GroupRequest $v2){ - $vv1 = $v1->toArray(); - $vv2 = $v2->toArray(); - return array_diff($vv1,$vv2); - } - - - +* 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_GroupRequestMapper { + + 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_GroupRequest($row); + $entry->setID($row['grouprequestID']); + $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_GroupRequest'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_GroupRequest $grouprequest) { + + $data = array('grouprequestID' => $grouprequest->getID() , 'groupID' => $grouprequest->getGroupID() , 'personID' => $grouprequest->getPersonID() , 'time' => $grouprequest->getTime() ); + + if (null == = ($id = $grouprequest->getID()) ) { + unset($data['grouprequestID']); + $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('grouprequestID = ?' => $id)); + } + } + + public function delete(Application_Model_GroupRequest $grouprequest) { + if (null == = ($id = $grouprequest->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('grouprequestID = ?' => $id)); + } + } + + public function find($id) { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + $grouprequest = new Application_Model_GroupRequest(); + $grouprequest->setID($row->grouprequestID)->setGroupID($row->groupID)->setPersonID($row->personID)->setTime($row->time); + return $grouprequest; + } + + public function fetchAll() { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_GroupRequest(); + + $entry->setID($row->grouprequestID)->setGroupID($row->groupID)->setPersonID($row->personID)->setTime($row->time); + + $entries[] = $entry; + } + return $entries; + } + + public function compare(Application_Model_GroupRequest $v1, Application_Model_GroupRequest $v2) { + $vv1 = $v1->toArray(); + $vv2 = $v2->toArray(); + return array_diff($vv1, $vv2); + } + + + } diff --git a/application/models/HomeType.php b/application/models/HomeType.php index afdf6ca..0532ae0 100644 --- a/application/models/HomeType.php +++ b/application/models/HomeType.php @@ -1,111 +1,101 @@ -<?php +<? 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/ - */ +* 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_HomeType -{ - protected $_hometypeID; - protected $_name; - - public function __construct(array $options = null) - { - if (is_array($options)) { - $this->setOptions($options); - } +class Application_Model_HomeType { + protected $_hometypeID; + protected $_name; + + 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 HomeType property'); - } - $this->$method($value); + public function __set($name, $value) { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid HomeType property'); } - - public function __get($name) - { - $method = 'get' . $name; - if (('mapper' == $name) || !method_exists($this, $method)) { - throw new Exception('Invalid HomeType property'); - } - return $this->$method(); + $this->$method($value); + } + + public function __get($name) { + $method = 'get' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid HomeType property'); } - - 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; + 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->_hometypeID; - } - public function setID($_hometypeID) - { - $this->_hometypeID = $_hometypeID; - return $this; - } + public function getID() { + return $this->_hometypeID; + } + public function setID($_hometypeID) { + $this->_hometypeID = $_hometypeID; + return $this; + } - public function getName() - { - return $this->_name; - } + public function getName() { + return $this->_name; + } - public function setName($_name) - { - $this->_name = $_name; - return $this; - } + public function setName($_name) { + $this->_name = $_name; + 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(); - } - - } + /** + * 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; } - return $result; + } + 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/HomeTypeMapper.php b/application/models/HomeTypeMapper.php index d795941..71aeb3d 100644 --- a/application/models/HomeTypeMapper.php +++ b/application/models/HomeTypeMapper.php @@ -1,148 +1,140 @@ -<?php +<? 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_HomeTypeMapper -{ - - 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_HomeType($row); - $entry->setID($row['hometypeID']); - $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_HomeType'); - } - - return $this->_dbTable; - } - - public function save(Application_Model_HomeType $hometype) - { - - $data = array('hometypeID'=> $hometype->getID() ,'name'=> $hometype->getName() ); - - if (null === ($id = $hometype->getID()) ) { - unset($data['hometypeID']); - $this->getDbTable()->insert($data); - } else { - $this->getDbTable()->update($data, array('hometypeID = ?' => $id)); - } - } - - public function delete(Application_Model_HomeType $hometype) - { - if (null === ($id = $hometype->getID()) ) { - return; - } else { - $this->getDbTable()->delete(array('hometypeID = ?' => $id)); - } - } - - public function find($id, Application_Model_HomeType $hometype = null) - { - $result = $this->getDbTable()->find($id); - if (0 == count($result)) { - return; - } - - $row = $result->current(); - - if($hometype == null){ - $hometype = new Application_Model_HomeType(); - $hometype->setID($row->hometypeID)->setName($row->name); - return $hometype; - }else{ - $hometype->setID($row->hometypeID)->setName($row->name); - } - - } - - public function fetchAll() - { - $resultSet = $this->getDbTable()->fetchAll(); - $entries = array(); - foreach ($resultSet as $row) { - $entry = new Application_Model_HomeType(); - - $entry->setID($row->hometypeID) - ->setName($row->name); - - $entries[] = $entry; - } - return $entries; - } - - public function compare(Application_Model_HomeType $v1,Application_Model_HomeType $v2){ - $vv1 = $v1->toArray(); - $vv2 = $v2->toArray(); - return array_diff($vv1,$vv2); - } - - - +* 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_HomeTypeMapper { + + 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_HomeType($row); + $entry->setID($row['hometypeID']); + $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_HomeType'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_HomeType $hometype) { + + $data = array('hometypeID' => $hometype->getID() , 'name' => $hometype->getName() ); + + if (null == = ($id = $hometype->getID()) ) { + unset($data['hometypeID']); + $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('hometypeID = ?' => $id)); + } + } + + public function delete(Application_Model_HomeType $hometype) { + if (null == = ($id = $hometype->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('hometypeID = ?' => $id)); + } + } + + public function find($id, Application_Model_HomeType $hometype = null) { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + if($hometype == null) { + $hometype = new Application_Model_HomeType(); + $hometype->setID($row->hometypeID)->setName($row->name); + return $hometype; + } else { + $hometype->setID($row->hometypeID)->setName($row->name); + } + + } + + public function fetchAll() { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_HomeType(); + + $entry->setID($row->hometypeID) + ->setName($row->name); + + $entries[] = $entry; + } + return $entries; + } + + public function compare(Application_Model_HomeType $v1, Application_Model_HomeType $v2) { + $vv1 = $v1->toArray(); + $vv2 = $v2->toArray(); + return array_diff($vv1, $vv2); + } + + + } diff --git a/application/models/Membership.php b/application/models/Membership.php index a455848..11fc6cc 100644 --- a/application/models/Membership.php +++ b/application/models/Membership.php @@ -1,149 +1,131 @@ -<?php +<? 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/ - */ +* 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; +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 __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 __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 __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 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; - } + 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 index 6786c92..c3a7d60 100644 --- a/application/models/MembershipMapper.php +++ b/application/models/MembershipMapper.php @@ -1,149 +1,141 @@ -<?php +<? 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); - } +* 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/PasswordRecovery.php b/application/models/PasswordRecovery.php index f860cdd..81710aa 100644 --- a/application/models/PasswordRecovery.php +++ b/application/models/PasswordRecovery.php @@ -1,108 +1,98 @@ -<?php +<? 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/ - */ +* 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_PasswordRecovery -{ - protected $_personID; - protected $_recoveryID; +class Application_Model_PasswordRecovery { + protected $_personID; + protected $_recoveryID; - public function __construct(array $options = null) - { - if (is_array($options)) { - $this->setOptions($options); - } - } + 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 passwordrecovery property'); - } - $this->$method($value); - } + public function __set($name, $value) { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid passwordrecovery 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 __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->_personID; - } - public function setID($_personID) - { - $this->_personID = $_personID; - return $this; - } + 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->_personID; + } + public function setID($_personID) { + $this->_personID = $_personID; + return $this; + } - public function getRecoveryID() - { - return $this->_recoveryID; - } - public function setRecoveryID($_recoveryID) - { - $this->_recoveryID = $_recoveryID; - 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 getRecoveryID() { + return $this->_recoveryID; + } + public function setRecoveryID($_recoveryID) { + $this->_recoveryID = $_recoveryID; + 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; + } }
\ No newline at end of file diff --git a/application/models/PasswordRecoveryMapper.php b/application/models/PasswordRecoveryMapper.php index c6ffd04..fca4812 100644 --- a/application/models/PasswordRecoveryMapper.php +++ b/application/models/PasswordRecoveryMapper.php @@ -1,145 +1,137 @@ -<?php +<? 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_PasswordRecoveryMapper -{ - 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_PasswordRecovery($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_PasswordRecovery'); - } - - return $this->_dbTable; - } - - public function save(Application_Model_PasswordRecovery $passwordrecovery) - { - - $data = array('personID'=> $passwordrecovery->getID() ,'recoveryID'=> $passwordrecovery->getRecoveryID() ); - - if (null === ($id = $passwordrecovery->getID()) ) { - return; - } else { - $passwordRecoveryFound = $this->find($passwordrecovery->getID()); - if(is_object($passwordRecoveryFound)) { - $personIDFound = $passwordRecoveryFound->getID(); - } - if(isset($personIDFound)) { - $this->getDbTable()->update($data, array('personID = ?' => $passwordrecovery->getID())); - } else { - $this->getDbTable()->insert($data); - } - } - } - - public function delete(Application_Model_PasswordRecovery $passwordrecovery) - { - if (null === ($id = $passwordrecovery->getID()) ) { - return; - } else { - $this->getDbTable()->delete(array('personID = ?' => $id)); - } - } - - public function find($id) - { - $result = $this->getDbTable()->find($id); - if (0 == count($result)) { - return; - } - - $row = $result->current(); - - $passwordrecovery = new Application_Model_PasswordRecovery(); - $passwordrecovery->setID($row->personID)->setRecoveryID($row->recoveryID); - return $passwordrecovery; - } - - public function fetchAll() - { - $resultSet = $this->getDbTable()->fetchAll(); - $entries = array(); - foreach ($resultSet as $row) { - $entry = new Application_Model_PasswordRecovery(); - - $entry->setID($row->personID)->setRecoveryID($row->recoveryID); - - $entries[] = $entry; - } - return $entries; - } - - public function compare(Application_Model_PasswordRecovery $v1,Application_Model_PasswordRecovery $v2){ - $vv1 = $v1->toArray(); - $vv2 = $v2->toArray(); - return array_diff($vv1,$vv2); - } +* 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_PasswordRecoveryMapper { + 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_PasswordRecovery($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_PasswordRecovery'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_PasswordRecovery $passwordrecovery) { + + $data = array('personID' => $passwordrecovery->getID() , 'recoveryID' => $passwordrecovery->getRecoveryID() ); + + if (null == = ($id = $passwordrecovery->getID()) ) { + return; + } else { + $passwordRecoveryFound = $this->find($passwordrecovery->getID()); + if(is_object($passwordRecoveryFound)) { + $personIDFound = $passwordRecoveryFound->getID(); + } + if(isset($personIDFound)) { + $this->getDbTable()->update($data, array('personID = ?' => $passwordrecovery->getID())); + } else { + $this->getDbTable()->insert($data); + } + } + } + + public function delete(Application_Model_PasswordRecovery $passwordrecovery) { + if (null == = ($id = $passwordrecovery->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('personID = ?' => $id)); + } + } + + public function find($id) { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + $passwordrecovery = new Application_Model_PasswordRecovery(); + $passwordrecovery->setID($row->personID)->setRecoveryID($row->recoveryID); + return $passwordrecovery; + } + + public function fetchAll() { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_PasswordRecovery(); + + $entry->setID($row->personID)->setRecoveryID($row->recoveryID); + + $entries[] = $entry; + } + return $entries; + } + + public function compare(Application_Model_PasswordRecovery $v1, Application_Model_PasswordRecovery $v2) { + $vv1 = $v1->toArray(); + $vv2 = $v2->toArray(); + return array_diff($vv1, $vv2); + } } diff --git a/application/models/Person.php b/application/models/Person.php index 637eb7d..40c4cf3 100644 --- a/application/models/Person.php +++ b/application/models/Person.php @@ -1,251 +1,213 @@ -<?php +<? 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/ - */ +* 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; +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 __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 __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 __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 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; - } + 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 index 9330e7e..e8f6169 100644 --- a/application/models/PersonMapper.php +++ b/application/models/PersonMapper.php @@ -1,198 +1,190 @@ -<?php +<? 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); - } - - - +* 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 index 4ceca29..ce90950 100644 --- a/application/models/Pool.php +++ b/application/models/Pool.php @@ -1,139 +1,123 @@ -<?php +<? 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/ - */ +* 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; +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 __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 __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 __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 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(); - } - - } + 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; + + } } + return $result; + } } diff --git a/application/models/PoolEntries.php b/application/models/PoolEntries.php index 020358c..c8f5d2a 100644 --- a/application/models/PoolEntries.php +++ b/application/models/PoolEntries.php @@ -1,118 +1,106 @@ -<?php +<? 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/ - */ +* 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; +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 __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 __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 __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 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(); - } - - } + 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; + + } } + return $result; + } } diff --git a/application/models/PoolEntriesMapper.php b/application/models/PoolEntriesMapper.php index c5a6893..c0a4a69 100644 --- a/application/models/PoolEntriesMapper.php +++ b/application/models/PoolEntriesMapper.php @@ -1,141 +1,133 @@ -<?php +<? 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); - } - - - +* 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 index 469ab92..fef6f60 100644 --- a/application/models/PoolMapper.php +++ b/application/models/PoolMapper.php @@ -1,152 +1,144 @@ -<?php +<? 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); - } - - +* 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); + } + + } diff --git a/application/models/PreBoot.php b/application/models/PreBoot.php index 34b4346..2a2737a 100644 --- a/application/models/PreBoot.php +++ b/application/models/PreBoot.php @@ -1,167 +1,147 @@ -<?php +<? 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_PreBoot -{ - protected $_prebootID; - protected $_title; - protected $_membershipID; - protected $_groupID; - protected $_source; - protected $_created; - protected $_description; - - - - public function __construct(array $options = null) - { - if (is_array($options)) { - $this->setOptions($options); - } +* 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_PreBoot { + protected $_prebootID; + protected $_title; + protected $_membershipID; + protected $_groupID; + protected $_source; + protected $_created; + 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 preboot property'); - } - $this->$method($value); + public function __set($name, $value) { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid preboot property'); } - - public function __get($name) - { - $method = 'get' . $name; - if (('mapper' == $name) || !method_exists($this, $method)) { - throw new Exception('Invalid preboot property'); - } - return $this->$method(); + $this->$method($value); + } + + public function __get($name) { + $method = 'get' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid preboot property'); } - - 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; + return $this->$method(); + } + + public function setOptions(array $options) { + $methods = get_class_methods($this); + foreach ($options as $key => $value) { + $method = 'set' . ucfirst($key); + if (in_array($method, $methods)) { + $this->$method($value); + } } + return $this; + } + + public function getID() { + return $this->_prebootID; + } + public function setID($_prebootID) { + $this->_prebootID = $_prebootID; + return $this; + } + + public function getMembershipID() { + return $this->_membershipID; + } + + public function setMembershipID($_membershipID) { + $this->_membershipID = $_membershipID; + return $this; + } - public function getID() - { - return $this->_prebootID; - } - public function setID($_prebootID) - { - $this->_prebootID = $_prebootID; - return $this; - } - - public function getMembershipID() - { - return $this->_membershipID; - } - - public function setMembershipID($_membershipID) - { - $this->_membershipID = $_membershipID; - return $this; - } - - public function getGroupID() - { - return $this->_groupID; - } - - public function setGroupID($_groupID) - { - $this->_groupID = $_groupID; - return $this; - } - public function getTitle() - { - return $this->_title; - } - public function setTitle($_title) - { - $this->_title = $_title; - return $this; - } - public function getCreated() - { - return $this->_created; - } - - public function setCreated($_created) - { - $this->_created = $_created; - return $this; - } - public function getSource() - { - return $this->_source; - } - - public function setSource($_source) - { - $this->_source = $_source; - 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(); - } - - } + 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 getCreated() { + return $this->_created; + } + + public function setCreated($_created) { + $this->_created = $_created; + return $this; + } + public function getSource() { + return $this->_source; + } + + public function setSource($_source) { + $this->_source = $_source; + 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; } - return $result; + } + elseif(substr($key, 0, 1) == '_' && $this->$key != = null) { + $key = substr($key, 1); + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + } else { + $result[$key] = $this->getID(); + } + + } } + return $result; + } } diff --git a/application/models/PreBootMapper.php b/application/models/PreBootMapper.php index b7b4104..f215e65 100644 --- a/application/models/PreBootMapper.php +++ b/application/models/PreBootMapper.php @@ -1,150 +1,142 @@ -<?php +<? 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_PreBootMapper -{ - - 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_PreBoot($row); - $entry->setID($row['prebootID']); - $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_PreBoot'); - } - - return $this->_dbTable; - } - - public function save(Application_Model_PreBoot $preboot) - { - - $data = array('prebootID'=> $preboot->getID() ,'membershipID'=> $preboot->getMembershipID() ,'title'=> $preboot->getTitle() ,'groupID'=> $preboot->getGroupID(), 'created' => $preboot->getCreated(), 'source' => $preboot->getSource(), 'description' => $preboot->getDescription()); - - if (null === ($id = $preboot->getID()) ) { - unset($data['prebootID']); - return $this->getDbTable()->insert($data); - } else { - $this->getDbTable()->update($data, array('prebootID = ?' => $id)); - } - - } - - public function delete(Application_Model_PreBoot $preboot) - { - if (null === ($id = $preboot->getID()) ) { - return; - } else { - $this->getDbTable()->delete(array('prebootID = ?' => $id)); - } - } - - public function find($id, Application_Model_PreBoot $preboot = null) - { - $result = $this->getDbTable()->find($id); - if (0 == count($result)) { - return; - } - - $row = $result->current(); - - if($preboot == null){ - $preboot = new Application_Model_PreBoot(); - $preboot->setID($row->prebootID)->setMembershipID($row->membershipID)->setTitle($row->title)->setGroupID($row->groupID)->setSource($row->source)->setCreated($row->created)->setDescription($row->description); - return $preboot; - }else{ - $preboot->setID($row->prebootID)->setMembershipID($row->membershipID)->setTitle($row->title)->setGroupID($row->groupID)->setSource($row->source)->setCreated($row->created)->setDescription($row->description); - } - } - - public function fetchAll() - { - $resultSet = $this->getDbTable()->fetchAll(); - $entries = array(); - foreach ($resultSet as $row) { - $entry = new Application_Model_PreBoot(); - - $entry->setID($row->prebootID)->setMembershipID($row->membershipID)->setTitle($row->title)->setGroupID($row->groupID)->setSource($row->source)->setCreated($row->created)->setDescription($row->description); - - $entries[] = $entry; - } - return $entries; - } - - public function compare(Application_Model_PreBoot $v1,Application_Model_PreBoot $v2){ - $vv1 = $v1->toArray(); - $vv2 = $v2->toArray(); - return array_diff($vv1,$vv2); - } - - - +* 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_PreBootMapper { + + 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_PreBoot($row); + $entry->setID($row['prebootID']); + $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_PreBoot'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_PreBoot $preboot) { + + $data = array('prebootID' => $preboot->getID() , 'membershipID' => $preboot->getMembershipID() , 'title' => $preboot->getTitle() , 'groupID' => $preboot->getGroupID(), 'created' => $preboot->getCreated(), 'source' => $preboot->getSource(), 'description' => $preboot->getDescription()); + + if (null == = ($id = $preboot->getID()) ) { + unset($data['prebootID']); + return $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('prebootID = ?' => $id)); + } + + } + + public function delete(Application_Model_PreBoot $preboot) { + if (null == = ($id = $preboot->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('prebootID = ?' => $id)); + } + } + + public function find($id, Application_Model_PreBoot $preboot = null) { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + if($preboot == null) { + $preboot = new Application_Model_PreBoot(); + $preboot->setID($row->prebootID)->setMembershipID($row->membershipID)->setTitle($row->title)->setGroupID($row->groupID)->setSource($row->source)->setCreated($row->created)->setDescription($row->description); + return $preboot; + } else { + $preboot->setID($row->prebootID)->setMembershipID($row->membershipID)->setTitle($row->title)->setGroupID($row->groupID)->setSource($row->source)->setCreated($row->created)->setDescription($row->description); + } + } + + public function fetchAll() { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_PreBoot(); + + $entry->setID($row->prebootID)->setMembershipID($row->membershipID)->setTitle($row->title)->setGroupID($row->groupID)->setSource($row->source)->setCreated($row->created)->setDescription($row->description); + + $entries[] = $entry; + } + return $entries; + } + + public function compare(Application_Model_PreBoot $v1, Application_Model_PreBoot $v2) { + $vv1 = $v1->toArray(); + $vv2 = $v2->toArray(); + return array_diff($vv1, $vv2); + } + + + } diff --git a/application/models/Right.php b/application/models/Right.php index 7201dd7..8e4732d 100644 --- a/application/models/Right.php +++ b/application/models/Right.php @@ -1,139 +1,123 @@ -<?php +<? 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/ - */ +* 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_Right -{ - protected $_rightID; - protected $_rightcategoryID; - protected $_shortcut; - protected $_title; - protected $_description; +class Application_Model_Right { + protected $_rightID; + protected $_rightcategoryID; + protected $_shortcut; + protected $_title; + protected $_description; - public function __construct(array $options = null) - { - if (is_array($options)) { - $this->setOptions($options); - } - } + 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 right property'); - } - $this->$method($value); - } + public function __set($name, $value) { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid right property'); + } + $this->$method($value); + } - public function __get($name) - { - $method = 'get' . $name; - if (('mapper' == $name) || !method_exists($this, $method)) { - throw new Exception('Invalid right property'); - } - return $this->$method(); - } + public function __get($name) { + $method = 'get' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid right 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 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->_rightID; - } - public function setID($_rightID) - { - $this->_rightID = $_rightID; - return $this; - } - public function getRightcategoryID() - { - return $this->_rightcategoryID; - } - public function setRightcategoryID($_rightcategoryID) - { - $this->_rightcategoryID = $_rightcategoryID; - return $this; - } - public function getShortcut() - { - return $this->_shortcut; - } - public function setShortcut($_shortcut) - { - $this->_shortcut = $_shortcut; - 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; - } + public function getID() { + return $this->_rightID; + } + public function setID($_rightID) { + $this->_rightID = $_rightID; + return $this; + } + public function getRightcategoryID() { + return $this->_rightcategoryID; + } + public function setRightcategoryID($_rightcategoryID) { + $this->_rightcategoryID = $_rightcategoryID; + return $this; + } + public function getShortcut() { + return $this->_shortcut; + } + public function setShortcut($_shortcut) { + $this->_shortcut = $_shortcut; + 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/RightCategory.php b/application/models/RightCategory.php index fb6df23..7aeea63 100644 --- a/application/models/RightCategory.php +++ b/application/models/RightCategory.php @@ -1,104 +1,94 @@ -<?php +<? 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/ - */ +* 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_RightCategory -{ - protected $_rightcategoryID; - protected $_title; +class Application_Model_RightCategory { + protected $_rightcategoryID; + protected $_title; - public function __construct(array $options = null) - { - if (is_array($options)) { - $this->setOptions($options); - } - } + 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 rightcategory property'); - } - $this->$method($value); - } + public function __set($name, $value) { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid rightcategory property'); + } + $this->$method($value); + } - public function __get($name) - { - $method = 'get' . $name; - if (('mapper' == $name) || !method_exists($this, $method)) { - throw new Exception('Invalid rightcategory property'); - } - return $this->$method(); - } + public function __get($name) { + $method = 'get' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid rightcategory 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 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->_rightcategoryID; - } - public function setID($_rightcategoryID) - { - $this->_rightcategoryID = $_rightcategoryID; - return $this; - } - public function getTitle() - { - return $this->_title; - } - public function setTitle($_title) - { - $this->_title = $_title; - return $this; - } + public function getID() { + return $this->_rightcategoryID; + } + public function setID($_rightcategoryID) { + $this->_rightcategoryID = $_rightcategoryID; + return $this; + } + public function getTitle() { + return $this->_title; + } + public function setTitle($_title) { + $this->_title = $_title; + return $this; + } - 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 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/RightCategoryMapper.php b/application/models/RightCategoryMapper.php index 9d7f277..142d2b7 100644 --- a/application/models/RightCategoryMapper.php +++ b/application/models/RightCategoryMapper.php @@ -1,140 +1,132 @@ -<?php +<? 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_RightCategoryMapper -{ - - 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_RightCategory($row); - $entry->setID($row['rightcategoryID']); - $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_RightCategory'); - } - - return $this->_dbTable; - } - - public function save(Application_Model_RightCategory $rightCategory) - { - - $data = array('rightcategoryID'=> $rightCategory->getID() ,'title'=> $rightCategory->getTitle() ); - - if (null === ($id = $rightCategory->getID()) ) { - unset($data['rightcategoryID']); - $this->getDbTable()->insert($data); - } else { - $this->getDbTable()->update($data, array('rightcategoryID = ?' => $id)); - } - } - - public function delete(Application_Model_RightCategory $rightCategory) - { - if (null === ($id = $rightCategory->getID()) ) { - return; - } else { - $this->getDbTable()->delete(array('rightcategoryID = ?' => $id)); - } - } - - public function find($id) - { - $result = $this->getDbTable()->find($id); - if (0 == count($result)) { - return; - } - - $row = $result->current(); - - $rightCategory = new Application_Model_RightCategory(); - $rightCategory->setID($row->rightcategoryID)->setTitle($row->title); - return $rightCategory; - } - - public function fetchAll() - { - $resultSet = $this->getDbTable()->fetchAll(); - $entries = array(); - foreach ($resultSet as $row) { - $entry = new Application_Model_RightCategory(); - - $entry->setID($row->rightcategoryID)->setTitle($row->title); - $entries[] = $entry; - } - return $entries; - } - - public function compare(Application_Model_RightCategory $v1,Application_Model_RightCategory $v2){ - $vv1 = $v1->toArray(); - $vv2 = $v2->toArray(); - return array_diff($vv1,$vv2); - } +* 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_RightCategoryMapper { + + 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_RightCategory($row); + $entry->setID($row['rightcategoryID']); + $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_RightCategory'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_RightCategory $rightCategory) { + + $data = array('rightcategoryID' => $rightCategory->getID() , 'title' => $rightCategory->getTitle() ); + + if (null == = ($id = $rightCategory->getID()) ) { + unset($data['rightcategoryID']); + $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('rightcategoryID = ?' => $id)); + } + } + + public function delete(Application_Model_RightCategory $rightCategory) { + if (null == = ($id = $rightCategory->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('rightcategoryID = ?' => $id)); + } + } + + public function find($id) { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + $rightCategory = new Application_Model_RightCategory(); + $rightCategory->setID($row->rightcategoryID)->setTitle($row->title); + return $rightCategory; + } + + public function fetchAll() { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_RightCategory(); + + $entry->setID($row->rightcategoryID)->setTitle($row->title); + $entries[] = $entry; + } + return $entries; + } + + public function compare(Application_Model_RightCategory $v1, Application_Model_RightCategory $v2) { + $vv1 = $v1->toArray(); + $vv2 = $v2->toArray(); + return array_diff($vv1, $vv2); + } } diff --git a/application/models/RightMapper.php b/application/models/RightMapper.php index 4b742a2..4fd56a5 100644 --- a/application/models/RightMapper.php +++ b/application/models/RightMapper.php @@ -1,155 +1,147 @@ -<?php +<? 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_RightMapper -{ - - 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_Right($row); - $entry->setID($row['rightID']); - $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_Right'); - } - - return $this->_dbTable; - } - - public function save(Application_Model_Right $right) - { - - $data = array('rightID'=> $right->getID(), - 'rightcategoryID'=> $right->getRightcategoryID(), - 'shortcut'=>$right->getShortcut(), - 'title'=> $right->getTitle() , - 'description'=> $right->getDescription() ); - - if (null === ($id = $right->getID()) ) { - unset($data['rightID']); - $this->getDbTable()->insert($data); - } else { - $this->getDbTable()->update($data, array('rightID = ?' => $id)); - } - } - - public function delete(Application_Model_Right $right) - { - if (null === ($id = $right->getID()) ) { - return; - } else { - $this->getDbTable()->delete(array('rightID = ?' => $id)); - } - } - - public function find($id) - { - $result = $this->getDbTable()->find($id); - if (0 == count($result)) { - return; - } - - $row = $result->current(); - - $right = new Application_Model_Right(); - $right->setID($row->rightID) - ->setRightcategoryID($row->rightcategoryID) - ->setShortcut($row->shortcut) - ->setTitle($row->title) - ->setDescription($row->description); - return $right; - } - - public function fetchAll() - { - $resultSet = $this->getDbTable()->fetchAll(); - $entries = array(); - foreach ($resultSet as $row) { - $entry = new Application_Model_Right(); - - $entry->setID($row->rightID) - ->setRightcategoryID($row->rightcategoryID) - ->setShortcut($row->shortcut) - ->setTitle($row->title) - ->setDescription($row->description); - - $entries[] = $entry; - } - return $entries; - } - - public function compare(Application_Model_Right $v1,Application_Model_Right $v2){ - $vv1 = $v1->toArray(); - $vv2 = $v2->toArray(); - return array_diff($vv1,$vv2); - } - - - +* 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_RightMapper { + + 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_Right($row); + $entry->setID($row['rightID']); + $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_Right'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_Right $right) { + + $data = array('rightID' => $right->getID(), + 'rightcategoryID' => $right->getRightcategoryID(), + 'shortcut' => $right->getShortcut(), + 'title' => $right->getTitle() , + 'description' => $right->getDescription() ); + + if (null == = ($id = $right->getID()) ) { + unset($data['rightID']); + $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('rightID = ?' => $id)); + } + } + + public function delete(Application_Model_Right $right) { + if (null == = ($id = $right->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('rightID = ?' => $id)); + } + } + + public function find($id) { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + $right = new Application_Model_Right(); + $right->setID($row->rightID) + ->setRightcategoryID($row->rightcategoryID) + ->setShortcut($row->shortcut) + ->setTitle($row->title) + ->setDescription($row->description); + return $right; + } + + public function fetchAll() { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_Right(); + + $entry->setID($row->rightID) + ->setRightcategoryID($row->rightcategoryID) + ->setShortcut($row->shortcut) + ->setTitle($row->title) + ->setDescription($row->description); + + $entries[] = $entry; + } + return $entries; + } + + public function compare(Application_Model_Right $v1, Application_Model_Right $v2) { + $vv1 = $v1->toArray(); + $vv2 = $v2->toArray(); + return array_diff($vv1, $vv2); + } + + + } diff --git a/application/models/RightRoles.php b/application/models/RightRoles.php index 3b5f816..8cfaa73 100644 --- a/application/models/RightRoles.php +++ b/application/models/RightRoles.php @@ -1,109 +1,99 @@ -<?php +<? 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/ - */ +* 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_RightRoles -{ - protected $_roleID; - protected $_rightID; +class Application_Model_RightRoles { + protected $_roleID; + protected $_rightID; - public function __construct(array $options = null) - { - if (is_array($options)) { - $this->setOptions($options); - } - } + 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 rightroles property'); - } - $this->$method($value); - } + public function __set($name, $value) { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid rightroles property'); + } + $this->$method($value); + } - public function __get($name) - { - $method = 'get' . $name; - if (('mapper' == $name) || !method_exists($this, $method)) { - throw new Exception('Invalid rightroles property'); - } - return $this->$method(); - } + public function __get($name) { + $method = 'get' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid rightroles 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 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 getRoleID() - { - return $this->_roleID; - } - public function setRoleID($_roleID) - { - $this->_roleID = $_roleID; - return $this; - } - public function getRightID() - { - return $this->_rightID; - } - public function setRightID($_rightID) - { - $this->_rightID = $_rightID; - 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(); - } - - } + public function getRoleID() { + return $this->_roleID; + } + public function setRoleID($_roleID) { + $this->_roleID = $_roleID; + return $this; + } + public function getRightID() { + return $this->_rightID; + } + public function setRightID($_rightID) { + $this->_rightID = $_rightID; + 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; + + } } + return $result; + } } diff --git a/application/models/RightRolesMapper.php b/application/models/RightRolesMapper.php index a7e8c89..8688277 100644 --- a/application/models/RightRolesMapper.php +++ b/application/models/RightRolesMapper.php @@ -1,138 +1,130 @@ -<?php +<? 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_RightRolesMapper -{ - - 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_RightRoles($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_RightRoles'); - } - - return $this->_dbTable; - } - - public function save(Application_Model_RightRoles $rightroles) - { - $data = array('roleID'=> $rightroles->getRoleID() ,'rightID'=> $rightroles->getRightID() ); - - if (null === $rightroles->getRoleID() || null === $rightroles->getRightID()) { - return; - } else { - $this->getDbTable()->insert($data); - } - } - - public function delete(Application_Model_RightRoles $rightroles) - { - if (null === ($roleID = $rightroles->getRoleID()) || null === ($rightID = $rightroles->getRightID())) { - return; - } else { - $this->getDbTable()->delete(array('roleID = ?' => $roleID, 'rightID = ?' => $rightID)); - } - } - - public function find($roleID, $rightID) - { - $result = $this->getDbTable()->find($roleID, $rightID); - if (0 == count($result)) { - return; - } - - $row = $result->current(); - - $rightroles = new Application_Model_RightRoles(); - $rightroles->setRoleID($row->roleID)->setRightID($row->rightID); - return $rightroles; - } - - public function fetchAll() - { - $resultSet = $this->getDbTable()->fetchAll(); - $entries = array(); - foreach ($resultSet as $row) { - $entry = new Application_Model_RightRoles(); - - $entry->setRoleID($row->roleID)->setRightID($row->rightID); - - $entries[] = $entry; - } - return $entries; - } - - public function compare(Application_Model_RightRoles $v1,Application_Model_RightRoles $v2){ - $vv1 = $v1->toArray(); - $vv2 = $v2->toArray(); - return array_diff($vv1,$vv2); - } +* 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_RightRolesMapper { + + 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_RightRoles($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_RightRoles'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_RightRoles $rightroles) { + $data = array('roleID' => $rightroles->getRoleID() , 'rightID' => $rightroles->getRightID() ); + + if (null == = $rightroles->getRoleID() || null == = $rightroles->getRightID()) { + return; + } else { + $this->getDbTable()->insert($data); + } + } + + public function delete(Application_Model_RightRoles $rightroles) { + if (null == = ($roleID = $rightroles->getRoleID()) || null == = ($rightID = $rightroles->getRightID())) { + return; + } else { + $this->getDbTable()->delete(array('roleID = ?' => $roleID, 'rightID = ?' => $rightID)); + } + } + + public function find($roleID, $rightID) { + $result = $this->getDbTable()->find($roleID, $rightID); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + $rightroles = new Application_Model_RightRoles(); + $rightroles->setRoleID($row->roleID)->setRightID($row->rightID); + return $rightroles; + } + + public function fetchAll() { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_RightRoles(); + + $entry->setRoleID($row->roleID)->setRightID($row->rightID); + + $entries[] = $entry; + } + return $entries; + } + + public function compare(Application_Model_RightRoles $v1, Application_Model_RightRoles $v2) { + $vv1 = $v1->toArray(); + $vv2 = $v2->toArray(); + return array_diff($vv1, $vv2); + } diff --git a/application/models/Role.php b/application/models/Role.php index 3d03d53..b8146d5 100644 --- a/application/models/Role.php +++ b/application/models/Role.php @@ -1,139 +1,123 @@ -<?php +<? 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/ - */ +* 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_Role -{ - protected $_roleID; - protected $_groupID; - protected $_title; - protected $_description; - protected $_inheritance; +class Application_Model_Role { + protected $_roleID; + protected $_groupID; + protected $_title; + protected $_description; + protected $_inheritance; - public function __construct(array $options = null) - { - if (is_array($options)) { - $this->setOptions($options); - } - } + 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 role property'); - } - $this->$method($value); - } + public function __set($name, $value) { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid role property'); + } + $this->$method($value); + } - public function __get($name) - { - $method = 'get' . $name; - if (('mapper' == $name) || !method_exists($this, $method)) { - throw new Exception('Invalid role property'); - } - return $this->$method(); - } + public function __get($name) { + $method = 'get' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid role 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 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->_roleID; - } - public function setID($_roleID) - { - $this->_roleID = $_roleID; - 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 getInheritance() - { - return $this->_inheritance; - } - public function setInheritance($_inheritance) - { - $this->_inheritance = $_inheritance; - 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->_roleID; + } + public function setID($_roleID) { + $this->_roleID = $_roleID; + 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 getInheritance() { + return $this->_inheritance; + } + public function setInheritance($_inheritance) { + $this->_inheritance = $_inheritance; + 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/RoleMapper.php b/application/models/RoleMapper.php index 88ac208..61ad1c4 100644 --- a/application/models/RoleMapper.php +++ b/application/models/RoleMapper.php @@ -1,142 +1,134 @@ -<?php +<? 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_RoleMapper -{ - - 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_Role($row); - $entry->setID($row['roleID']); - $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_Role'); - } - - return $this->_dbTable; - } - - public function save(Application_Model_Role $role) - { - - $data = array('roleID'=> $role->getID() ,'groupID'=> $role->getGroupID() ,'title'=> $role->getTitle() ,'description'=> $role->getDescription(), 'inheritance' => $role->getInheritance() ); - - if (null === ($id = $role->getID()) ) { - unset($data['roleID']); - $this->getDbTable()->insert($data); - } else { - $this->getDbTable()->update($data, array('roleID = ?' => $id)); - } - } - - public function delete(Application_Model_Role $role) - { - if (null === ($id = $role->getID()) ) { - return; - } else { - $this->getDbTable()->delete(array('roleID = ?' => $id)); - } - } - - public function find($id) - { - $result = $this->getDbTable()->find($id); - if (0 == count($result)) { - return; - } - - $row = $result->current(); - $role = new Application_Model_Role(); - $role->setID($row->roleID)->setGroupID($row->groupID)->setTitle($row->title)->setDescription($row->description)->setInheritance($row->inheritance); - return $role; - } - - public function fetchAll() - { - $resultSet = $this->getDbTable()->fetchAll(); - $entries = array(); - foreach ($resultSet as $row) { - $entry = new Application_Model_Role(); - - $entry->setID($row->roleID)->setGroupID($row->groupID)->setTitle($row->title)->setDescription($row->description)->setInheritance($row->inheritance); - - $entries[] = $entry; - } - return $entries; - } - - public function compare(Application_Model_Role $v1,Application_Model_Role $v2){ - $vv1 = $v1->toArray(); - $vv2 = $v2->toArray(); - return array_diff($vv1,$vv2); - } - - - +* 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_RoleMapper { + + 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_Role($row); + $entry->setID($row['roleID']); + $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_Role'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_Role $role) { + + $data = array('roleID' => $role->getID() , 'groupID' => $role->getGroupID() , 'title' => $role->getTitle() , 'description' => $role->getDescription(), 'inheritance' => $role->getInheritance() ); + + if (null == = ($id = $role->getID()) ) { + unset($data['roleID']); + $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('roleID = ?' => $id)); + } + } + + public function delete(Application_Model_Role $role) { + if (null == = ($id = $role->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('roleID = ?' => $id)); + } + } + + public function find($id) { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + $role = new Application_Model_Role(); + $role->setID($row->roleID)->setGroupID($row->groupID)->setTitle($row->title)->setDescription($row->description)->setInheritance($row->inheritance); + return $role; + } + + public function fetchAll() { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_Role(); + + $entry->setID($row->roleID)->setGroupID($row->groupID)->setTitle($row->title)->setDescription($row->description)->setInheritance($row->inheritance); + + $entries[] = $entry; + } + return $entries; + } + + public function compare(Application_Model_Role $v1, Application_Model_Role $v2) { + $vv1 = $v1->toArray(); + $vv2 = $v2->toArray(); + return array_diff($vv1, $vv2); + } + + + } diff --git a/application/models/Session.php b/application/models/Session.php index fa9979a..2d794d2 100644 --- a/application/models/Session.php +++ b/application/models/Session.php @@ -1,199 +1,171 @@ -<?php +<? 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/ - */ +* 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_Session -{ - protected $_sessionID; - protected $_alphasessionID; - protected $_clientID; - protected $_bootmenuentryID; - protected $_bootosID; - protected $_bootisoID; - protected $_membershipID; - protected $_personID; - protected $_time; - protected $_ip; - protected $_ip6; +class Application_Model_Session { + protected $_sessionID; + protected $_alphasessionID; + protected $_clientID; + protected $_bootmenuentryID; + protected $_bootosID; + protected $_bootisoID; + protected $_membershipID; + protected $_personID; + protected $_time; + protected $_ip; + protected $_ip6; - public function __construct(array $options = null) - { - if (is_array($options)) { - $this->setOptions($options); - } - } + 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 session property'); - } - $this->$method($value); - } + public function __set($name, $value) { + $method = 'set' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid session property'); + } + $this->$method($value); + } - public function __get($name) - { - $method = 'get' . $name; - if (('mapper' == $name) || !method_exists($this, $method)) { - throw new Exception('Invalid session property'); - } - return $this->$method(); - } + public function __get($name) { + $method = 'get' . $name; + if (('mapper' == $name) || !method_exists($this, $method)) { + throw new Exception('Invalid session 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 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->_sessionID; - } - public function setID($_sessionID) - { - $this->_sessionID = $_sessionID; - return $this; - } - public function getAlphasessionID() - { - return $this->_alphasessionID; - } - public function setAlphasessionID($_alphasessionID) - { - $this->_alphasessionID = $_alphasessionID; - return $this; - } - public function getClientID() - { - return $this->_clientID; - } - public function setClientID($_clientID) - { - $this->_clientID = $_clientID; - return $this; - } - public function getBootmenuentryID() - { - return $this->_bootmenuentryID; - } - public function setBootmenuentryID($_bootmenuentryID) - { - $this->_bootmenuentryID = $_bootmenuentryID; - return $this; - } - public function getBootosID() - { - return $this->_bootosID; - } - public function setBootosID($_bootosID) - { - $this->_bootosID = $_bootosID; - return $this; - } - public function getBootisoID() - { - return $this->_bootisoID; - } - public function setBootisoID($_bootisoID) - { - $this->_bootisoID = $_bootisoID; - return $this; - } - public function getMembershipID() - { - return $this->_membershipID; - } - public function setMembershipID($_membershipID) - { - $this->_membershipID = $_membershipID; - return $this; - } - public function getPersonID() - { - return $this->_personID; - } - public function setPersonID($_personID) - { - $this->_personID = $_personID; - return $this; - } - public function getTime() - { - return $this->_time; - } - public function setTime($_time) - { - $this->_time = $_time; - return $this; - } - public function getIp() - { - return $this->_ip; - } - public function setIp($_ip) - { - $this->_ip = $_ip; - return $this; - } - public function getIp6() - { - return $this->_ip6; - } - public function setIp6($_ip6) - { - $this->_ip6 = $_ip6; - 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(); - } - - } + public function getID() { + return $this->_sessionID; + } + public function setID($_sessionID) { + $this->_sessionID = $_sessionID; + return $this; + } + public function getAlphasessionID() { + return $this->_alphasessionID; + } + public function setAlphasessionID($_alphasessionID) { + $this->_alphasessionID = $_alphasessionID; + return $this; + } + public function getClientID() { + return $this->_clientID; + } + public function setClientID($_clientID) { + $this->_clientID = $_clientID; + return $this; + } + public function getBootmenuentryID() { + return $this->_bootmenuentryID; + } + public function setBootmenuentryID($_bootmenuentryID) { + $this->_bootmenuentryID = $_bootmenuentryID; + return $this; + } + public function getBootosID() { + return $this->_bootosID; + } + public function setBootosID($_bootosID) { + $this->_bootosID = $_bootosID; + return $this; + } + public function getBootisoID() { + return $this->_bootisoID; + } + public function setBootisoID($_bootisoID) { + $this->_bootisoID = $_bootisoID; + return $this; + } + public function getMembershipID() { + return $this->_membershipID; + } + public function setMembershipID($_membershipID) { + $this->_membershipID = $_membershipID; + return $this; + } + public function getPersonID() { + return $this->_personID; + } + public function setPersonID($_personID) { + $this->_personID = $_personID; + return $this; + } + public function getTime() { + return $this->_time; + } + public function setTime($_time) { + $this->_time = $_time; + return $this; + } + public function getIp() { + return $this->_ip; + } + public function setIp($_ip) { + $this->_ip = $_ip; + return $this; + } + public function getIp6() { + return $this->_ip6; + } + public function setIp6($_ip6) { + $this->_ip6 = $_ip6; + 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; + + } } + return $result; + } } diff --git a/application/models/SessionMapper.php b/application/models/SessionMapper.php index 3b35ccb..3304798 100644 --- a/application/models/SessionMapper.php +++ b/application/models/SessionMapper.php @@ -1,169 +1,161 @@ -<?php +<? 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_SessionMapper -{ - - 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_Session($row); - $entry->setID($row['sessionID']); - $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_Session'); - } - - return $this->_dbTable; - } - - public function save(Application_Model_Session $session) - { - $data = array( 'sessionID'=> $session->getID() , - 'alphasessionID'=> $session->getAlphasessionID(), - 'clientID'=> $session->getClientID() , - 'bootmenuentryID'=> $session->getBootmenuentryID(), - 'bootosID'=> $session->getBootosID() , - 'bootisoID'=> $session->getBootisoID() , - 'membershipID'=> $session->getMembershipID() , - 'personID'=> $session->getPersonID() , - 'time'=> $session->getTime() , - 'ip'=> $session->getIp() , - 'ip6'=> $session->getIp6() ); - if (null === ($id = $session->getID()) ) { - unset($data['sessionID']); - return $this->getDbTable()->insert($data); - } else { - $this->getDbTable()->update($data, array('sessionID = ?' => $id)); - } - } - - public function delete(Application_Model_Session $sesion) - { - if (null === ($id = $sesion->getID()) ) { - return; - } else { - $this->getDbTable()->delete(array('sessionID = ?' => $id)); - } - } - - public function find($id, Application_Model_Session $sesion) - { - $result = $this->getDbTable()->find($id); - if (0 == count($result)) { - return; - } - - $row = $result->current(); - - $sesion->setID($row->sessionID) - ->setAlphasessionID($row->alphasessionID) - ->setClientID($row->clientID) - ->setBootmenuentryID($row->bootmenuentryID) - ->setBootosID($row->bootosID) - ->setBootisoID($row->bootisoID) - ->setMembershipID($row->membershipID) - ->setPersonID($row->personID) - ->setTime($row->time) - ->setIp($row->ip) - ->setIp6($row->ip6); - } - - public function fetchAll() - { - $resultSet = $this->getDbTable()->fetchAll(); - $entries = array(); - foreach ($resultSet as $row) { - $entry = new Application_Model_Session(); - - $entry->setID($row->sessionID) - ->setAlphasessionID($row->alphasessionID) - ->setClientID($row->clientID) - ->setBootmenuentryID($row->bootmenuentryID) - ->setBootosID($row->bootosID) - ->setBootisoID($row->bootisoID) - ->setMembershipID($row->membershipID) - ->setPersonID($row->personID) - ->setTime($row->time) - ->setIp($row->ip) - ->setIp6($row->ip6); - - $entries[] = $entry; - } - return $entries; - } - - public function compare(Application_Model_Session $v1,Application_Model_Session $v2){ - $vv1 = $v1->toArray(); - $vv2 = $v2->toArray(); - return array_diff($vv1,$vv2); - } - - - +* 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_SessionMapper { + + 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_Session($row); + $entry->setID($row['sessionID']); + $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_Session'); + } + + return $this->_dbTable; + } + + public function save(Application_Model_Session $session) { + $data = array( 'sessionID' => $session->getID() , + 'alphasessionID' => $session->getAlphasessionID(), + 'clientID' => $session->getClientID() , + 'bootmenuentryID' => $session->getBootmenuentryID(), + 'bootosID' => $session->getBootosID() , + 'bootisoID' => $session->getBootisoID() , + 'membershipID' => $session->getMembershipID() , + 'personID' => $session->getPersonID() , + 'time' => $session->getTime() , + 'ip' => $session->getIp() , + 'ip6' => $session->getIp6() ); + if (null == = ($id = $session->getID()) ) { + unset($data['sessionID']); + return $this->getDbTable()->insert($data); + } else { + $this->getDbTable()->update($data, array('sessionID = ?' => $id)); + } + } + + public function delete(Application_Model_Session $sesion) { + if (null == = ($id = $sesion->getID()) ) { + return; + } else { + $this->getDbTable()->delete(array('sessionID = ?' => $id)); + } + } + + public function find($id, Application_Model_Session $sesion) { + $result = $this->getDbTable()->find($id); + if (0 == count($result)) { + return; + } + + $row = $result->current(); + + $sesion->setID($row->sessionID) + ->setAlphasessionID($row->alphasessionID) + ->setClientID($row->clientID) + ->setBootmenuentryID($row->bootmenuentryID) + ->setBootosID($row->bootosID) + ->setBootisoID($row->bootisoID) + ->setMembershipID($row->membershipID) + ->setPersonID($row->personID) + ->setTime($row->time) + ->setIp($row->ip) + ->setIp6($row->ip6); + } + + public function fetchAll() { + $resultSet = $this->getDbTable()->fetchAll(); + $entries = array(); + foreach ($resultSet as $row) { + $entry = new Application_Model_Session(); + + $entry->setID($row->sessionID) + ->setAlphasessionID($row->alphasessionID) + ->setClientID($row->clientID) + ->setBootmenuentryID($row->bootmenuentryID) + ->setBootosID($row->bootosID) + ->setBootisoID($row->bootisoID) + ->setMembershipID($row->membershipID) + ->setPersonID($row->personID) + ->setTime($row->time) + ->setIp($row->ip) + ->setIp6($row->ip6); + + $entries[] = $entry; + } + return $entries; + } + + public function compare(Application_Model_Session $v1, Application_Model_Session $v2) { + $vv1 = $v1->toArray(); + $vv2 = $v2->toArray(); + return array_diff($vv1, $vv2); + } + + + } |