source: products/qPloneComments/tags/1.7.2/skins/qplonecomments/prefs_comments_setup.cpy

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

Building directory structure

File size: 1.3 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.qPloneComments.config import PROPERTY_SHEET
11from Products.qPloneComments.utils import setAnonymCommenting
12from Products.CMFCore.utils import getToolByName
13
14form = context.REQUEST.form
15pp = getToolByName(context, 'portal_properties')
16props_sheet = getattr(pp, PROPERTY_SHEET)
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        # For boolean type in REQUEST present ONLY CHECKED fields
24        # PECULIARITY: when field uncheck - it disappear from the REQUEST
25        if id in request_ids:
26            kw[id] = True
27        else:
28            kw[id] = False
29
30        # Switch anonymouse commenting
31        if id == 'Enable_Anonymous_Commenting':
32            allow = False
33            if id in request_ids:
34                allow = True
35            setAnonymCommenting(context, allow)
36    else:
37        if id in request_ids:
38            kw[id] = form[id]
39
40props_sheet.manage_changeProperties(kw)
41
42return state.set(portal_status_message='qPloneComments configuration changes saved.')
Note: See TracBrowser for help on using the repository browser.