コード例 #1
0
ファイル: views.py プロジェクト: Gutherie/Products.IMS
 def action_forward(self, action, data):
     """Forward Message
     """
     message = self.context.forwardMessage(self.request.form.get('subject', data['subject']), data['message'], data['receiver'])
     if message:
         IStatusMessage(self.request).addStatusMessage(_(u"Your message has been sent successfully"), type='info')
         return self.request.response.redirect(message.absolute_url())
     else:
         IStatusMessage(self.request).addStatusMessage(_(u"Sending your message failed"), type='error')
         return self.request.response.redirect(self.context.absolute_url())
コード例 #2
0
ファイル: views.py プロジェクト: Gutherie/Products.IMS
    def _sendMessage(self, action, data):
        imsmessage = IIMSMessage(self.context)

        message = imsmessage.sendMessage(data['subject'], data['message'], data['receiver'])
        if message:
            IStatusMessage(self.request).addStatusMessage(_(u"Your message has been sent successfully"), type='info')
            return self.request.response.redirect(message.absolute_url())
        else:
            IStatusMessage(self.request).addStatusMessage(_(u"Sending your message failed"), type='error')
            return self.request.response.redirect(self.context.absolute_url())
コード例 #3
0
ファイル: utils.py プロジェクト: Gutherie/Products.IMS
def newMessageNotify(object, event):
    """ Notifies the appropriate User if he received a new message
    """
    if IReceivedMessageFolder.providedBy(aq_parent(object)):
        try:
            mailhost = getToolByName(object, 'MailHost')
            mship = getToolByName(object, 'portal_membership')
            sender = object.getSender()
            receiver = object.getReceiver()
            portal = getSiteManager(object)
            body = object.new_message_notification(name=mship.getMemberInfo(receiver).get('fullname', object.getReceiver()),
                                                   sender=mship.getMemberInfo(sender).get('fullname', object.getSender()),
                                                   site=portal.getProperty('title', ''),
                                                   siteurl=getToolByName(object, 'portal_url')(),
                                                   url=object.absolute_url(),
                                                   emailfrom=portal.getProperty('email_from_name', ''),
                                                   message=object)
            mailhost.secureSend(body,
                                mto=mship.getMemberById(receiver).getProperty('email'),
                                mfrom='%s <%s>' % (portal.getProperty('email_from_name', ''), portal.getProperty('email_from_address', '')),
                                subject=translate(_(u'mail_subject', default=u'You have received a new message'), context=object.REQUEST),
                                charset='utf-8')
        except:
            # no mailserver
            pass
コード例 #4
0
 def Title(self):
     try:
         return translate(_('title_sentmessagefolder',
                            default=u'Sent Messages'),
                          context=self.REQUEST)
     except:
         return u'Sent Messages'
コード例 #5
0
 def Title(self):
     try:
         return translate(_('title_sentmessagefolder',
                          default=u'Sent Messages'),
                          context=self.REQUEST).encode('utf-8')
     except:
         return u'Sent Messages'.encode('utf-8')
コード例 #6
0
 def Title(self):
     try:
         return translate(_('title_receivedmessagefolder',
                            default=u'Received Messages'),
                          context=self.REQUEST)
     except:
         return u'Received Messages'
コード例 #7
0
ファイル: views.py プロジェクト: RedTurtle/Products.IMS
    def __call__(self):
        mship = getToolByName(self.context, 'portal_membership')
        current_auth = mship.getAuthenticatedMember()
        if IApplication.providedBy(aq_parent(aq_parent(
                current_auth.getUser()))):
            IStatusMessage(self.request).addStatusMessage(_(
                u"Unfortunately it is not possible to send messages using your user account. Please use a Plone user rather than a Zope user."
            ),
                                                          type='error')
            return self.request.response.redirect(self.context.absolute_url())

        self.request.set('disable_border', True)

        self.form_fields.get('receiver').field.default = None
        self.form_fields.get('receiver').field.readonly = False
        self.form_fields.get('subject').field.default = None
        self.form_fields.get('message').field.default = None

        if self.request.get('receiver', None) is not None:
            self.form_fields.get('receiver').field.default = self.request.get(
                'receiver', None)

        if self.request.get('subject', None) is not None:
            self.form_fields.get('subject').field.default = self.request.get(
                'subject', None).decode('utf-8')

        return super(NewMessageForm, self).__call__()
コード例 #8
0
ファイル: views.py プロジェクト: RedTurtle/Products.IMS
class ForwardMessageForm(formbase.PageForm):
    form_fields = form.FormFields(INewMessageForm)
    label = _(u"Forward Message")

    template = ViewPageTemplateFile('templates/message_form.pt')

    def __call__(self):
        self.request.set('disable_border', True)

        checkOwnership(self.context)

        self.form_fields.get('receiver').field.default = None
        self.form_fields.get('receiver').field.readonly = False

        self.form_fields.get('subject').field.default = (
            'Fw: %s' % self.context.Title().decode('utf-8'))
        if self.request.get('receiver', None) is not None:
            self.form_fields.get('receiver').field.default = self.request.get(
                'receiver', None)
        self.form_fields.get(
            'message').field.default = self.context.getMessage().decode(
                'utf-8')

        return super(ForwardMessageForm, self).__call__()

    @form.action(_(u"forward"))
    def action_forward(self, action, data):
        """Forward Message
        """
        message = self.context.forwardMessage(
            self.request.form.get('subject', data['subject']), data['message'],
            data['receiver'])
        if message:
            IStatusMessage(self.request).addStatusMessage(
                _(u"Your message has been sent successfully"), type='info')
            return self.request.response.redirect(message.absolute_url())
        else:
            IStatusMessage(self.request).addStatusMessage(
                _(u"Sending your message failed"), type='error')
            return self.request.response.redirect(self.context.absolute_url())

    @form.action(_(u"cancel"), validator=lambda *args, **kwargs: {})
    def action_cancel(self, action, data):
        """Cancel message-creation
        """
        return self.request.response.redirect(self.context.absolute_url())
