'Send a Task Dispatch notice from a Task
- if a location is supplied, this will be formatted as an OpenGeoSMS'

@staticmethod
def project_task_dispatch(r, **attr):

    if ((r.representation == 'html') and (r.name == 'task') and r.id and (not r.component)):
        record = r.record
        text = ('%s:    %s' % (record.name, record.description))
        msg = current.msg
        message = msg.prepare_opengeosms(record.location_id, code='ST', map='google', text=text)
        url = URL(c='project', f='task', args=r.id)
        if record.pe_id:
            opts = dict(recipient=record.pe_id)
        else:
            opts = dict(recipient_type='pr_person')
        output = msg.compose(type='SMS', message=message, url=url, **opts)
        if ('rheader' in attr):
            rheader = attr['rheader'](r)
            if rheader:
                output['rheader'] = rheader
        output['title'] = current.T('Send    Task    Notification')
        current.response.view = 'msg/compose.html'
        return output
    else:
        raise HTTP(405, current.ERROR.BAD_METHOD)
