1 | from Products.CMFCore import CatalogTool |
---|
2 | from Products.CMFCore.utils import _getAuthenticatedUser |
---|
3 | from Products.ZCatalog.ZCatalog import ZCatalog |
---|
4 | # searchResults has inherited security assertions. |
---|
5 | def searchResults(self, REQUEST=None, **kw): |
---|
6 | """ |
---|
7 | Calls ZCatalog.searchResults with extra arguments that |
---|
8 | limit the results to what the user is allowed to see. |
---|
9 | """ |
---|
10 | user = _getAuthenticatedUser(self) |
---|
11 | kw[ 'allowedRolesAndUsers' ] = self._listAllowedRolesAndUsers( user ) |
---|
12 | |
---|
13 | if not _checkPermission( AccessInactivePortalContent, self ): |
---|
14 | now = DateTime() |
---|
15 | |
---|
16 | self._convertQuery(kw) |
---|
17 | |
---|
18 | # Intersect query restrictions with those implicit to the tool |
---|
19 | # for k in 'effective', 'expires': |
---|
20 | # if kw.has_key(k): |
---|
21 | # range = kw[k]['range'] or '' |
---|
22 | # query = kw[k]['query'] |
---|
23 | # if not isinstance(query, (tuple, list)): |
---|
24 | # query = (query,) |
---|
25 | # else: |
---|
26 | # range = '' |
---|
27 | # query = None |
---|
28 | # if range.find('min') > -1: |
---|
29 | # lo = min(query) |
---|
30 | # else: |
---|
31 | # lo = None |
---|
32 | # if range.find('max') > -1: |
---|
33 | # hi = max(query) |
---|
34 | # else: |
---|
35 | # hi = None |
---|
36 | # if k == 'effective': |
---|
37 | # if hi is None or hi > now: |
---|
38 | # hi = now |
---|
39 | # if lo is not None and hi < lo: |
---|
40 | # return () |
---|
41 | # else: # 'expires': |
---|
42 | # if lo is None or lo < now: |
---|
43 | # lo = now |
---|
44 | # if hi is not None and hi < lo: |
---|
45 | # return () |
---|
46 | # # Rebuild a query |
---|
47 | # if lo is None: |
---|
48 | # query = hi |
---|
49 | # range = 'max' |
---|
50 | # elif hi is None: |
---|
51 | # query = lo |
---|
52 | # range = 'min' |
---|
53 | # else: |
---|
54 | # query = (lo, hi) |
---|
55 | # range = 'min:max' |
---|
56 | # kw[k] = {'query': query, 'range': range} |
---|
57 | |
---|
58 | return ZCatalog.searchResults(self, REQUEST, **kw) |
---|
59 | |
---|
60 | CatalogTool.searchResults = searchResults |
---|