def _quoted_txt2html(*args, **kwargs): from invenio.utils.mail import email_quoted_txt2html return email_quoted_txt2html(*args, **kwargs)
def tmpl_display_msg(self, msg_id="", msg_from_id="", msg_from_nickname="", msg_sent_to="", msg_sent_to_group="", msg_subject="", msg_body="", msg_sent_date="", msg_received_date=datetext_default, ln=CFG_SITE_LANG): """ Displays a given message @param msg_id: id of the message @param msg_from_id: id of user who sent the message @param msg_from_nickname: nickname of the user who sent the message @param msg_sent_to: list of users who received the message (comma separated string) @param msg_sent_to_group: list of groups who received the message (comma separated string) @param msg_subject: subject of the message @param msg_body: body of the message @param msg_sent_date: date at which the message was sent @param msg_received_date: date at which the message had to be received (if this argument != 0000-00-00 => reminder @param ln: language of the page @return: the message in HTML format """ # load the right message language _ = gettext_set_language(ln) sent_to_link = '' tos = msg_sent_to.split(CFG_WEBMESSAGE_SEPARATOR) if (tos): for to in tos[0:-1]: to_display = to if to.isdigit(): (dummy, to, to_display) = get_user_info(int(to), ln) sent_to_link += create_html_link(CFG_SITE_URL + '/yourmessages/write', {'msg_to': to, 'ln': ln}, escape_html(to_display)) sent_to_link += CFG_WEBMESSAGE_SEPARATOR to_display = tos[-1] to = tos[-1] if to.isdigit(): (dummy, to, to_display) = get_user_info(int(to), ln) sent_to_link += create_html_link(CFG_SITE_URL + '/yourmessages/write', {'msg_to': to, 'ln': ln}, escape_html(to_display)) group_to_link = "" groups = msg_sent_to_group.split(CFG_WEBMESSAGE_SEPARATOR) if (groups): for group in groups[0:-1]: group_to_link += create_html_link( CFG_SITE_URL + '/yourmessages/write', {'msg_to_group': group, 'ln': ln}, escape_html(group)) group_to_link += CFG_WEBMESSAGE_SEPARATOR group_to_link += create_html_link( CFG_SITE_URL + '/yourmessages/write', {'msg_to_group': groups[-1], 'ln': ln}, escape_html(groups[-1])) # format the msg so that the '>>' chars give vertical lines final_body = email_quoted_txt2html(msg_body) out = """ <table class="mailbox" style="width: 70%%;"> <thead class="mailboxheader"> <tr> <td class="inboxheader" colspan="2"> <table class="messageheader"> <tr> <td class="mailboxlabel">%(from_label)s</td> <td>%(from_link)s</td> </tr> <tr> <td class="mailboxlabel">%(subject_label)s</td> <td style="width: 100%%;">%(subject)s</td> </tr> <tr> <td class="mailboxlabel">%(sent_label)s</td> <td>%(sent_date)s</td> </tr>""" if (msg_received_date != datetext_default): out += """ <tr> <td class="mailboxlabel">%(received_label)s</td> <td>%(received_date)s</td> </tr>""" out += """ <tr> <td class="mailboxlabel">%(sent_to_label)s</td> <td>%(sent_to)s</td> </tr>""" if (msg_sent_to_group != ""): out += """ <tr> <td class="mailboxlabel">%(groups_label)s</td> <td>%(sent_to_group)s</td> </tr>""" out += """ </table> </td> </tr> </thead> <tfoot> <tr> <td></td> <td></td> </tr> </tfoot> <tbody class="mailboxbody"> <tr class="mailboxrecord"> <td colspan="2">%(body)s</td> </tr> <tr class="mailboxfooter"> <td> <form name="reply" action="%(reply_url)s" method="post"> <input class="formbutton" name="reply" value="%(reply_but_label)s" type="submit" /> </form> </td> <td> <form name="deletemsg" action="%(delete_url)s" method="post"> <input class="formbutton" name="delete" value="%(delete_but_label)s" type="submit" /> </form> </td> </tr> </tbody> </table> """ if msg_from_nickname: msg_from_display = msg_from_nickname else: msg_from_display = get_user_info(msg_from_id, ln)[2] msg_from_nickname = msg_from_id return out % {'from_link': create_html_link( CFG_SITE_URL + '/yourmessages/write', {'msg_to': msg_from_nickname, 'ln': ln}, msg_from_display), 'reply_url': create_url(CFG_SITE_URL + '/yourmessages/write', {'msg_reply_id': msg_id, 'ln': ln}), 'delete_url': create_url(CFG_SITE_URL + '/yourmessages/delete', {'msgid': msg_id, 'ln': ln}), 'sent_date' : convert_datetext_to_dategui(msg_sent_date, ln), 'received_date': convert_datetext_to_dategui(msg_received_date, ln), 'sent_to': sent_to_link, 'sent_to_group': group_to_link, 'subject' : msg_subject, 'body' : final_body, 'reply_to': msg_from_id, 'ln': ln, 'from_label':_("From:"), 'subject_label':_("Subject:"), 'sent_label': _("Sent on:"), 'received_label':_("Received on:"), 'sent_to_label': _("Sent to:"), 'groups_label': _("Sent to groups:"), 'reply_but_label':_("REPLY"), 'delete_but_label': _("DELETE")}