diff options
| author | Björn Geiger | 2011-03-27 16:44:55 +0200 |
|---|---|---|
| committer | Björn Geiger | 2011-03-27 16:44:55 +0200 |
| commit | aaf8275e5ff92504357c5f3167a3f256d0d393ad (patch) | |
| tree | 1b6faae50f95f7a3bc2c51c452fc33c8f867caa4 /application/models | |
| parent | Compare Methode bei allen Mappern ergänzt (diff) | |
| download | pbs2-aaf8275e5ff92504357c5f3167a3f256d0d393ad.tar.gz pbs2-aaf8275e5ff92504357c5f3167a3f256d0d393ad.tar.xz pbs2-aaf8275e5ff92504357c5f3167a3f256d0d393ad.zip | |
Rollenverwaltung User Module
Diffstat (limited to 'application/models')
| -rw-r--r-- | application/models/Acl.php | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/application/models/Acl.php b/application/models/Acl.php new file mode 100644 index 0000000..3de2ec9 --- /dev/null +++ b/application/models/Acl.php @@ -0,0 +1,71 @@ +<?php + +class Application_Model_Acl +{ + private static $roleID; + + public static function setRoleID($roleID) { + Application_Model_Acl::$roleID = $roleID; + } + + public static function getRoleID() { + return Application_Model_Acl::$roleID; + } + + public static function checkRight($rightID) { + $rightRolesMapper = new Application_Model_RightRolesMapper(); + $rightroles = $rightRolesMapper->findBy('roleID', Application_Model_Acl::$roleID); + $rightMapper = new Application_Model_RightMapper(); + foreach($rightroles as $rightrole) { + $right = $rightMapper->find($rightrole['rightID']); + if($right->getID() == $rightID) { + return true; + } + } + return false; + } + + public static function checkRightByMembershipID($membershipID, $rightID) { + $membershipMapper = new Application_Model_MembershipMapper(); + $membership = $membershipMapper->find($membershipID); + $rightRolesMapper = new Application_Model_RightRolesMapper(); + $rightroles = $rightRolesMapper->findBy('roleID', $membership->getRoleID()); + $rightMapper = new Application_Model_RightMapper(); + foreach($rightroles as $rightrole) { + $right = $rightMapper->find($rightrole['rightID']); + if($right->getID() == $rightID) { + return true; + } + } + return false; + } + + public static function checkRightTitle($rightTitle) { + $rightRolesMapper = new Application_Model_RightRolesMapper(); + $rightroles = $rightRolesMapper->findBy('roleID', Application_Model_Acl::$roleID); + $rightMapper = new Application_Model_RightMapper(); + foreach($rightroles as $rightrole) { + $right = $rightMapper->find($rightrole['rightID']); + if($right->getTitle() == $rightTitle) { + return true; + } + } + return false; + } + + public static function checkRightTitleByMembershipID($membershipID, $rightTitle) { + $membershipMapper = new Application_Model_MembershipMapper(); + $membership = $membershipMapper->find($membershipID); + $rightRolesMapper = new Application_Model_RightRolesMapper(); + $rightroles = $rightRolesMapper->findBy('roleID', $membership->getRoleID()); + $rightMapper = new Application_Model_RightMapper(); + foreach($rightroles as $rightrole) { + $right = $rightMapper->find($rightrole['rightID']); + if($right->getTitle() == $rightTitle) { + return true; + } + } + return false; + } +} + |
