Search in sources :

Example 81 with ContactList

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);
}
Also used : Locale(java.util.Locale) Translator(org.olat.core.gui.translator.Translator) ContactList(org.olat.core.util.mail.ContactList) MailBundle(org.olat.core.util.mail.MailBundle)

Example 82 with ContactList

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);
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) ContactFormController(org.olat.modules.co.ContactFormController) ContactList(org.olat.core.util.mail.ContactList) ContactMessage(org.olat.core.util.mail.ContactMessage)

Example 83 with ContactList

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);
}
Also used : MailContextImpl(org.olat.core.util.mail.MailContextImpl) MailContext(org.olat.core.util.mail.MailContext) ContactList(org.olat.core.util.mail.ContactList) MailBundle(org.olat.core.util.mail.MailBundle) Identity(org.olat.core.id.Identity)

Example 84 with ContactList

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();
    }
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) ContactFormController(org.olat.modules.co.ContactFormController) ContactList(org.olat.core.util.mail.ContactList) Identity(org.olat.core.id.Identity) ContactMessage(org.olat.core.util.mail.ContactMessage)

Example 85 with ContactList

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;
}
Also used : LeaveOption(org.olat.group.model.LeaveOption) ContactList(org.olat.core.util.mail.ContactList)

Aggregations

ContactList (org.olat.core.util.mail.ContactList)92 Identity (org.olat.core.id.Identity)66 ContactMessage (org.olat.core.util.mail.ContactMessage)28 MailBundle (org.olat.core.util.mail.MailBundle)26 ContactFormController (org.olat.modules.co.ContactFormController)22 MailContextImpl (org.olat.core.util.mail.MailContextImpl)18 MailerResult (org.olat.core.util.mail.MailerResult)18 MailContext (org.olat.core.util.mail.MailContext)16 ArrayList (java.util.ArrayList)14 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)14 RepositoryEntry (org.olat.repository.RepositoryEntry)10 HashSet (java.util.HashSet)8 Test (org.junit.Test)8 BusinessGroup (org.olat.group.BusinessGroup)7 Locale (java.util.Locale)6 WindowControl (org.olat.core.gui.control.WindowControl)6 Translator (org.olat.core.gui.translator.Translator)6 File (java.io.File)4 Date (java.util.Date)4 Address (javax.mail.Address)4