use of org.olat.core.util.mail.MailBundle in project openolat by klemens.
the class IQEditReplaceWizard method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == mailCtr && event == Event.DONE_EVENT) {
MailTemplate mailTemplate = mailCtr.getMailTemplate();
if (mailTemplate != null) {
MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
String metaId = UUID.randomUUID().toString().replace("-", "");
MailerResult result = new MailerResult();
MailBundle[] bundles = mailManager.makeMailBundles(context, learners, mailTemplate, getIdentity(), metaId, result);
result.append(mailManager.sendMessage(bundles));
if (mailTemplate.getCpfrom()) {
MailBundle ccBundle = mailManager.makeMailBundle(context, getIdentity(), mailTemplate, getIdentity(), metaId, result);
result.append(mailManager.sendMessage(ccBundle));
}
}
fireEvent(ureq, Event.DONE_EVENT);
} else if (source == searchCtr && event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRY_SELECTED) {
selectedRepositoryEntry = searchCtr.getSelectedEntry();
doStep2(ureq);
}
}
use of org.olat.core.util.mail.MailBundle in project openolat by klemens.
the class QTI21AssessmentRunController method decorateCourseConfirmation.
public static void decorateCourseConfirmation(AssessmentTestSession candidateSession, DigitalSignatureOptions options, CourseEnvironment courseEnv, CourseNode courseNode, RepositoryEntry testEntry, Date timestamp, Locale locale) {
MailBundle bundle = new MailBundle();
bundle.setToId(candidateSession.getIdentity());
Identity assessedIdentity = candidateSession.getIdentity();
String fullname = CoreSpringFactory.getImpl(UserManager.class).getUserDisplayName(assessedIdentity);
Date assessedDate = candidateSession.getFinishTime() == null ? timestamp : candidateSession.getFinishTime();
String[] args = new String[] { // {0}
courseEnv.getCourseTitle(), // {1}
courseEnv.getCourseResourceableId().toString(), // {2}
courseNode.getShortTitle(), // {3}
courseNode.getIdent(), // {4}
testEntry.getDisplayname(), // {5}
fullname, Formatter.getInstance(locale).formatDateAndTime(// {6}
assessedDate), // {7}
assessedIdentity.getName(), assessedIdentity.getUser().getProperty(UserConstants.INSTITUTIONALUSERIDENTIFIER, // {8}
locale), assessedIdentity.getUser().getProperty(UserConstants.INSTITUTIONALNAME, // {9}
locale) };
Translator translator = Util.createPackageTranslator(QTI21AssessmentRunController.class, locale);
String subject = translator.translate("digital.signature.mail.subject", args);
String body = translator.translate("digital.signature.mail.body", args);
bundle.setContent(subject, body);
options.setMailBundle(bundle);
options.setSubIdentName(courseNode.getShortTitle());
}
use of org.olat.core.util.mail.MailBundle in project openolat by klemens.
the class BGEmailCompositionStepController method formOK.
@Override
protected void formOK(UserRequest ureq) {
boolean success = false;
try {
File[] attachments = contactForm.getAttachments();
MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
MailBundle bundle = new MailBundle();
bundle.setContext(context);
bundle.setFromId(getIdentity());
bundle.setContactLists(contactForm.getEmailToContactLists());
bundle.setContent(contactForm.getSubject(), contactForm.getBody(), attachments);
MailerResult result = mailService.sendMessage(bundle);
success = result.isSuccessful();
if (contactForm.isTcpFrom()) {
MailBundle ccBundle = new MailBundle();
ccBundle.setContext(context);
ccBundle.setFromId(getIdentity());
ccBundle.setCc(getIdentity());
ccBundle.setContent(contactForm.getSubject(), contactForm.getBody(), attachments);
MailerResult ccResult = mailService.sendMessage(ccBundle);
success = ccResult.isSuccessful();
}
} catch (Exception e) {
logError(null, e);
}
if (success) {
fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
}
}
use of org.olat.core.util.mail.MailBundle in project openolat by klemens.
the class OLATAuthManager method sendConfirmationEmail.
private void sendConfirmationEmail(Identity doer, Identity identity) {
String prefsLanguage = identity.getUser().getPreferences().getLanguage();
Locale locale = I18nManager.getInstance().getLocaleOrDefault(prefsLanguage);
Translator translator = Util.createPackageTranslator(OLATAuthenticationController.class, locale);
ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(OresHelper.createOLATResourceableInstance("changepw", 0l));
String changePwUrl = BusinessControlFactory.getInstance().getAsURIString(Collections.singletonList(ce), false);
String[] args = new String[] { // 0: changed users username
identity.getName(), // 1: changed users email address
UserManager.getInstance().getUserDisplayEmail(identity, locale), // 2: Name (first and last name) of user who changed the password
userManager.getUserDisplayName(doer.getUser()), // 3: configured support email address
WebappHelper.getMailConfig("mailSupport"), // 4: direct link to change password workflow (e.g. https://xx.xx.xx/olat/url/changepw/0)
changePwUrl };
String subject = translator.translate("mail.pwd.subject", args);
String body = translator.translate("mail.pwd.body", args);
MailContext context = new MailContextImpl(null, null, "[Identity:" + identity.getKey() + "]");
MailBundle bundle = new MailBundle();
bundle.setContext(context);
bundle.setToId(identity);
bundle.setContent(subject, body);
mailManager.sendMessage(bundle);
}
use of org.olat.core.util.mail.MailBundle in project openolat by klemens.
the class SendDocumentsByEMailController method sendEmail.
protected void sendEmail(List<Identity> tos, String subject, String body, UserRequest ureq) {
File[] attachmentArray = null;
if (attachments != null && !attachments.isEmpty() && allowAttachments) {
attachmentArray = attachments.toArray(new File[attachments.size()]);
}
MailerResult result = new MailerResult();
String metaId = UUID.randomUUID().toString().replace("-", "");
for (Identity to : tos) {
MailBundle bundle = new MailBundle();
bundle.setToId(to);
bundle.setMetaId(metaId);
bundle.setFromId(ureq.getIdentity());
bundle.setContent(subject, body, attachmentArray);
result.append(mailManager.sendMessage(bundle));
}
MailHelper.printErrorsAndWarnings(result, getWindowControl(), ureq.getUserSession().getRoles().isOLATAdmin(), ureq.getLocale());
}
Aggregations