source: products/qPloneComments/trunk/skins/qplonecomments/prefs_comments_setup.cpy @ 1

Last change on this file since 1 was 1, checked in by myroslav, 18 years ago

Building directory structure

File size: 1.7 KB
Line 
1## Script (Python) "prefs_comments_setup"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=
9##
10from Products.CMFCore.utils import getToolByName
11from Products.qPloneComments.utils import setAnonymCommenting
12from Products.qPloneComments.utils import setStatusMsg
13
14form = context.REQUEST.form
15pp = getToolByName(context, 'portal_properties')
16props_sheet = getattr(pp, 'qPloneComments')
17property_maps=[(m['id'], m['type']) for m in props_sheet.propertyMap() if not m['id']=='title']
18request_ids = form.keys()
19
20kw={}
21for id,type in property_maps:
22    if type == 'boolean':
23        if id in request_ids:
24            kw[id] = True
25        else:
26            kw[id] = False
27
28        # Switch anonymouse commenting
29        if id == 'enable_anonymous_commenting':
30            allow = False
31            if id in request_ids:
32                allow = True
33            setAnonymCommenting(context, allow)
34    else:
35        if id in request_ids:
36            kw[id] = form[id]
37
38props_sheet.manage_changeProperties(kw)
39
40moderate_discussion = 'Moderate Discussion'
41if not 'EnableManagerModeration' in request_ids:
42    roles = [item['name'] for item in context.rolesOfPermission(moderate_discussion)
43             if (item['name'] != 'Manager') and (item['selected'] == 'SELECTED')]
44    context.manage_permission(moderate_discussion, roles,  acquire=0)
45
46else:
47    roles = [item['name'] for item in context.rolesOfPermission(moderate_discussion)
48             if item['selected'] == 'SELECTED']
49    roles.append('Manager')
50    context.manage_permission(moderate_discussion, roles,  acquire=0)
51
52setStatusMsg(state, context, u'qPloneComments configuration changes saved.')
53return state
Note: See TracBrowser for help on using the repository browser.