use of org.olat.core.util.mail.MailContext in project openolat by klemens.
the class GTAAvailableTaskController method doSendConfirmationEmail.
private void doSendConfirmationEmail(Task assignedTask) {
MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
MailBundle bundle = new MailBundle();
bundle.setContext(context);
ContactList contacts = new ContactList("participants");
if (GTAType.group.name().equals(gtaNode.getModuleConfiguration().getStringValue(GTACourseNode.GTASK_TYPE))) {
List<Identity> participants = businessGroupService.getMembers(assessedGroup, GroupRoles.participant.name());
contacts.addAllIdentites(participants);
bundle.setMetaId(UUID.randomUUID().toString());
} else {
contacts.add(assessedIdentity);
}
bundle.setContactList(contacts);
String[] args = new String[] { // 0 first name
getIdentity().getUser().getFirstName(), // 1 last name
getIdentity().getUser().getLastName(), // 2 course name
courseEnv.getCourseTitle(), // 3 task
assignedTask.getTaskName() };
String subject = translate("mail.confirm.assignment.subject", args);
String body = translate("mail.confirm.assignment.body", args);
bundle.setContent(subject, body);
mailManager.sendMessage(bundle);
}
use of org.olat.core.util.mail.MailContext in project openolat by klemens.
the class ProjectGroupController method handleCandidateGroupEvent.
private void handleCandidateGroupEvent(UserRequest urequest, Event event) {
if (event instanceof IdentitiesAddEvent) {
IdentitiesAddEvent identitiesAddEvent = (IdentitiesAddEvent) event;
List<Identity> addedIdentities = projectGroupManager.addCandidates(identitiesAddEvent.getAddIdentities(), project);
identitiesAddEvent.setIdentitiesAddedEvent(addedIdentities);
fireEvent(urequest, Event.CHANGED_EVENT);
} else if (event instanceof IdentitiesRemoveEvent) {
projectGroupManager.removeCandidates(((IdentitiesRemoveEvent) event).getRemovedIdentities(), project);
fireEvent(urequest, Event.CHANGED_EVENT);
} else if (event instanceof IdentitiesMoveEvent) {
final IdentitiesMoveEvent identitiesMoveEvent = (IdentitiesMoveEvent) event;
// OLAT-6342: check identity not in group first!
List<Identity> moveIdents = identitiesMoveEvent.getChosenIdentities();
BusinessGroupAddResponse response = projectGroupManager.acceptCandidates(moveIdents, project, urequest.getIdentity(), projectBrokerModuleConfiguration.isAutoSignOut(), projectBrokerModuleConfiguration.isAcceptSelectionManually());
identitiesMoveEvent.setMovedIdentities(response.getAddedIdentities());
identitiesMoveEvent.setNotMovedIdentities(response.getIdentitiesAlreadyInGroup());
// send mail for all of them
MailTemplate mailTemplate = identitiesMoveEvent.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, identitiesMoveEvent.getMovedIdentities(), mailTemplate, null, metaId, result);
result.append(mailManager.sendMessage(bundles));
if (mailTemplate.getCpfrom()) {
MailBundle ccBundle = mailManager.makeMailBundle(context, urequest.getIdentity(), mailTemplate, null, metaId, result);
result.append(mailManager.sendMessage(ccBundle));
}
MailHelper.printErrorsAndWarnings(result, getWindowControl(), urequest.getUserSession().getRoles().isOLATAdmin(), urequest.getLocale());
}
fireEvent(urequest, Event.CHANGED_EVENT);
// Participant and waiting-list were changed => reload both
projectMemberController.reloadData();
// Do only reload data in case of IdentitiesMoveEvent (IdentitiesAddEvent and reload data resulting in doublicate values)
projectCandidatesController.reloadData();
}
}
use of org.olat.core.util.mail.MailContext in project openolat by klemens.
the class ProjectBrokerMailerImpl method sendEmail.
// ////////////////
// Private Methods
// ////////////////
private MailerResult sendEmail(Identity enrolledIdentity, Project project, String subject, String body, Locale locale) {
MailTemplate enrolledMailTemplate = createMailTemplate(project, enrolledIdentity, subject, body, locale);
MailContext context = new MailContextImpl(project.getProjectBroker(), null, null);
MailerResult result = new MailerResult();
MailBundle bundle = mailManager.makeMailBundle(context, enrolledIdentity, enrolledMailTemplate, null, null, result);
if (bundle != null) {
mailManager.sendMessage(bundle);
}
log.audit("ProjectBroker: sendEmail to identity.name=" + enrolledIdentity.getName() + " , mailerResult.returnCode=" + result.getReturnCode());
return result;
}
use of org.olat.core.util.mail.MailContext in project openolat by klemens.
the class TaskFolderCallback method sendNotificationEmail.
private void sendNotificationEmail(UserRequest ureq, MailTemplate mailTemplate, List<Identity> recipients) {
// send the notification mail
if (mailTemplate != null) {
Identity sender = ureq.getIdentity();
MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
MailerResult result = new MailerResult();
String metaId = UUID.randomUUID().toString().replace("-", "");
MailBundle[] bundles = mailManager.makeMailBundles(context, recipients, mailTemplate, sender, metaId, result);
result.append(mailManager.sendMessage(bundles));
if (mailTemplate.getCpfrom()) {
MailBundle ccBundle = mailManager.makeMailBundle(context, sender, mailTemplate, sender, metaId, result);
result.append(mailManager.sendMessage(ccBundle));
}
MailHelper.printErrorsAndWarnings(result, getWindowControl(), ureq.getUserSession().getRoles().isOLATAdmin(), ureq.getLocale());
}
}
use of org.olat.core.util.mail.MailContext in project openolat by klemens.
the class FinishCallback method sendMail.
private boolean sendMail(UserRequest ureq, WindowControl wControl, StepsRunContext runContext) {
boolean success = false;
try {
ContactList contacts = new ContactList("Forum");
ListWrapper recipients = (ListWrapper) runContext.get(SendMailStepForm.RECIPIENTS);
contacts.addAllIdentites(recipients.getListOfIdentity());
MailContext context = new MailContextImpl(wControl.getBusinessControl().getAsString());
MailBundle bundle = new MailBundle();
bundle.setContext(context);
Identity sender = (Identity) runContext.get(SendMailStepForm.SENDER);
bundle.setFromId(sender != null ? sender : ureq.getIdentity());
bundle.setContactLists(new ArrayList<ContactList>(Arrays.asList(contacts)));
MailTemplate mailTemplate = (MailTemplate) runContext.get(SendMailStepForm.MAIL_TEMPLATE);
bundle.setContent(mailTemplate.getSubjectTemplate(), mailTemplate.getBodyTemplate());
MailerResult result = mailService.sendMessage(bundle);
return success = result.isSuccessful();
} catch (Exception e) {
log.error(null, e);
return success;
}
}
Aggregations