diff options
| author | Simon | 2011-04-07 15:38:28 +0200 |
|---|---|---|
| committer | Simon | 2011-04-07 15:38:28 +0200 |
| commit | 2bcd3d5462b0be70cb5edc0abe1d310081fffca8 (patch) | |
| tree | c32144ca753204b16aa60daa285e792d00c13f6f | |
| parent | kleine design-anpassungen (diff) | |
| download | pbs2-2bcd3d5462b0be70cb5edc0abe1d310081fffca8.tar.gz pbs2-2bcd3d5462b0be70cb5edc0abe1d310081fffca8.tar.xz pbs2-2bcd3d5462b0be70cb5edc0abe1d310081fffca8.zip | |
ACL beschleunigt, nur 2 SQL Abfragen, keine Schleife und Cache implementiert
| -rw-r--r-- | library/Pbs/Acl.php | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/library/Pbs/Acl.php b/library/Pbs/Acl.php index f3ed08e..798c5e5 100644 --- a/library/Pbs/Acl.php +++ b/library/Pbs/Acl.php @@ -2,18 +2,25 @@ class Pbs_Acl { + protected $cache; public static function checkRight($rightShortcut) { $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); $roleID = $userIDsNamespace['roleID']; - $rightRolesMapper = new Application_Model_RightRolesMapper(); - $rightroles = $rightRolesMapper->findBy(array('roleID' => $roleID),true); + if(isset($this->cache[$roleID][$rightShortcut])) + return $this->cache[$roleID][$rightShortcut]; + $rightMapper = new Application_Model_RightMapper(); - foreach($rightroles as $rightrole) { - $right = $rightMapper->find($rightrole['rightID']); - if($right->getShortcut() == $rightShortcut) { - return true; - } + $element = $rightMapper->findBy(array('shortcut',$rightshortcut)); + if($element == null) + return false; + + $rightRolesMapper = new Application_Model_RightRolesMapper(); + $rightroles = $rightRolesMapper->findBy(array('roleID' => $roleID,'rightID',$element->getID())); + if(count($rightroles) >=1){ + $this->cache[$roleID][$rightShortcut] = true; + return true; } + $this->cache[$roleID][$rightShortcut] = false; return false; } |
