source: products/qPloneCaptchas/trunk/skins/plone_captchas/prefs_captchas_setup.cpy @ 659

Last change on this file since 659 was 60, checked in by piv, 18 years ago

changes: added to readme.txt explanation to use of dropdownmenutool; changed drop_down.css; compatible with Plone 2.1

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1## Controller Script (Python) "prefs_captchas_setup"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind state=state
7##bind subpath=traverse_subpath
8##parameters=
9##title=Set necessary skin
10##
11from Products.CMFCore.utils import getToolByName
12import string
13
14def exchangeLayers(layer1, layer2):
15    for skin in skinstool.getSkinSelections():
16        path = skinstool.getSkinPath(skin)
17        path = map( string.strip, string.split( path,',' ))
18        try:
19            i = path.index(layer1)
20            path.remove(layer1)
21            path.insert(i, layer2)
22        except ValueError:
23            pass
24        path = string.join( path, ', ' )
25        skinstool.addSkinSelection( skin, path )
26
27form = context.REQUEST.form
28request_ids = form.keys()
29ct = form.get('static_captchas')
30skinstool = getToolByName(context, 'portal_skins')
31if ct == 'static':
32    exchangeLayers('plone_captchas/dynamic', 'plone_captchas/static')
33else:
34    exchangeLayers('plone_captchas/static', 'plone_captchas/dynamic')
35
36captcha_props = getToolByName(context, 'portal_properties')['qPloneCaptchas']
37
38property_map=[(m['id'], m['type']) for m in captcha_props.propertyMap() if not m['id']=='title']
39kw={}
40for id,type in property_map:
41    if type == 'boolean':
42        if id in request_ids:
43            kw[id] = True
44        else:
45            kw[id] = False
46    else:
47        if id in request_ids:
48            kw[id] = form[id]
49
50captcha_props.manage_changeProperties(**kw)
51
52return state.set(portal_status_message = 'Changes saved.')
Note: See TracBrowser for help on using the repository browser.