Commit 12d89cad authored by 's avatar

- fixed some permission checks

parent 88ea35a7
...@@ -17,6 +17,7 @@ from AccessControl.Permissions import access_contents_information ...@@ -17,6 +17,7 @@ from AccessControl.Permissions import access_contents_information
from AccessControl.Permissions import add_documents_images_and_files from AccessControl.Permissions import add_documents_images_and_files
from AccessControl.Permissions import view as View from AccessControl.Permissions import view as View
from AccessControl.SecurityInfo import ClassSecurityInfo from AccessControl.SecurityInfo import ClassSecurityInfo
from AccessControl.SecurityManagement import getSecurityManager
from Acquisition import Implicit from Acquisition import Implicit
from App.special_dtml import DTMLFile from App.special_dtml import DTMLFile
from App.special_dtml import HTML from App.special_dtml import HTML
...@@ -24,12 +25,12 @@ from OFS.ObjectManager import ObjectManager ...@@ -24,12 +25,12 @@ from OFS.ObjectManager import ObjectManager
from OFS.SimpleItem import Item from OFS.SimpleItem import Item
from Persistence import Persistent from Persistence import Persistent
from Products.PluginIndexes.KeywordIndex.KeywordIndex import KeywordIndex from Products.PluginIndexes.KeywordIndex.KeywordIndex import KeywordIndex
from Products.ZCatalog.ZCatalog import ZCatalog
from Products.ZCatalog.Lazy import LazyCat from Products.ZCatalog.Lazy import LazyCat
from Products.ZCTextIndex.OkapiIndex import OkapiIndex from Products.ZCatalog.ZCatalog import ZCatalog
from Products.ZCTextIndex.Lexicon import CaseNormalizer
from Products.ZCTextIndex.HTMLSplitter import HTMLWordSplitter from Products.ZCTextIndex.HTMLSplitter import HTMLWordSplitter
from Products.ZCTextIndex.Lexicon import CaseNormalizer
from Products.ZCTextIndex.Lexicon import StopWordRemover from Products.ZCTextIndex.Lexicon import StopWordRemover
from Products.ZCTextIndex.OkapiIndex import OkapiIndex
from Products.ZCTextIndex.ZCTextIndex import PLexicon from Products.ZCTextIndex.ZCTextIndex import PLexicon
from Products.ZCTextIndex.ZCTextIndex import ZCTextIndex from Products.ZCTextIndex.ZCTextIndex import ZCTextIndex
...@@ -72,13 +73,13 @@ class HelpSys(Implicit, ObjectManager, Item, Persistent): ...@@ -72,13 +73,13 @@ class HelpSys(Implicit, ObjectManager, Item, Persistent):
def __call__(self, REQUEST=None, **kw): def __call__(self, REQUEST=None, **kw):
"Searchable interface" "Searchable interface"
if REQUEST is not None: if REQUEST is not None:
perms=[] perms = []
user=REQUEST.AUTHENTICATED_USER sm = getSecurityManager()
for p in self.ac_inherited_permissions(): for p in self.ac_inherited_permissions(all=True):
if user.has_permission(p[0], self): if sm.checkPermission(p[0], self):
perms.append(p[0]) perms.append(p[0])
REQUEST.set('permissions',perms) REQUEST.set('permissions', perms)
results=[] results = []
for ph in self.helpValues(): for ph in self.helpValues():
results.append(apply(getattr(ph, '__call__'), (REQUEST,) , kw)) results.append(apply(getattr(ph, '__call__'), (REQUEST,) , kw))
return LazyCat(results) return LazyCat(results)
...@@ -268,11 +269,9 @@ class ProductHelp(Implicit, ObjectManager, Item, Persistent): ...@@ -268,11 +269,9 @@ class ProductHelp(Implicit, ObjectManager, Item, Persistent):
Help Topics for which the user is not authorized Help Topics for which the user is not authorized
are not listed. are not listed.
""" """
topics=self.objectValues('Help Topic') topics = self.objectValues('Help Topic')
if REQUEST is None: sm = getSecurityManager()
return topics return [ t for t in topics if t.authorized(sm) ]
return filter(
lambda ht, u=REQUEST.AUTHENTICATED_USER: ht.authorized(u), topics)
def tpValues(self): def tpValues(self):
""" """
......
...@@ -58,14 +58,11 @@ class HelpTopicBase: ...@@ -58,14 +58,11 @@ class HelpTopicBase:
def helpValues(self, REQUEST=None): def helpValues(self, REQUEST=None):
return () return ()
def authorized(self, user): def authorized(self, sm):
"Is a given user authorized to view this Help Topic?" "Is a given user authorized to view this Help Topic?"
if not self.permissions: if not self.permissions:
return 1 return True
for perm in self.permissions: return any( sm.checkPermission(p, self) for p in self.permissions )
if user.has_permission(perm, self):
return 1
return 0
# Indexable methods # Indexable methods
# ----------------- # -----------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment