use of org.olat.core.util.mail.MailTemplate in project OpenOLAT by OpenOLAT.
the class GroupController method doImportUsers.
private void doImportUsers(UserRequest ureq) {
removeAsListenerAndDispose(userToGroupWizard);
Step start = new UsersToGroupWizardStep00(ureq, addUserMailDefaultTempl, mandatoryEmail);
StepRunnerCallback finish = new StepRunnerCallback() {
@Override
public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
@SuppressWarnings("unchecked") List<Identity> choosenIdentities = (List<Identity>) runContext.get("members");
MailTemplate customTemplate = (MailTemplate) runContext.get("mailTemplate");
if (choosenIdentities == null || choosenIdentities.size() == 0) {
showError("msg.selectionempty");
} else {
doAddIdentitiesToGroup(uureq, choosenIdentities, customTemplate);
}
return StepsMainRunController.DONE_MODIFIED;
}
};
userToGroupWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("overview.addusers"), "o_sel_secgroup_import_logins_wizard");
listenTo(userToGroupWizard);
getWindowControl().pushAsModalDialog(userToGroupWizard.getInitialComponent());
}
use of org.olat.core.util.mail.MailTemplate 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.MailTemplate 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.MailTemplate in project OpenOLAT by OpenOLAT.
the class IQEditReplaceWizard method doStep3.
private void doStep3(UserRequest ureq) {
StringBuilder extLink = new StringBuilder();
extLink.append(Settings.getServerContextPathURI());
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(course, true);
extLink.append("/url/RepositoryEntry/").append(re.getKey());
extLink.append("/CourseNode/").append(courseNode.getIdent());
String[] bodyArgs = new String[] { course.getCourseTitle(), extLink.toString() };
String subject = translate("inform.users.subject", bodyArgs);
String body = translate("inform.users.body", bodyArgs);
MailTemplate mailTempl = new MailTemplate(subject, body, null) {
@Override
public void putVariablesInMailContext(VelocityContext context, Identity identity) {
// nothing to do
}
};
removeAsListenerAndDispose(mailCtr);
mailCtr = new MailNotificationEditController(getWindowControl(), ureq, mailTempl, false, false, true);
listenTo(mailCtr);
vcStep3 = createVelocityContainer("replacewizard_step3");
vcStep3.put("mailform", mailCtr.getInitialComponent());
setNextWizardStep(translate("replace.wizard.title.step3"), vcStep3);
}
use of org.olat.core.util.mail.MailTemplate 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