'Form to Compose a Message
@param type: The default message type: None, EMAIL, SMS or TWITTER
@param recipient_type: Send to Persons or Groups? (pr_person or pr_group)
@param recipient: The pe_id of the person/group to send the message to
- this can also be set by setting one of
(in priority order, if multiple found):
request.vars.pe_id
request.vars.person_id @ToDo
request.vars.group_id  @ToDo
request.vars.hrm_id    @ToDo
@param subject: The default subject text (for Emails)
@param message: The default message text
@param url: Redirect to the specified URL() after message sent
@param formid: If set, allows multiple forms open in different tabs'

def compose(self, type='SMS', recipient_type=None, recipient=None, subject='', message='', url=None):

    if (not url):
        url = URL(c='msg', f='compose')
    auth = current.auth
    if (auth.is_logged_in() or auth.basic()):
        pass
    else:
        redirect(URL(c='default', f='user', args='login', vars={'_next': url}))
    if (not auth.permission.has_permission('update', c='msg')):
        current.session.error = current.T('You    do    not    have    permission    to    send    messages')
        redirect(URL(f='index'))
    instance = S3Compose()
    instance.contact_method = type
    instance.recipient = recipient
    instance.recipients = None
    instance.recipient_type = recipient_type
    instance.subject = subject
    instance.message = message
    instance.resource = None
    instance.url = url
    form = instance._compose_form()
    title = current.T('Send    Message')
    return dict(form=form, title=title)
