source: products/qPloneComments/branches/plone3_extend/skins/qplonecomments/prefs_comments_setup.cpy @ 864

Last change on this file since 864 was 800, checked in by crchemist, 17 years ago

Deleted mistakable folder.

  • Property svn:eol-style set to native
File size: 1.8 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
13from Products.CMFPlone import MessageFactory
14_ = MessageFactory('plonecomments')
15
16form = context.REQUEST.form
17pp = getToolByName(context, 'portal_properties')
18props_sheet = getattr(pp, 'qPloneComments')
19property_maps=[(m['id'], m['type']) for m in props_sheet.propertyMap() if not m['id']=='title']
20request_ids = form.keys()
21
22kw={}
23for id,type in property_maps:
24    if type == 'boolean':
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
42moderate_discussion = 'Moderate Discussion'
43if not 'EnableManagerModeration' in request_ids:
44    roles = [item['name'] for item in context.rolesOfPermission(moderate_discussion)
45             if (item['name'] != 'Manager') and (item['selected'] == 'SELECTED')]
46    context.manage_permission(moderate_discussion, roles,  acquire=0)
47
48else:
49    roles = [item['name'] for item in context.rolesOfPermission(moderate_discussion)
50             if item['selected'] == 'SELECTED']
51    roles.append('Manager')
52    context.manage_permission(moderate_discussion, roles,  acquire=0)
53
54setStatusMsg(state, context, _(u'qPloneComments configuration changes saved.'))
55return state
Note: See TracBrowser for help on using the repository browser.