source: products/qPloneCaptchas/tags/1.3.3/skins/captchas_discussion/2.0.5/discussion_reply.cpy @ 2284

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

Building directory structure

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1## Script (Python) "discussion_reply"
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=subject,body_text,text_format='plain',username=None,password=None
9##title=Reply to content
10
11from Products.PythonScripts.standard import url_quote_plus
12req = context.REQUEST
13
14if username or password:
15    # The user username/password inputs on on the comment form were used,
16    # which might happen when anonymous commenting is enabled. If they typed
17    # something in to either of the inputs, we send them to 'logged_in'.
18    # 'logged_in' will redirect them back to this script if authentication
19    # succeeds with a query string which will post the message appropriately
20    # and show them the result.  if 'logged_in' fails, the user will be
21    # presented with the stock login failure page.  This all depends
22    # heavily on cookiecrumbler, but I believe that is a Plone requirement.
23    came_from = '%s?subject=%s&body_text=%s' % (req['URL'], subject, body_text)
24    came_from = url_quote_plus(came_from)
25    portal_url = context.portal_url()
26
27    return req.RESPONSE.redirect(
28        '%s/logged_in?__ac_name=%s'
29        '&__ac_password=%s'
30        '&came_from=%s' % (portal_url,
31                               url_quote_plus(username),
32                               url_quote_plus(password),
33                               came_from,
34                               )
35        )
36
37# if (the user is already logged in) or (if anonymous commenting is enabled and
38# they posted without typing a username or password into the form), we do
39# the following
40
41creator = context.portal_membership.getAuthenticatedMember().getUserName()
42tb = context.talkback
43id = tb.createReply(title=subject, text=body_text, Creator=creator)
44reply = tb.getReply(id)
45
46#XXX THIS NEEDS TO GO AWAY!
47portal_discussion=context.portal_discussion
48if hasattr(portal_discussion.aq_explicit, 'cookReply'):
49    portal_discussion.cookReply(reply, text_format='plain')
50
51parent = tb.aq_parent
52
53from Products.CMFPlone import transaction_note
54transaction_note('Added comment to %s at %s' % (parent.title_or_id(), reply.absolute_url()))
55
56target = '%s/%s' % (parent.absolute_url(), parent.getTypeInfo().getActionById('view'))
57return req.RESPONSE.redirect(target)
Note: See TracBrowser for help on using the repository browser.