Search in sources :

Example 1 with ContactList

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

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

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

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

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

the class PublishController method sendInvitation.

private void sendInvitation(List<Identity> identities, MailTemplate mailTemplate) {
    ContactList contactList = new ContactList("Invitation");
    contactList.addAllIdentites(identities);
    boolean success = false;
    try {
        MailContext context = new MailContextImpl(binder, null, getWindowControl().getBusinessControl().getAsString());
        MailBundle bundle = new MailBundle();
        bundle.setContext(context);
        bundle.setFromId(getIdentity());
        bundle.setContactList(contactList);
        bundle.setContent(mailTemplate.getSubjectTemplate(), mailTemplate.getBodyTemplate());
        MailerResult result = mailManager.sendMessage(bundle);
        success = result.isSuccessful();
    } catch (Exception e) {
        logError("Error on sending invitation mail to contactlist, invalid address.", e);
    }
    if (success) {
        showInfo("invitation.mail.success");
    } else {
        showError("invitation.mail.failure");
    }
}
Also used : MailContextImpl(org.olat.core.util.mail.MailContextImpl) MailContext(org.olat.core.util.mail.MailContext) MailerResult(org.olat.core.util.mail.MailerResult) ContactList(org.olat.core.util.mail.ContactList) MailBundle(org.olat.core.util.mail.MailBundle)

Example 4 with ContactList

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

the class StudentCoursesController method contact.

private void contact(UserRequest ureq) {
    removeAsListenerAndDispose(cmc);
    ContactMessage cmsg = new ContactMessage(getIdentity());
    ContactList contactList = new ContactList("to");
    contactList.add(student);
    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 5 with ContactList

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

the class ContactForm method addEmailTo.

/**
 * add a ContactList as EmailTo:
 *
 * @param emailList
 */
public void addEmailTo(ContactList emailList) {
    if (contactLists.containsKey(emailList.getName())) {
        // there is already a ContactList with this name...
        ContactList existing = contactLists.get(emailList.getName());
        // , merge their values.
        existing.add(emailList);
    // the form itself must not be updated, because it already displays
    // the name.
    } else {
        // a new ContactList, put it into contactLists
        contactLists.put(emailList.getName(), emailList);
        // and add its name in the form
        addContactFormEmailTo("[" + emailList.getName() + "]");
    }
}
Also used : 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