Search in sources :

Example 61 with ContactList

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

the class FinishCallback method sendMail.

private boolean sendMail(UserRequest ureq, WindowControl wControl, StepsRunContext runContext) {
    boolean success = false;
    try {
        ContactList contacts = new ContactList("Forum");
        ListWrapper recipients = (ListWrapper) runContext.get(SendMailStepForm.RECIPIENTS);
        contacts.addAllIdentites(recipients.getListOfIdentity());
        MailContext context = new MailContextImpl(wControl.getBusinessControl().getAsString());
        MailBundle bundle = new MailBundle();
        bundle.setContext(context);
        Identity sender = (Identity) runContext.get(SendMailStepForm.SENDER);
        bundle.setFromId(sender != null ? sender : ureq.getIdentity());
        bundle.setContactLists(new ArrayList<ContactList>(Arrays.asList(contacts)));
        MailTemplate mailTemplate = (MailTemplate) runContext.get(SendMailStepForm.MAIL_TEMPLATE);
        bundle.setContent(mailTemplate.getSubjectTemplate(), mailTemplate.getBodyTemplate());
        MailerResult result = mailService.sendMessage(bundle);
        return success = result.isSuccessful();
    } catch (Exception e) {
        log.error(null, e);
        return success;
    }
}
Also used : MailContextImpl(org.olat.core.util.mail.MailContextImpl) MailContext(org.olat.core.util.mail.MailContext) MailerResult(org.olat.core.util.mail.MailerResult) MailTemplate(org.olat.core.util.mail.MailTemplate) ContactList(org.olat.core.util.mail.ContactList) MailBundle(org.olat.core.util.mail.MailBundle) Identity(org.olat.core.id.Identity)

Example 62 with ContactList

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

the class GroupContactController method createContactMessage.

private ContactMessage createContactMessage(Identity from, String contactListName, BusinessGroup businessGroup) {
    ContactMessage contactMessage = new ContactMessage(from);
    ContactList contactList = new ContactList(translate(contactListName));
    List<Identity> members = businessGroupService.getMembers(businessGroup, GroupRoles.coach.name());
    for (Identity member : members) {
        contactList.add(member);
    }
    contactMessage.addEmailTo(contactList);
    return contactMessage;
}
Also used : ContactList(org.olat.core.util.mail.ContactList) Identity(org.olat.core.id.Identity) ContactMessage(org.olat.core.util.mail.ContactMessage)

Example 63 with ContactList

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

the class AbstractMemberListController method doOpenContact.

protected void doOpenContact(UserRequest ureq, MemberView member) {
    removeAsListenerAndDispose(contactCtrl);
    Identity choosenIdentity = securityManager.loadIdentityByKey(member.getIdentityKey());
    String fullname = userManager.getUserDisplayName(choosenIdentity);
    ContactMessage cmsg = new ContactMessage(ureq.getIdentity());
    ContactList emailList = new ContactList(fullname);
    emailList.add(choosenIdentity);
    cmsg.addEmailTo(emailList);
    OLATResourceable ores = OresHelper.createOLATResourceableType("Contact");
    WindowControl bwControl = addToHistory(ureq, ores, null);
    contactCtrl = new ContactFormController(ureq, bwControl, true, false, false, cmsg);
    listenTo(contactCtrl);
    toolbarPanel.pushController(fullname, contactCtrl);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) ContactFormController(org.olat.modules.co.ContactFormController) ContactList(org.olat.core.util.mail.ContactList) Identity(org.olat.core.id.Identity) WindowControl(org.olat.core.gui.control.WindowControl) ContactMessage(org.olat.core.util.mail.ContactMessage)

Example 64 with ContactList

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

the class BusinessGroupServiceImpl method getAdminContactList.

public ContactList getAdminContactList(BusinessGroup group) {
    ContactList list = new ContactList("Contact");
    List<Identity> coaches = getMembers(group, GroupRoles.coach.name());
    if (coaches.isEmpty()) {
        Collection<BusinessGroup> groups = Collections.singletonList(group);
        List<RepositoryEntry> entries = businessGroupRelationDAO.findRepositoryEntries(groups, 0, -1);
        for (RepositoryEntry re : entries) {
            coaches.addAll(repositoryService.getMembers(re, GroupRoles.coach.name()));
        }
        if (coaches.isEmpty()) {
            // get system administrators
            SecurityGroup adminSecGroup = securityManager.findSecurityGroupByName(Constants.GROUP_ADMIN);
            List<Identity> admins = securityManager.getIdentitiesByPowerSearch(null, null, false, new SecurityGroup[] { adminSecGroup }, null, null, null, null, null, null, Identity.STATUS_VISIBLE_LIMIT);
            coaches.addAll(admins);
        }
    }
    list.addAllIdentites(coaches);
    return list;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) ContactList(org.olat.core.util.mail.ContactList) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) SecurityGroup(org.olat.basesecurity.SecurityGroup)

Example 65 with ContactList

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

the class ContactForm method getEmailTo.

/**
 * retrieve the contact list names from the to field, and map them back to the
 * stored contact lists names.
 *
 * @return
 */
protected String getEmailTo() {
    String retVal = "";
    String value;
    if (tto != null)
        value = tto.getValue();
    else
        value = ttoBig.getValue();
    String sep = "";
    int i = 0;
    int j = -1;
    i = value.indexOf("[", j + 1);
    j = value.indexOf("]", j + 2);
    while (i > -1 && j > 0) {
        String contactListName = value.substring(i + 1, j);
        i = value.indexOf("[", j + 1);
        j = value.indexOf("]", j + 2);
        if (contactLists.containsKey(contactListName)) {
            ContactList found = contactLists.get(contactListName);
            retVal += sep + found.toString();
            sep = ", ";
        }
    }
    return retVal;
}
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