use of com.xpn.xwiki.web.XWikiMessageTool in project celements-blog by celements.
the class NewsletterReceivers method sendNewsletterToOneReceiver.
String[] sendNewsletterToOneReceiver(String from, String replyTo, String subject, XWikiDocument doc, String baseURL, String[] userMailPair, XWikiContext context) throws XWikiException {
VelocityContext vcontext = (VelocityContext) context.get("vcontext");
String[] result;
LOGGER.debug("userMailPair: " + ArrayUtils.toString(userMailPair));
context.setUser(userMailPair[0]);
String language = userMailPair[2];
context.setLanguage(language);
vcontext.put("firstname", userMailPair[3]);
vcontext.put("name", userMailPair[4]);
vcontext.put("email", userMailPair[1]);
vcontext.put("language", language);
vcontext.put("newsletter_language", language);
vcontext.put("admin_language", language);
XWikiMessageTool msgTool = getWebUtilsService().getMessageTool(language);
vcontext.put("msg", msgTool);
vcontext.put("adminMsg", msgTool);
if (context.getWiki().checkAccess("view", doc, context)) {
String senderContextLang = context.getLanguage();
context.setLanguage(language);
String htmlContent = getHtmlContent(doc, baseURL);
context.setLanguage(language);
htmlContent += getUnsubscribeFooter(userMailPair[1], doc);
context.setLanguage(senderContextLang);
XWikiMessageTool messageTool = getWebUtilsService().getMessageTool(language);
int singleResult = sendMail(from, replyTo, userMailPair[1], subject, baseURL, htmlContent);
result = new String[] { userMailPair[1], Integer.toString(singleResult) };
} else {
LOGGER.warn("Tried to send " + doc + " to user " + userMailPair[0] + " which" + " has no view rights on this Document.");
List<String> params = new ArrayList<>();
params.add(doc.toString());
XWikiMessageTool messageTool = getWebUtilsService().getMessageTool(language);
result = new String[] { userMailPair[1], messageTool.get("cel_blog_newsletter_receiver_no_rights", params) };
}
return result;
}
Aggregations