use of org.olat.core.util.mail.MailTemplate in project OpenOLAT by OpenOLAT.
the class DENManager method getAddedMailTemplate.
/**
* Generates a mail template for users who were added to a date
* @param identity
* @param event
* @param translator
* @return MailTemplate
*/
protected MailTemplate getAddedMailTemplate(UserRequest ureq, String subjectStr, Translator translator) {
Identity identity = ureq.getIdentity();
String[] bodyArgs = new String[] { identity.getUser().getProperty(UserConstants.FIRSTNAME, ureq.getLocale()), identity.getUser().getProperty(UserConstants.LASTNAME, ureq.getLocale()), UserManager.getInstance().getUserDisplayEmail(identity, ureq.getLocale()), "", subjectStr };
String subject = translator.translate("mail.participants.add.subject", bodyArgs);
String body = translator.translate("mail.participants.add.body", bodyArgs);
MailTemplate mailTempl = new MailTemplate(subject, body, null) {
@Override
public void putVariablesInMailContext(VelocityContext context, Identity ident) {
//
}
};
return mailTempl;
}
use of org.olat.core.util.mail.MailTemplate in project OpenOLAT by OpenOLAT.
the class DENManager method getRemovedMailTemplate.
/**
* Generates a mail template for users who were removed from a date
* @param identity
* @param event
* @param trans
* @return MailTemplate
*/
protected MailTemplate getRemovedMailTemplate(UserRequest ureq, String subjectStr, Translator trans) {
Identity identity = ureq.getIdentity();
String[] bodyArgs = new String[] { identity.getUser().getProperty(UserConstants.FIRSTNAME, ureq.getLocale()), identity.getUser().getProperty(UserConstants.LASTNAME, ureq.getLocale()), UserManager.getInstance().getUserDisplayEmail(identity, ureq.getLocale()), "", subjectStr };
String subject = trans.translate("mail.participants.remove.subject", bodyArgs);
String body = trans.translate("mail.participants.remove.body", bodyArgs);
MailTemplate mailTempl = new MailTemplate(subject, body, null) {
@Override
public void putVariablesInMailContext(VelocityContext context, Identity ident) {
//
}
};
return mailTempl;
}
use of org.olat.core.util.mail.MailTemplate in project OpenOLAT by OpenOLAT.
the class SelectionForm method handleEmailButtonEvent.
private void handleEmailButtonEvent(UserRequest ureq, TableMultiSelectEvent tmse) {
List<Identity> identities = tdm.getObjects(tmse.getSelection());
if (identities.size() > 0) {
selectedIdentities = identities;
MailTemplate deleteMailTemplate = createMailTemplate(translate(KEY_EMAIL_SUBJECT), translate(KEY_EMAIL_BODY));
deleteMailTemplate.setCpfrom(Boolean.FALSE);
deleteMailTemplate.addToContext("lastloginduration", Integer.toString(UserDeletionManager.getInstance().getLastLoginDuration()));
deleteMailTemplate.addToContext("durationdeleteemail", Integer.toString(UserDeletionManager.getInstance().getDeleteEmailDuration()));
removeAsListenerAndDispose(deleteUserMailCtr);
deleteUserMailCtr = new MailNotificationEditController(getWindowControl(), ureq, deleteMailTemplate, true, false, false);
listenTo(deleteUserMailCtr);
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("close"), deleteUserMailCtr.getInitialComponent());
listenTo(cmc);
cmc.activate();
} else {
showWarning("nothing.selected.msg");
}
}
use of org.olat.core.util.mail.MailTemplate in project OpenOLAT by OpenOLAT.
the class UserImportController method createMailTemplateForNewIdentity.
private MailTemplate createMailTemplateForNewIdentity(Identity identity, TransientIdentity transientIdentity) {
// get some data about the actor and fetch the translated subject / body via i18n module
String[] bodyArgs = new String[] { // {0}
identity.getName(), // {1}
identity.getUser().getProperty(UserConstants.FIRSTNAME, null), // {2}
identity.getUser().getProperty(UserConstants.LASTNAME, null), // {3}
UserManager.getInstance().getUserDisplayEmail(identity, getLocale()), // {4}
Settings.getServerContextPathURI(), // {5}
transientIdentity.getPassword() };
Locale locale = I18nManager.getInstance().getLocaleOrDefault(identity.getUser().getPreferences().getLanguage());
Translator translator = Util.createPackageTranslator(UserImportController.class, locale);
String subject = translator.translate("mail.new.identity.subject");
String body = translator.translate("mail.new.identity.text", bodyArgs);
// create a mail template which all these data
MailTemplate mailTempl = new MailTemplate(subject, body, null) {
@Override
public void putVariablesInMailContext(VelocityContext context, Identity identity) {
// Put user variables into velocity context
User user = identity.getUser();
context.put("firstname", user.getProperty(UserConstants.FIRSTNAME, null));
context.put("lastname", user.getProperty(UserConstants.LASTNAME, null));
// the email of the user, needs to stay named 'login'
context.put("login", user.getProperty(UserConstants.EMAIL, null));
}
};
return mailTempl;
}
use of org.olat.core.util.mail.MailTemplate in project OpenOLAT by OpenOLAT.
the class WaitingGroupController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Controller sourceController, Event event) {
if (sourceController == tableCtr) {
if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
// Multiselect events
TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
if (tmse.getAction().equals(COMMAND_MOVE_USER_WAITINGLIST)) {
if (tmse.getSelection().isEmpty()) {
getWindowControl().setWarning(translate("msg.selectionempty"));
} else {
List<Identity> objects = identitiesTableModel.getIdentities(tmse.getSelection());
toTransfer = objects;
removeAsListenerAndDispose(transferMailCtr);
transferMailCtr = new MailNotificationEditController(getWindowControl(), ureq, transferUserMailTempl, true, mandatoryEmail, true);
listenTo(transferMailCtr);
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("close"), transferMailCtr.getInitialComponent());
listenTo(cmc);
cmc.activate();
// don't execute super method
return;
}
}
}
} else if (sourceController == transferMailCtr) {
if (event == Event.DONE_EVENT) {
// fetch configured mail template and finish this controller workflow
MailTemplate customTransferTemplate = transferMailCtr.getMailTemplate();
cmc.deactivate();
IdentitiesMoveEvent identitiesMoveEvent = new IdentitiesMoveEvent(toTransfer);
identitiesMoveEvent.setMailTemplate(customTransferTemplate);
fireEvent(ureq, identitiesMoveEvent);
StringBuilder infoMessage = new StringBuilder();
for (Identity identity : identitiesMoveEvent.getNotMovedIdentities()) {
String fullName = userManager.getUserDisplayName(identity);
infoMessage.append(translate("msg.alreadyinwaiitinggroup", fullName)).append("<br />");
}
// report any errors on screen
if (infoMessage.length() > 0)
getWindowControl().setInfo(infoMessage.toString());
// don't execute super method
return;
} else if (event == Event.CANCELLED_EVENT) {
cmc.deactivate();
// don't execute super method
return;
} else {
throw new RuntimeException("unknown event ::" + event.getCommand());
}
}
// it is no WaitingGroupController event, forward it to super class GroupController
super.event(ureq, sourceController, event);
}
Aggregations