return 0
def getCPInfo(self) :
- try: cp = _cb_decode(self.REQUEST['__cp'])
+ if self.REQUEST.RESPONSE.cookies.has_key('__cp') :
+ cp = self.REQUEST.RESPONSE.cookies['__cp']['value']
+ else :
+ cp = self.REQUEST.get('__cp')
+ try: cp = _cb_decode(cp)
except: return None
return cp
security.declarePublic('getBestTranslationLanguage')
def getBestTranslationLanguage(langs, context):
""" returns best translation language according
- availables languages (param langs)
+ to available languages (param langs)
and user preferences (retrieves by context)
"""
request = getattr(context, 'REQUEST', None)
else :
return default
+security.declarePublic('encodeQuopriEmail')
def encodeQuopriEmail(name, email) :
qpName = encodestring(name).replace('=\n', '')
return '''"=?utf-8?q?%s?=" <%s>''' % (qpName, email)
+security.declarePublic('encodeMailHeader')
def encodeMailHeader(content) :
s = encodestring(content).replace('=\n', '')
s = s.replace('_', '=5F')
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)