Created
September 15, 2011 07:17
-
-
Save leihog/1218720 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git 0.11/access/macro.py 0.11/access/macro.py | |
index 7ea2e23..70ed06f 100644 | |
--- 0.11/access/macro.py | |
+++ 0.11/access/macro.py | |
@@ -11,6 +11,7 @@ import re | |
from trac.core import * | |
from trac.wiki.api import IWikiMacroProvider | |
from trac.wiki.formatter import format_to_html | |
+from trac.perm import PermissionSystem, IPermissionStore | |
class AccessMacro(Component): | |
""" | |
@@ -43,6 +44,8 @@ class AccessMacro(Component): | |
PARSE_RULE = re.compile(r'^\s*(allow|deny)\s*\(\s*([^,)]+\s*(?:,\s*[^,\)]+)*)\)(.*)', re.I) | |
SPLIT_LIST = re.compile(r'\s*,\s*') | |
+ | |
+ perm_store = ExtensionPoint(IPermissionStore) | |
# IWikiMacroProvider | |
def get_macros(self): | |
@@ -82,18 +85,27 @@ class AccessMacro(Component): | |
else: | |
raise TracError("Invalid permission specification: %s" % content) | |
+ # get user permissions and groups | |
+ user_perms = [] | |
+ for provider in self.perm_store: | |
+ foobar = provider.get_all_permissions(); | |
+ for uu in foobar: | |
+ if uu[0] == formatter.req.authname: | |
+ user_perms.append( uu[1] ) | |
+ | |
+ | |
# Check access | |
allow = None | |
if action.lower() == "allow": | |
allow = False | |
for p in permissions: | |
- if p in formatter.req.perm: | |
+ if p in user_perms: | |
allow = True | |
break | |
else: | |
allow = True | |
for p in permissions: | |
- if p in formatter.req.perm: | |
+ if p in user_perms: | |
allow = False | |
break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment