예제 #1
0
    def submit_abuse_report(self):
        """ Send an email with the abuse report message and hide abuse report form.
        """
        errors = {}
        context = aq_inner(self.context)
        request = context.REQUEST
        portal = getToolByName(self.context, 'portal_url').getPortalObject()
        if hasattr(context, 'captcha_validator'):
            dummy_controller_state = ControllerState(
                                            id='comments.pt',
                                            context=context,
                                            button='submit',
                                            status='success',
                                            errors={},
                                            next_action=None,)
            # get the form controller
            controller = portal.portal_form_controller
            # send the validate script to the form controller with the dummy state object
            controller_state = controller.validate(dummy_controller_state, request, ['captcha_validator',])
            errors.update(controller_state.errors)

        message = request.get('message')
        if not message:
            errors.update({'message': 'Please provide a message'})

        mtool = getToolByName(self.context, "portal_membership")
        member = mtool.getAuthenticatedMember()
        comment_id = self.context.request.get('comment_id')
        ksscore = self.getCommandSet('core')
        if errors:
            html = self.macroContent('context/report_abuse_form/macros/form',
                                     errors=errors,
                                     show_form=True,
                                     tabindex=IndexIterator(),
                                     member=member,
                                     **request.form)
            node = ksscore.getHtmlIdSelector('span-reply-form-holder-%s' % comment_id)
            ksscore.replaceInnerHTML(node,  html)
            return self.render()

        # report_abuse(context, context, message, comment)
        manage_mails(context, self.context, 'report_abuse')

        html = self.macroContent('context/report_abuse_form/macros/form',
                                 tabindex=IndexIterator(),
                                 member=member,
                                 **request.form)
        node = ksscore.getHtmlIdSelector('span-reply-form-holder-%s' % comment_id)
        html = '<br/><span style="color:red">You have reported this comment for abuse.</span>'
        self.commands.addCommand('remove_abuse_report_form', 
                                 node, 
                                 comment_id=comment_id, 
                                 html=html)

        node = ksscore.getHtmlIdSelector('div-captcha-%s' % comment_id)
        html = self.macroContent('context/report_abuse_form/macros/captcha',
                                 **request.form)
        ksscore.replaceInnerHTML(node,  html)
        return self.render()
예제 #2
0
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=obj=None
##title=Delete discussion item
##

from quintagroup.plonecomments.utils import manage_mails
from Products.CMFPlone import PloneMessageFactory

if obj is None:
    obj=context

parent = obj.inReplyTo()
if parent is not None:
    talkback = context.portal_discussion.getDiscussionFor(parent)
else:
    talkback = parent = obj.aq_parent

# remove the discussion item
talkback.deleteReply( obj.getId() )
manage_mails(obj, context, 'deleting')

# redirect to the object that is being discussed
redirect_target = context.plone_utils.getDiscussionThread(talkback)[0]
view = redirect_target.getTypeInfo().immediate_view

context.plone_utils.addPortalMessage(PloneMessageFactory(u'Reply deleted.'))

context.REQUEST['RESPONSE'].redirect( redirect_target.absolute_url() + '/%s' % view )
from Products.CMFPlone import MessageFactory
_ = MessageFactory('quintagroup.plonecomments')

if obj is None:
    obj = context

parent = obj.inReplyTo()
if parent is not None:
    dtool = getToolByName(context, 'portal_discussion')
    talkback = dtool.getDiscussionFor(parent)
else:
    talkback = parent = obj.aq_parent

reply = talkback.getReply(obj.getId())
publishDiscussion(reply)
manage_mails(reply, context, action='publishing')

putils = getToolByName(context, 'plone_utils')
redirect_target = putils.getDiscussionThread(talkback)[0]
view = redirect_target.getTypeInfo().getActionInfo('object/view')['url']
rt = redirect_target.absolute_url()

if rt and rt[-1] == '/':
    rt = rt[:-1]

if view and view[0] == '/':
    view = view[1:]

if view and view[-1] == '/':
    view = view[:-1]
_ = MessageFactory("quintagroup.plonecomments")

if obj is None:
    obj = context

parent = obj.inReplyTo()
if parent is not None:
    dtool = getToolByName(context, "portal_discussion")
    talkback = dtool.getDiscussionFor(parent)
else:
    talkback = parent = obj.aq_parent

reply = talkback.getReply(obj.getId())
publishDiscussion(reply)
manage_mails(reply, context, action="publishing")

putils = getToolByName(context, "plone_utils")
redirect_target = putils.getDiscussionThread(talkback)[0]
view = redirect_target.getTypeInfo().getActionInfo("object/view")["url"]
rt = redirect_target.absolute_url()

if rt and rt[-1] == "/":
    rt = rt[:-1]

if view and view[0] == "/":
    view = view[1:]

if view and view[-1] == "/":
    view = view[:-1]