a6b02c9d866ae0f9d38a320a2744fe365f13ddd8
[MosaicDocument.git] / skins / make_nav_tree.py
1 ##parameters=rootObject, filtered_meta_types=[], userid=''
2
3 req = context.REQUEST
4 resp = req.RESPONSE
5 collapse_all = False
6 if req.form.get('collapse_all', '') == rootObject.id or req.get('just_login', False) :
7 collapse_all = True
8
9 from Products.CMFCore.permissions import View
10
11 def getSubObjects(object) :
12 if getattr(object, 'isPortalContent', False) :
13 return []
14 childs = list(object.listNearestFolderContents(contentFilter={'portal_type':filtered_meta_types}, userid=userid))
15 childs.sort(lambda x, y : cmp(x.title_or_id().lower(), y.title_or_id().lower()))
16 return childs
17
18
19
20 from ZTUtils import SimpleTreeMaker
21 stateName = rootObject.id + userid + '_tree'
22 cookieName = stateName + '-state'
23 stm = SimpleTreeMaker(stateName)
24 stm.setChildAccess(function=getSubObjects)
25 #stm.setStateFunction(expandIfUnauthorized)
26
27 tree, rows = stm.cookieTree(rootObject)
28 cookieValue = resp.cookies[cookieName]['value']
29 resp.setCookie(cookieName, cookieValue, path = '/')
30
31 return {'tree' : tree, 'rows' : rows}