use of org.olat.core.util.mail.MailBundle in project OpenOLAT by OpenOLAT.
the class UserBulkChangeManager method sendLoginDeniedEmail.
public void sendLoginDeniedEmail(Identity identity) {
String lang = identity.getUser().getPreferences().getLanguage();
Locale locale = I18nManager.getInstance().getLocaleOrDefault(lang);
Translator translator = Util.createPackageTranslator(SystemRolesAndRightsController.class, locale);
String gender = "";
UserPropertyHandler handler = userManager.getUserPropertiesConfig().getPropertyHandler(UserConstants.GENDER);
if (handler instanceof GenderPropertyHandler) {
String internalGender = ((GenderPropertyHandler) handler).getInternalValue(identity.getUser());
if (StringHelper.containsNonWhitespace(internalGender)) {
Translator userPropTrans = userManager.getUserPropertiesConfig().getTranslator(translator);
gender = userPropTrans.translate("form.name.gender.salutation." + internalGender);
}
}
String email = identity.getUser().getProperty(UserConstants.EMAIL, null);
email = StringHelper.containsNonWhitespace(email) ? email : "-";
String[] args = new String[] { // 0: changed users username
identity.getName(), // 1: changed users email address
email, // 2: Name (first and last name) of user who changed the password
userManager.getUserDisplayName(identity.getUser()), // 3: configured support email address
WebappHelper.getMailConfig("mailSupport"), // 4 last name
identity.getUser().getProperty(UserConstants.LASTNAME, null), // 5 url system
getServerURI(), // 6 Mr. Mrs.
gender };
MailBundle bundle = new MailBundle();
bundle.setToId(identity);
bundle.setContent(translator.translate("mailtemplate.login.denied.subject", args), translator.translate("mailtemplate.login.denied.body", args));
mailManager.sendExternMessage(bundle, null, false);
}
use of org.olat.core.util.mail.MailBundle in project OpenOLAT by OpenOLAT.
the class UserImportController method sendMailToNewIdentities.
private void sendMailToNewIdentities(Map<TransientIdentity, Identity> newIdentities) {
MailerResult result = new MailerResult();
for (Map.Entry<TransientIdentity, Identity> newEntry : newIdentities.entrySet()) {
if (newEntry.getKey() != null && newEntry.getValue() != null) {
Identity newIdentity = newEntry.getValue();
MailTemplate template = createMailTemplateForNewIdentity(newIdentity, newEntry.getKey());
MailBundle bundle = mailService.makeMailBundle(null, newIdentity, template, getIdentity(), null, result);
if (bundle != null) {
mailService.sendExternMessage(bundle, result, true);
}
}
}
}
use of org.olat.core.util.mail.MailBundle in project OpenOLAT by OpenOLAT.
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());
}
use of org.olat.core.util.mail.MailBundle in project OpenOLAT by OpenOLAT.
the class GTAParticipantController method doSubmissionEmail.
private void doSubmissionEmail() {
String body = config.getStringValue(GTACourseNode.GTASK_SUBMISSION_TEXT);
if (StringHelper.containsNonWhitespace(body)) {
MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
List<Identity> recipientsTO;
File submitDirectory;
if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
recipientsTO = businessGroupService.getMembers(assessedGroup, GroupRoles.participant.name());
submitDirectory = gtaManager.getSubmitDirectory(courseEnv, gtaNode, assessedGroup);
} else {
recipientsTO = Collections.singletonList(assessedIdentity);
submitDirectory = gtaManager.getSubmitDirectory(courseEnv, gtaNode, assessedIdentity);
}
String subject = translate("submission.mail.subject");
File[] files = TaskHelper.getDocuments(submitDirectory);
MailTemplate template = new GTAMailTemplate(subject, body, files, getIdentity(), getTranslator());
MailerResult result = new MailerResult();
MailBundle[] bundles = mailManager.makeMailBundles(context, recipientsTO, template, null, UUID.randomUUID().toString(), result);
mailManager.sendMessage(bundles);
}
}
use of org.olat.core.util.mail.MailBundle in project OpenOLAT by OpenOLAT.
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);
}
}
Aggregations