use of org.olat.core.util.mail.MailManager in project openolat by klemens.
the class BulkAssessmentTask method sendFeedback.
private void sendFeedback(List<BulkAssessmentFeedback> feedbacks) {
if (task == null) {
log.error("Haven't a task to know creator and modifiers of the task", null);
return;
}
Identity creator = task.getCreator();
String language = creator.getUser().getPreferences().getLanguage();
Locale locale = I18nManager.getInstance().getLocaleOrDefault(language);
Translator translator = Util.createPackageTranslator(BulkAssessmentOverviewController.class, locale, Util.createPackageTranslator(AssessmentManager.class, locale));
MailManager mailManager = CoreSpringFactory.getImpl(MailManager.class);
TaskExecutorManager taskManager = CoreSpringFactory.getImpl(TaskExecutorManager.class);
String feedbackStr = renderFeedback(feedbacks, translator);
MailBundle mail = new MailBundle();
mail.setToId(creator);
mail.setFrom(WebappHelper.getMailConfig("mailReplyTo"));
List<Identity> modifiers = taskManager.getModifiers(task);
if (modifiers.size() > 0) {
ContactList cc = new ContactList("CC");
cc.addAllIdentites(modifiers);
mail.setContactList(cc);
}
String businessPath = "";
ICourse course = CourseFactory.loadCourse(courseRes);
CourseNode node = course.getRunStructure().getNode(courseNodeIdent);
String courseTitle = course.getCourseTitle();
String nodeTitle = node.getShortTitle();
String numOfAssessedIds = Integer.toString(datas == null ? 0 : datas.getRowsSize());
String date = Formatter.getInstance(locale).formatDateAndTime(new Date());
mail.setContext(new MailContextImpl(courseRes, courseNodeIdent, businessPath));
String subject = translator.translate("confirmation.mail.subject", new String[] { courseTitle, nodeTitle });
String body = translator.translate("confirmation.mail.body", new String[] { courseTitle, nodeTitle, feedbackStr, numOfAssessedIds, date });
mail.setContent(subject, body);
mailManager.sendMessage(mail);
}
use of org.olat.core.util.mail.MailManager in project openolat by klemens.
the class BusinessGroupMailing method sendEmail.
protected static void sendEmail(Identity ureqIdentity, Identity identity, BusinessGroupShort group, MailType type, MailPackage mailing) {
if (mailing != null && !mailing.isSendEmail()) {
return;
}
if (mailing == null) {
BaseSecurity securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
BusinessGroupModule groupModule = CoreSpringFactory.getImpl(BusinessGroupModule.class);
Roles ureqRoles = securityManager.getRoles(ureqIdentity);
if (!groupModule.isMandatoryEnrolmentEmail(ureqRoles)) {
return;
}
}
MailTemplate template = mailing == null ? null : mailing.getTemplate();
if (mailing == null || mailing.getTemplate() == null) {
// booking by myself
if (type != null && type == MailType.addParticipant && ureqIdentity != null && ureqIdentity.equals(identity)) {
template = BGMailHelper.createAddMyselfMailTemplate(group, ureqIdentity);
} else {
template = getDefaultTemplate(type, group, ureqIdentity);
}
} else if (group != null && template.getContext() != null && needTemplateEnhancement(template)) {
BusinessGroupService businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class);
List<RepositoryEntryShort> repoEntries = businessGroupService.findShortRepositoryEntries(Collections.singletonList(group), 0, -1);
template = new MailTemplateDelegate(template, group, repoEntries);
}
MailContext context = mailing == null ? null : mailing.getContext();
if (context == null) {
context = new MailContextImpl(null, null, "[BusinessGroup:" + group.getKey() + "]");
}
MailerResult result = new MailerResult();
String metaId = mailing != null ? mailing.getUuid() : null;
MailManager mailService = CoreSpringFactory.getImpl(MailManager.class);
MailBundle bundle = mailService.makeMailBundle(context, identity, template, ureqIdentity, metaId, result);
if (bundle != null) {
mailService.sendMessage(bundle);
}
if (mailing != null) {
mailing.appendResult(result);
}
}
use of org.olat.core.util.mail.MailManager in project openolat by klemens.
the class GroupController method init.
protected void init(UserRequest ureq, boolean mayModifyMembers, boolean keepAtLeastOne, boolean enableTablePreferences, boolean enableUserSelection, boolean allowDownload, boolean mandatoryEmail, SecurityGroup aSecurityGroup) {
this.securityGroup = aSecurityGroup;
this.mayModifyMembers = mayModifyMembers;
this.keepAtLeastOne = keepAtLeastOne;
this.mandatoryEmail = mandatoryEmail;
securityManager = BaseSecurityManager.getInstance();
imModule = CoreSpringFactory.getImpl(InstantMessagingModule.class);
imService = CoreSpringFactory.getImpl(InstantMessagingService.class);
userManager = CoreSpringFactory.getImpl(UserManager.class);
sessionManager = CoreSpringFactory.getImpl(UserSessionManager.class);
mailManager = CoreSpringFactory.getImpl(MailManager.class);
Roles roles = ureq.getUserSession().getRoles();
BaseSecurityModule securityModule = CoreSpringFactory.getImpl(BaseSecurityModule.class);
isAdministrativeUser = securityModule.isUserAllowedAdminProps(roles);
chatEnabled = imModule.isEnabled() && imModule.isPrivateEnabled();
// default group controller has no mail functionality
this.addUserMailDefaultTempl = null;
this.removeUserMailDefaultTempl = null;
groupmemberview = createVelocityContainer("index");
addUsersButton = LinkFactory.createButtonSmall("overview.addusers", groupmemberview, this);
addUsersButton.setElementCssClass("o_sel_group_import_users");
addUserButton = LinkFactory.createButtonSmall("overview.adduser", groupmemberview, this);
addUserButton.setElementCssClass("o_sel_group_add_user");
if (mayModifyMembers) {
groupmemberview.contextPut("mayadduser", Boolean.TRUE);
}
TableGuiConfiguration tableConfig = new TableGuiConfiguration();
tableConfig.setDownloadOffered(allowDownload);
if (enableTablePreferences) {
// save table preferences for each group seperatly
if (mayModifyMembers) {
tableConfig.setPreferencesOffered(true, "groupcontroller" + securityGroup.getKey());
} else {
// different rowcount...
tableConfig.setPreferencesOffered(true, "groupcontrollerreadonly" + securityGroup.getKey());
}
}
myTrans = userManager.getPropertyHandlerTranslator(getTranslator());
tableCtr = new TableController(tableConfig, ureq, getWindowControl(), myTrans);
listenTo(tableCtr);
initGroupTable(tableCtr, ureq, enableTablePreferences, enableUserSelection);
// set data model
reloadData();
groupmemberview.put("subjecttable", tableCtr.getInitialComponent());
putInitialPanel(groupmemberview);
}
use of org.olat.core.util.mail.MailManager in project OpenOLAT by OpenOLAT.
the class GroupController method init.
protected void init(UserRequest ureq, boolean mayModifyMembers, boolean keepAtLeastOne, boolean enableTablePreferences, boolean enableUserSelection, boolean allowDownload, boolean mandatoryEmail, SecurityGroup aSecurityGroup) {
this.securityGroup = aSecurityGroup;
this.mayModifyMembers = mayModifyMembers;
this.keepAtLeastOne = keepAtLeastOne;
this.mandatoryEmail = mandatoryEmail;
securityManager = BaseSecurityManager.getInstance();
imModule = CoreSpringFactory.getImpl(InstantMessagingModule.class);
imService = CoreSpringFactory.getImpl(InstantMessagingService.class);
userManager = CoreSpringFactory.getImpl(UserManager.class);
sessionManager = CoreSpringFactory.getImpl(UserSessionManager.class);
mailManager = CoreSpringFactory.getImpl(MailManager.class);
Roles roles = ureq.getUserSession().getRoles();
BaseSecurityModule securityModule = CoreSpringFactory.getImpl(BaseSecurityModule.class);
isAdministrativeUser = securityModule.isUserAllowedAdminProps(roles);
chatEnabled = imModule.isEnabled() && imModule.isPrivateEnabled();
// default group controller has no mail functionality
this.addUserMailDefaultTempl = null;
this.removeUserMailDefaultTempl = null;
groupmemberview = createVelocityContainer("index");
addUsersButton = LinkFactory.createButtonSmall("overview.addusers", groupmemberview, this);
addUsersButton.setElementCssClass("o_sel_group_import_users");
addUserButton = LinkFactory.createButtonSmall("overview.adduser", groupmemberview, this);
addUserButton.setElementCssClass("o_sel_group_add_user");
if (mayModifyMembers) {
groupmemberview.contextPut("mayadduser", Boolean.TRUE);
}
TableGuiConfiguration tableConfig = new TableGuiConfiguration();
tableConfig.setDownloadOffered(allowDownload);
if (enableTablePreferences) {
// save table preferences for each group seperatly
if (mayModifyMembers) {
tableConfig.setPreferencesOffered(true, "groupcontroller" + securityGroup.getKey());
} else {
// different rowcount...
tableConfig.setPreferencesOffered(true, "groupcontrollerreadonly" + securityGroup.getKey());
}
}
myTrans = userManager.getPropertyHandlerTranslator(getTranslator());
tableCtr = new TableController(tableConfig, ureq, getWindowControl(), myTrans);
listenTo(tableCtr);
initGroupTable(tableCtr, ureq, enableTablePreferences, enableUserSelection);
// set data model
reloadData();
groupmemberview.put("subjecttable", tableCtr.getInitialComponent());
putInitialPanel(groupmemberview);
}
use of org.olat.core.util.mail.MailManager in project openolat by klemens.
the class RepositoryMailing method sendEmail.
public static void sendEmail(Identity ureqIdentity, Identity identity, RepositoryEntry re, Type type, MailPackage mailing) {
if (mailing != null && !mailing.isSendEmail()) {
return;
}
String email = identity.getUser().getProperty(UserConstants.EMAIL, null);
String emailAlt = identity.getUser().getProperty(UserConstants.INSTITUTIONALEMAIL, null);
if (!StringHelper.containsNonWhitespace(email) && !StringHelper.containsNonWhitespace(emailAlt)) {
return;
}
if (mailing == null) {
BaseSecurity securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
RepositoryModule repositoryModule = CoreSpringFactory.getImpl(RepositoryModule.class);
Roles ureqRoles = securityManager.getRoles(ureqIdentity);
if (!repositoryModule.isMandatoryEnrolmentEmail(ureqRoles)) {
return;
}
}
MailTemplate template = mailing == null ? null : mailing.getTemplate();
if (mailing == null || mailing.getTemplate() == null) {
template = getDefaultTemplate(type, re, ureqIdentity);
}
MailContext context = mailing == null ? null : mailing.getContext();
if (context == null) {
context = new MailContextImpl(null, null, "[RepositoryEntry:" + re.getKey() + "]");
}
String metaId = mailing == null ? null : mailing.getUuid();
MailerResult result = new MailerResult();
MailManager mailManager = CoreSpringFactory.getImpl(MailManager.class);
MailBundle bundle = mailManager.makeMailBundle(context, identity, template, ureqIdentity, metaId, result);
if (bundle != null) {
mailManager.sendMessage(bundle);
}
if (mailing != null) {
mailing.appendResult(result);
}
}
Aggregations