summaryrefslogtreecommitdiffstats
path: root/application/models
diff options
context:
space:
mode:
authorBjörn Geiger2011-03-23 19:31:03 +0100
committerBjörn Geiger2011-03-23 19:31:03 +0100
commitf581446f90526dd3466becddd625d23bd1c26ed4 (patch)
tree22b5708100e6c71e7cbd3a567527dcfc013fca91 /application/models
parentseriel liegt jetzt im root/ (diff)
downloadpbs2-f581446f90526dd3466becddd625d23bd1c26ed4.tar.gz
pbs2-f581446f90526dd3466becddd625d23bd1c26ed4.tar.xz
pbs2-f581446f90526dd3466becddd625d23bd1c26ed4.zip
Rollenverwaltung in Dev Modul
Diffstat (limited to 'application/models')
-rw-r--r--application/models/DbTable/RightRoles.php1
-rw-r--r--application/models/RightMapper.php4
-rw-r--r--application/models/RightRolesMapper.php52
-rw-r--r--application/models/RoleMapper.php5
-rw-r--r--application/models/RolesMapper.php98
5 files changed, 32 insertions, 128 deletions
diff --git a/application/models/DbTable/RightRoles.php b/application/models/DbTable/RightRoles.php
index ebf1738..070a650 100644
--- a/application/models/DbTable/RightRoles.php
+++ b/application/models/DbTable/RightRoles.php
@@ -5,6 +5,5 @@ class Application_Model_DbTable_RightRoles extends Zend_Db_Table_Abstract
protected $_name = 'pbs_rightroles';
-
}
diff --git a/application/models/RightMapper.php b/application/models/RightMapper.php
index 570259a..9905f92 100644
--- a/application/models/RightMapper.php
+++ b/application/models/RightMapper.php
@@ -66,7 +66,7 @@ class Application_Model_RightMapper
}
}
- public function find($id, Application_Model_Right $right)
+ public function find($id)
{
$result = $this->getDbTable()->find($id);
if (0 == count($result)) {
@@ -75,7 +75,9 @@ class Application_Model_RightMapper
$row = $result->current();
+ $right = new Application_Model_Right();
$right->setID($row->rightID)->setTitle($row->title)->setDescription($row->description);
+ return $right;
}
public function fetchAll()
diff --git a/application/models/RightRolesMapper.php b/application/models/RightRolesMapper.php
index e2adff5..d6610f5 100644
--- a/application/models/RightRolesMapper.php
+++ b/application/models/RightRolesMapper.php
@@ -2,23 +2,23 @@
class Application_Model_RightRolesMapper
{
-
+
protected $_dbTable;
- public function findBy($criteria, $value)
- {
- try{
+ public function findBy($criteria, $value)
+ {
+ try{
$db = Zend_Db_Table::getDefaultAdapter();
- $select = $this->getDbTable()->select()
- ->from($this->_dbTable)
- ->where($criteria . ' = ?', $value);
+ $select = $this->getDbTable()->select()
+ ->from($this->_dbTable)
+ ->where($criteria . ' = ?', $value);
$stmt = $select->query();
$result = $stmt->fetchAll();
return $result;
- }catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
}
- }
+ }
public function setDbTable($dbTable)
{
@@ -31,7 +31,7 @@ class Application_Model_RightRolesMapper
}
$this->_dbTable = $dbTable;
-
+
return $this;
}
@@ -40,42 +40,42 @@ class Application_Model_RightRolesMapper
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 === ($id = $rightroles->getID()) ) {
- unset($data['rightrolesID']);
- $this->getDbTable()->insert($data);
+ if (null === $rightroles->getRoleID() || null === $rightroles->getRightID()) {
+ return;
} else {
- $this->getDbTable()->update($data, array('rightrolesID = ?' => $id));
+ $this->getDbTable()->insert($data);
}
}
-
+
public function delete(Application_Model_RightRoles $rightroles)
{
- if (null === ($id = $rightroles->getID()) ) {
+ if (null === ($roleID = $rightroles->getRoleID()) || null === ($rightID = $rightroles->getRightID())) {
return;
} else {
- $this->getDbTable()->delete(array('rightrolesID = ?' => $id));
+ $this->getDbTable()->delete(array('roleID = ?' => $roleID, 'rightID = ?' => $roleID));
}
}
- public function find($id, Application_Model_RightRoles $rightroles)
+ public function find($roleID, $rightID)
{
- $result = $this->getDbTable()->find($id);
+ $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()
@@ -84,8 +84,8 @@ class Application_Model_RightRolesMapper
$entries = array();
foreach ($resultSet as $row) {
$entry = new Application_Model_RightRoles();
-
- $entry->setRoleID($row->roleID)->setRightID($row->rightID);
+
+ $entry->setRoleID($row->roleID)->setRightID($row->rightID);
$entries[] = $entry;
}
@@ -93,6 +93,6 @@ class Application_Model_RightRolesMapper
}
-
+
}
diff --git a/application/models/RoleMapper.php b/application/models/RoleMapper.php
index bc9bc48..4b8b832 100644
--- a/application/models/RoleMapper.php
+++ b/application/models/RoleMapper.php
@@ -66,7 +66,7 @@ class Application_Model_RoleMapper
}
}
- public function find($id, Application_Model_Role $role)
+ public function find($id)
{
$result = $this->getDbTable()->find($id);
if (0 == count($result)) {
@@ -74,8 +74,9 @@ class Application_Model_RoleMapper
}
$row = $result->current();
-
+ $role = new Application_Model_Role();
$role->setID($row->roleID)->setGroupID($row->groupID)->setTitle($row->title)->setDescription($row->description);
+ return $role;
}
public function fetchAll()
diff --git a/application/models/RolesMapper.php b/application/models/RolesMapper.php
deleted file mode 100644
index d48d747..0000000
--- a/application/models/RolesMapper.php
+++ /dev/null
@@ -1,98 +0,0 @@
-<?php
-
-class Application_Model_RolesMapper
-{
-
- protected $_dbTable;
-
- public function findBy($criteria, $value)
- {
- try{
- $db = Zend_Db_Table::getDefaultAdapter();
- $select = $this->getDbTable()->select()
- ->from($this->_dbTable)
- ->where($criteria . ' = ?', $value);
- $stmt = $select->query();
- $result = $stmt->fetchAll();
- return $result;
- }catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
- }
- }
-
- public function setDbTable($dbTable)
- {
- if (is_string($dbTable)) {
- $dbTable = new $dbTable();
- }
-
- if (!$dbTable instanceof Zend_Db_Table_Abstract) {
- throw new Exception('Invalid table data gateway provided');
- }
-
- $this->_dbTable = $dbTable;
-
- return $this;
- }
-
- public function getDbTable()
- {
- if (null === $this->_dbTable) {
- $this->setDbTable('Application_Model_DbTable_Roles');
- }
-
- return $this->_dbTable;
- }
-
- public function save(Application_Model_Roles $roles)
- {
-
- $data = array();
-
- if (null === ($id = $roles->getID()) ) {
- unset($data['rolesID']);
- $this->getDbTable()->insert($data);
- } else {
- $this->getDbTable()->update($data, array('rolesID = ?' => $id));
- }
- }
-
- public function delete(Application_Model_Roles $roles)
- {
- if (null === ($id = $roles->getID()) ) {
- return;
- } else {
- $this->getDbTable()->delete(array('rolesID = ?' => $id));
- }
- }
-
- public function find($id, Application_Model_Roles $roles)
- {
- $result = $this->getDbTable()->find($id);
- if (0 == count($result)) {
- return;
- }
-
- $row = $result->current();
-
- $roles;
- }
-
- public function fetchAll()
- {
- $resultSet = $this->getDbTable()->fetchAll();
- $entries = array();
- foreach ($resultSet as $row) {
- $entry = new Application_Model_Roles();
-
- $entry;
-
- $entries[] = $entry;
- }
- return $entries;
- }
-
-
-
-}
-