コード例 #9
0
class ReplyMessageForm(formbase.PageForm):
    form_fields = form.FormFields(INewMessageForm)
    label = _("Reply to Message")

    template = ViewPageTemplateFile('templates/message_form.pt')

    def __call__(self):
        self.request.set('disable_border', True)

        checkOwnership(self.context)

        self.form_fields.get('subject').field.default = ('Re: %s' % self.context.Title().decode('utf-8'))
        self.form_fields.get('receiver').field.default = self.context.getSender()
        self.form_fields.get('receiver').field.readonly = True
        self.form_fields.get('message').field.default = None

        return super(ReplyMessageForm, self).__call__()

    @form.action(_("reply"))
    def action_reply(self, action, data):
        """Reply to Message
        """
        message = self.context.replyToMessage(self.request.form.get('subject', data['subject']), data['message'])
        if message:
            IStatusMessage(self.request).addStatusMessage(_("Your message has been sent successfully"), type='info')
            return self.request.response.redirect(message.absolute_url())
        else:
            IStatusMessage(self.request).addStatusMessage(_("Sending your message failed"), type='error')
            return self.request.response.redirect(self.context.absolute_url())

    @form.action(_("cancel"),validator=lambda *args, **kwargs: {})
    def action_cancel(self, action, data):
        """Cancel message-creation
        """
        return self.request.response.redirect(self.context.absolute_url())

    @memoize
    def getMessageThread(self):
        messageview = getMultiAdapter((self.context, self.request), name='view')
        thread = messageview.getMessageThread()
        thread.insert(0, messageview._getMessageValues(self.context))
        return thread
コード例 #10
0
ファイル: views.py プロジェクト: Gutherie/Products.IMS
    def __call__(self):
        mship = getToolByName(self.context, 'portal_membership')
        current_auth = mship.getAuthenticatedMember()
        if IApplication.providedBy(aq_parent(aq_parent(current_auth.getUser()))):
            IStatusMessage(self.request).addStatusMessage(_(u"Unfortunately it is not possible to send messages using your user account. Please use a Plone user rather than a Zope user."), type='error')
            return self.request.response.redirect(self.context.absolute_url())
        
        self.request.set('disable_border', True)

        self.form_fields.get('receiver').field.default = None
        self.form_fields.get('receiver').field.readonly = False
        self.form_fields.get('subject').field.default = None
        self.form_fields.get('message').field.default = None

        if self.request.get('receiver', None) is not None:
            self.form_fields.get('receiver').field.default = self.request.get('receiver', None)

        if self.request.get('subject', None) is not None:
            self.form_fields.get('subject').field.default = self.request.get('subject', None).decode('utf-8')

        return super(NewMessageForm, self).__call__()
コード例 #11
0
class NewContextMessageForm(NewMessageForm):
    form_fields = form.FormFields(INewMessageForm)

    def __call__(self):
        self.request.set('disable_border', True)

        self.form_fields.get('receiver').field.default = self.context.getId()
        self.form_fields.get('receiver').field.readonly = True
        self.form_fields.get('subject').field.default = None
        self.form_fields.get('message').field.default = None

        if self.request.get('subject', None) is not None:
            self.form_fields.get('subject').field.default = self.request.get('subject', None).decode('utf-8')

        return super(NewMessageForm, self).__call__()

    @form.action(_("send"))
    def action_send(self, action, data):
        """Send the message
        """
        data['receiver'] = self.context.getId()
        return self._sendMessage(action, data)
コード例 #12
0
from Products.Archetypes.public import *

from Products.ATContentTypes.content.base import ATCTMixin

from Products.IMS.config import PROJECTNAME
from Products.IMS.interfaces import IMessage, IIMSMessage, ISentMessage, IReceivedMessage
from Products.IMS import IMSMessageFactory as _
from Products.IMS.events import MessageBeforeDelete

MessageSchema = BaseContent.schema.copy() + Schema((
    StringField(
        name='sender',
        required=1,
        widget=StringWidget(
            label=_('label_sender', default=u'Sent by'),
            visible=0,
        ),
    ),
    LinesField(
        name='receiver',
        required=1,
        widget=TextAreaWidget(
            label=_('label_receiver', default=u'Received by'),
            visible=0,
        ),
    ),
    TextField(
        name='message',
        required=1,
        widget=TextAreaWidget(
コード例 #13
0
 def Title(self):
     try:
         return translate(_('title_receivedmessagefolder', default=u'Received Messages'), context=self.REQUEST)
     except:
         return u'Received Messages'