use of org.olat.core.util.mail.MailContextImpl in project OpenOLAT by OpenOLAT.
the class EnrollmentManager method doCancelEnrollment.
public void doCancelEnrollment(final Identity identity, final BusinessGroup enrolledGroup, final ENCourseNode enNode, final CoursePropertyManager coursePropertyManager, WindowControl wControl, Translator trans) {
if (isLogDebugEnabled())
logDebug("doCancelEnrollment");
// 1. Remove group membership, fire events, do loggin etc.
// Remove participant. This will also check if a waiting-list with auto-close-ranks is configurated
// and move the users accordingly
MailPackage doNotSendmailPackage = new MailPackage(false);
businessGroupService.removeParticipants(identity, Collections.singletonList(identity), enrolledGroup, doNotSendmailPackage);
logInfo(" doCancelEnrollment in group " + enrolledGroup, identity.getName());
logInfo(" doCancelEnrollment in group " + enrolledGroup, identity.getName());
// 2. Remove enrollmentdate property
// only remove last time date, not firsttime
Property lastTime = coursePropertyManager.findCourseNodeProperty(enNode, identity, null, ENCourseNode.PROPERTY_RECENT_ENROLLMENT_DATE);
if (lastTime != null) {
coursePropertyManager.deleteProperty(lastTime);
}
// 3. Send notification mail
MailTemplate mailTemplate = BGMailHelper.createRemoveMyselfMailTemplate(enrolledGroup, identity);
// fxdiff VCRP-16: intern mail system
MailContext context = new MailContextImpl(wControl.getBusinessControl().getAsString());
MailerResult result = new MailerResult();
MailBundle bundle = mailManager.makeMailBundle(context, identity, mailTemplate, null, null, result);
if (bundle != null) {
mailManager.sendMessage(bundle);
}
MailHelper.printErrorsAndWarnings(result, wControl, false, trans.getLocale());
}
use of org.olat.core.util.mail.MailContextImpl in project OpenOLAT by OpenOLAT.
the class EnrollmentManager method addUserToParticipantList.
// /////////////////
// Private Methods
// /////////////////
private boolean addUserToParticipantList(Identity identity, BusinessGroup group, ENCourseNode enNode, CoursePropertyManager coursePropertyManager, WindowControl wControl, Translator trans) {
// 2. Set first enrollment date
String nowString = Long.toString(System.currentTimeMillis());
Property firstTime = coursePropertyManager.findCourseNodeProperty(enNode, identity, null, ENCourseNode.PROPERTY_INITIAL_ENROLLMENT_DATE);
if (firstTime == null) {
// create firsttime
firstTime = coursePropertyManager.createCourseNodePropertyInstance(enNode, identity, null, ENCourseNode.PROPERTY_INITIAL_ENROLLMENT_DATE, null, null, nowString, null);
coursePropertyManager.saveProperty(firstTime);
}
// 3. Set enrollmentdate property
Property thisTime = coursePropertyManager.findCourseNodeProperty(enNode, identity, null, ENCourseNode.PROPERTY_RECENT_ENROLLMENT_DATE);
if (thisTime == null) {
// create firsttime
thisTime = coursePropertyManager.createCourseNodePropertyInstance(enNode, identity, null, ENCourseNode.PROPERTY_RECENT_ENROLLMENT_DATE, null, null, nowString, null);
coursePropertyManager.saveProperty(thisTime);
} else {
thisTime.setStringValue(nowString);
coursePropertyManager.updateProperty(thisTime);
}
// 4. Send notification mail
MailTemplate mailTemplate = BGMailHelper.createAddMyselfMailTemplate(group, identity);
MailContext context = new MailContextImpl(wControl.getBusinessControl().getAsString());
MailerResult result = new MailerResult();
MailBundle bundle = mailManager.makeMailBundle(context, identity, mailTemplate, null, null, result);
if (bundle != null) {
mailManager.sendMessage(bundle);
}
MailHelper.printErrorsAndWarnings(result, wControl, false, trans.getLocale());
return true;
}
use of org.olat.core.util.mail.MailContextImpl in project OpenOLAT by OpenOLAT.
the class EnrollmentManager method addUserToWaitingList.
private boolean addUserToWaitingList(Identity identity, BusinessGroup group, ENCourseNode enNode, CoursePropertyManager coursePropertyManager, WindowControl wControl, Translator trans) {
// <- moved to bgs 1. Add user to group, fire events, do loggin etc.
// 2. Set first waiting-list date
String nowString = Long.toString(System.currentTimeMillis());
Property firstTime = coursePropertyManager.findCourseNodeProperty(enNode, identity, null, ENCourseNode.PROPERTY_INITIAL_WAITINGLIST_DATE);
if (firstTime == null) {
// create firsttime
firstTime = coursePropertyManager.createCourseNodePropertyInstance(enNode, identity, null, ENCourseNode.PROPERTY_INITIAL_WAITINGLIST_DATE, null, null, nowString, null);
coursePropertyManager.saveProperty(firstTime);
}
// 3. Set waiting-list date property
Property thisTime = coursePropertyManager.findCourseNodeProperty(enNode, identity, null, ENCourseNode.PROPERTY_RECENT_WAITINGLIST_DATE);
if (thisTime == null) {
// create firsttime
thisTime = coursePropertyManager.createCourseNodePropertyInstance(enNode, identity, null, ENCourseNode.PROPERTY_RECENT_WAITINGLIST_DATE, null, null, nowString, null);
coursePropertyManager.saveProperty(thisTime);
} else {
thisTime.setStringValue(nowString);
coursePropertyManager.updateProperty(thisTime);
}
// 4. Send notification mail
MailTemplate mailTemplate = BGMailHelper.createAddWaitinglistMailTemplate(group, identity);
// fxdiff VCRP-16: intern mail system
MailContext context = new MailContextImpl(wControl.getBusinessControl().getAsString());
MailerResult result = new MailerResult();
MailBundle bundle = mailManager.makeMailBundle(context, identity, mailTemplate, null, null, result);
if (bundle != null) {
mailManager.sendMessage(bundle);
}
MailHelper.printErrorsAndWarnings(result, wControl, false, trans.getLocale());
return true;
}
use of org.olat.core.util.mail.MailContextImpl in project OpenOLAT by OpenOLAT.
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.MailContextImpl in project OpenOLAT by OpenOLAT.
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);
}
Aggregations