X-Git-Url: https://scm.cri.minesparis.psl.eu/git/Plinn.git/blobdiff_plain/c7fa7959f1718394c772a187bb124780f86fa2f3..077c4d9810b96d4b949e77f3daa0180c9d4a8c96:/utils.py

diff --git a/utils.py b/utils.py
index 6b3b697..de68f22 100755
--- a/utils.py
+++ b/utils.py
@@ -319,4 +319,20 @@ def _sudo(func, userid=None) :
         raise e
 
     return ret
-    
\ No newline at end of file
+
+security.declarePublic('searchContentsWithLocalRolesForAuthenticatedUser')
+def searchContentsWithLocalRolesForAuthenticatedUser(**kw):
+    mtool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+    ctool = getUtilityByInterfaceName('Products.CMFCore.interfaces.ICatalogTool')
+    member = mtool.getAuthenticatedMember()
+    userid = member.getId()
+    userAndGroups = ['user:%s' % userid]
+    
+    getGroups = getattr(member, 'getGroups', None)
+    if getGroups is not None :
+        for group in getGroups():
+            userAndGroups.append('user:'+group)
+    
+    kw[ 'allowedRolesAndUsers' ] = userAndGroups
+    
+    return ctool.unrestrictedSearchResults(**kw)