use of com.celements.web.plugin.api.CelementsWebPluginApi in project celements-blog by celements.
the class BlogPlugin method sendNewsletterActivationMail.
void sendNewsletterActivationMail(BaseObject obj, XWikiDocument blogDoc, String docName, Map<String, String> request, XWikiContext context) throws XWikiException {
String email = request.get("emailadresse");
email = email.toLowerCase();
if (context.getWiki().exists("Tools.NewsletterSubscriptionActivation", context)) {
VelocityContext vcontext = ((VelocityContext) context.get("vcontext"));
vcontext.put("activationKey", getActivationKey(obj, docName));
vcontext.put("blog", blogDoc);
vcontext.put("email", email);
XWikiDocument emailContentDoc = context.getWiki().getDocument("Tools.NewsletterSubscriptionActivation", context);
BaseObject blogConf = blogDoc.getObject("Celements2.BlogConfigClass");
boolean embedImages = blogConf.getIntValue("newsletterEmbedImages", 0) == 1;
vcontext.put("embedImages", embedImages);
String emailContent = emailContentDoc.getTranslatedContent(context);
String htmlContent = context.getWiki().getRenderingEngine().interpretText(emailContent, context.getDoc(), context);
String emailTitle = emailContentDoc.getTranslatedDocument(context).getTitle();
String renderedTitle = context.getWiki().getRenderingEngine().interpretText(emailTitle, context.getDoc(), context);
String from = "";
String reply = "";
if (blogConf != null) {
from = blogConf.getStringValue("from_address");
reply = blogConf.getStringValue("reply_to_address");
}
if ((from == null) || "".equals(from.trim())) {
from = context.getWiki().getXWikiPreference("admin_email", context);
}
if ((reply == null) || "".equals(reply.trim())) {
reply = from;
}
CelementsWebPluginApi celementsweb = (CelementsWebPluginApi) context.getWiki().getPluginApi("celementsweb", context);
celementsweb.getPlugin().sendMail(from, reply, email, null, null, renderedTitle, htmlContent, "", getAllAttachmentsList(), null, context);
} else {
LOGGER.error("No newsletter activation Mail sent for '" + email + "'. No " + "Mailcontent found in Tools.NewsletterSubscriptionActivation");
}
}
Aggregations