use of org.olat.core.util.mail.ContactList in project openolat by klemens.
the class CertificatesManagerImpl method sendCertificate.
private MailerResult sendCertificate(Identity to, RepositoryEntry entry, File certificateFile) {
MailBundle bundle = new MailBundle();
bundle.setToId(to);
bundle.setFrom(WebappHelper.getMailConfig("mailReplyTo"));
List<String> bccs = certificatesModule.getCertificatesBccEmails();
if (bccs.size() > 0) {
ContactList bcc = new ContactList();
bccs.forEach(email -> {
bcc.add(email);
});
bundle.setContactList(bcc);
}
String[] args = new String[] { entry.getDisplayname(), userManager.getUserDisplayName(to) };
String userLanguage = to.getUser().getPreferences().getLanguage();
Locale locale = i18nManager.getLocaleOrDefault(userLanguage);
Translator translator = Util.createPackageTranslator(CertificateController.class, locale);
String subject = translator.translate("certification.email.subject", args);
String body = translator.translate("certification.email.body", args);
bundle.setContent(subject, body, certificateFile);
return mailManager.sendMessage(bundle);
}
use of org.olat.core.util.mail.ContactList in project openolat by klemens.
the class CertificateAndEfficiencyStatementController method contact.
private void contact(UserRequest ureq) {
removeAsListenerAndDispose(cmc);
ContactMessage cmsg = new ContactMessage(getIdentity());
ContactList contactList = new ContactList("to");
contactList.add(statementOwner);
cmsg.addEmailTo(contactList);
contactCtrl = new ContactFormController(ureq, getWindowControl(), true, false, false, cmsg);
listenTo(contactCtrl);
cmc = new CloseableModalController(getWindowControl(), translate("close"), contactCtrl.getInitialComponent());
cmc.activate();
listenTo(cmc);
}
use of org.olat.core.util.mail.ContactList 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.ContactList in project openolat by klemens.
the class GTACoachController method doOpenMailForm.
private void doOpenMailForm(UserRequest ureq) {
// build recipient list
ContactList contactList = null;
if (assessedGroup != null) {
String toName = assessedGroup.getName();
contactList = new ContactList(toName);
List<Identity> memberList = businessGroupService.getMembers(assessedGroup, GroupRoles.participant.name());
contactList.addAllIdentites(memberList);
} else if (assessedIdentity != null) {
String toName = userManager.getUserDisplayName(assessedIdentity);
contactList = new ContactList(toName);
contactList.add(assessedIdentity);
}
// open dialog with mail form
if (contactList != null && contactList.getEmailsAsStrings().size() > 0) {
removeAsListenerAndDispose(emailController);
ContactMessage cmsg = new ContactMessage(ureq.getIdentity());
cmsg.addEmailTo(contactList);
emailController = new ContactFormController(ureq, getWindowControl(), true, false, false, cmsg);
listenTo(emailController);
removeAsListenerAndDispose(cmc);
// same title as link button
String title = translate(emailLink.getI18n());
cmc = new CloseableModalController(getWindowControl(), translate("close"), emailController.getInitialComponent(), true, title);
listenTo(cmc);
cmc.activate();
}
}
use of org.olat.core.util.mail.ContactList in project openolat by klemens.
the class BusinessGroupServiceImpl method isAllowToLeaveBusinessGroup.
@Override
public LeaveOption isAllowToLeaveBusinessGroup(Identity identity, BusinessGroup group) {
LeaveOption opt;
if (groupModule.isAllowLeavingGroupOverride()) {
if (group.isAllowToLeave()) {
opt = new LeaveOption();
} else {
ContactList list = getAdminContactList(group);
opt = new LeaveOption(false, list);
}
} else if (groupModule.isAllowLeavingGroupCreatedByAuthors() && groupModule.isAllowLeavingGroupCreatedByLearners()) {
opt = new LeaveOption();
} else if (!groupModule.isAllowLeavingGroupCreatedByAuthors() && !groupModule.isAllowLeavingGroupCreatedByLearners()) {
ContactList list = getAdminContactList(group);
opt = new LeaveOption(false, list);
} else {
int numOfCoaches = countMembers(group, GroupRoles.coach.name());
if (numOfCoaches == 0) {
int numOfResources = businessGroupRelationDAO.countResources(group);
if (numOfResources > 0) {
// author group
if (groupModule.isAllowLeavingGroupCreatedByAuthors()) {
opt = new LeaveOption();
} else {
ContactList list = getAdminContactList(group);
opt = new LeaveOption(false, list);
}
// learner group
} else if (groupModule.isAllowLeavingGroupCreatedByLearners()) {
opt = new LeaveOption();
} else {
ContactList list = getAdminContactList(group);
opt = new LeaveOption(false, list);
}
} else {
int numOfAuthors = businessGroupRelationDAO.countAuthors(group);
if (numOfAuthors > 0) {
if (groupModule.isAllowLeavingGroupCreatedByAuthors()) {
opt = new LeaveOption();
} else {
ContactList list = getAdminContactList(group);
opt = new LeaveOption(false, list);
}
} else if (groupModule.isAllowLeavingGroupCreatedByLearners()) {
opt = new LeaveOption();
} else {
ContactList list = getAdminContactList(group);
opt = new LeaveOption(false, list);
}
}
}
return opt;
}
Aggregations