Search in sources :

Example 51 with ContactList

use of org.olat.core.util.mail.ContactList in project OpenOLAT by OpenOLAT.

the class BusinessGroupServiceTest method allowToLeavingBusinessGroup_defaultSettings_groupOverride.

/**
 * Test the default settings but the author set the business group to "leaving not allowed".
 */
@Test
public void allowToLeavingBusinessGroup_defaultSettings_groupOverride() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("leave-auth-2-" + UUID.randomUUID().toString());
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("leave-bg-2-");
    BusinessGroup group = businessGroupService.createBusinessGroup(author, "Leaving group", "But you cannot leave :-(", new Integer(0), new Integer(2), false, false, null);
    businessGroupRelationDao.addRole(participant, group, GroupRoles.participant.name());
    dbInstance.commitAndCloseSession();
    // set to not allowed to leave
    group = businessGroupService.updateAllowToLeaveBusinessGroup(group, false);
    dbInstance.commitAndCloseSession();
    LeaveOption optionToLeave = businessGroupService.isAllowToLeaveBusinessGroup(participant, group);
    Assert.assertNotNull(optionToLeave);
    Assert.assertFalse(optionToLeave.isAllowToLeave());
    ContactList contacts = optionToLeave.getContacts();
    Assert.assertNotNull(contacts);
    Collection<Identity> contactList = contacts.getIdentiEmails().values();
    Assert.assertNotNull(contactList);
    Assert.assertEquals(1, contactList.size());
    Assert.assertTrue(contactList.contains(author));
}
Also used : LeaveOption(org.olat.group.model.LeaveOption) BusinessGroup(org.olat.group.BusinessGroup) ContactList(org.olat.core.util.mail.ContactList) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 52 with ContactList

use of org.olat.core.util.mail.ContactList in project OpenOLAT by OpenOLAT.

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 53 with ContactList

use of org.olat.core.util.mail.ContactList in project OpenOLAT by OpenOLAT.

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 54 with ContactList

use of org.olat.core.util.mail.ContactList in project OpenOLAT by OpenOLAT.

the class CORunController method retrieveParticipantsFromGroups.

private ContactList retrieveParticipantsFromGroups(List<Long> groupKeys) {
    List<Identity> participiants = cgm.getParticipantsFromBusinessGroups(groupKeys);
    ContactList cl = new ContactList(translate("form.message.chckbx.partips"));
    cl.addAllIdentites(participiants);
    return cl;
}
Also used : ContactList(org.olat.core.util.mail.ContactList) Identity(org.olat.core.id.Identity)

Example 55 with ContactList

use of org.olat.core.util.mail.ContactList in project OpenOLAT by OpenOLAT.

the class CORunController method retrieveCoachesFromCourse.

private ContactList retrieveCoachesFromCourse() {
    List<Identity> coaches = cgm.getCoaches();
    ContactList cl = new ContactList(translate("form.message.chckbx.partips"));
    cl.addAllIdentites(coaches);
    return cl;
}
Also used : ContactList(org.olat.core.util.mail.ContactList) Identity(org.olat.core.id.Identity)

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