summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorSimon2011-04-07 15:38:28 +0200
committerSimon2011-04-07 15:38:28 +0200
commit2bcd3d5462b0be70cb5edc0abe1d310081fffca8 (patch)
treec32144ca753204b16aa60daa285e792d00c13f6f /library
parentkleine design-anpassungen (diff)
downloadpbs2-2bcd3d5462b0be70cb5edc0abe1d310081fffca8.tar.gz
pbs2-2bcd3d5462b0be70cb5edc0abe1d310081fffca8.tar.xz
pbs2-2bcd3d5462b0be70cb5edc0abe1d310081fffca8.zip
ACL beschleunigt, nur 2 SQL Abfragen, keine Schleife und Cache implementiert
Diffstat (limited to 'library')
-rw-r--r--library/Pbs/Acl.php21
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;
}